From 0a98a85fb697d398237f046e10a21370d8ac921a Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Thu, 2 Aug 2018 15:53:41 -0400 Subject: [PATCH 1/2] chore(api): bump deployments from apps/v1beta2 to apps/v1 --- ...e_install_strategy_deployment_interface.go | 68 +++++----- pkg/api/client/deployment_install_client.go | 16 +-- pkg/controller/install/deployment.go | 10 +- pkg/controller/install/deployment_test.go | 34 ++--- pkg/controller/install/status_viewer.go | 8 +- pkg/controller/install/status_viewer_test.go | 2 +- pkg/lib/operatorclient/client.go | 22 ++-- pkg/lib/operatorclient/deployment.go | 46 +++---- pkg/lib/operatorclient/mock_client.go | 118 +++++++++--------- pkg/lib/operatorclient/patch.go | 30 ++--- test/e2e/csv_e2e_test.go | 6 +- test/e2e/installplan_e2e_test.go | 4 +- test/e2e/ocs_e2e_test.go | 8 +- test/e2e/subscription_e2e_test.go | 4 +- 14 files changed, 188 insertions(+), 188 deletions(-) diff --git a/pkg/api/client/clientfakes/fake_install_strategy_deployment_interface.go b/pkg/api/client/clientfakes/fake_install_strategy_deployment_interface.go index 1e230d3522..17d517af5d 100644 --- a/pkg/api/client/clientfakes/fake_install_strategy_deployment_interface.go +++ b/pkg/api/client/clientfakes/fake_install_strategy_deployment_interface.go @@ -6,7 +6,7 @@ import ( "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client" "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil" - appsv1beta2 "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1beta1rbac "k8s.io/api/rbac/v1beta1" ) @@ -52,30 +52,30 @@ type FakeInstallStrategyDeploymentInterface struct { result1 *corev1.ServiceAccount result2 error } - CreateDeploymentStub func(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) + CreateDeploymentStub func(deployment *appsv1.Deployment) (*appsv1.Deployment, error) createDeploymentMutex sync.RWMutex createDeploymentArgsForCall []struct { - deployment *appsv1beta2.Deployment + deployment *appsv1.Deployment } createDeploymentReturns struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error } createDeploymentReturnsOnCall map[int]struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error } - CreateOrUpdateDeploymentStub func(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) + CreateOrUpdateDeploymentStub func(deployment *appsv1.Deployment) (*appsv1.Deployment, error) createOrUpdateDeploymentMutex sync.RWMutex createOrUpdateDeploymentArgsForCall []struct { - deployment *appsv1beta2.Deployment + deployment *appsv1.Deployment } createOrUpdateDeploymentReturns struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error } createOrUpdateDeploymentReturnsOnCall map[int]struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error } DeleteDeploymentStub func(name string) error @@ -102,17 +102,17 @@ type FakeInstallStrategyDeploymentInterface struct { result1 *corev1.ServiceAccount result2 error } - FindAnyDeploymentsMatchingNamesStub func(depNames []string) ([]*appsv1beta2.Deployment, error) + FindAnyDeploymentsMatchingNamesStub func(depNames []string) ([]*appsv1.Deployment, error) findAnyDeploymentsMatchingNamesMutex sync.RWMutex findAnyDeploymentsMatchingNamesArgsForCall []struct { depNames []string } findAnyDeploymentsMatchingNamesReturns struct { - result1 []*appsv1beta2.Deployment + result1 []*appsv1.Deployment result2 error } findAnyDeploymentsMatchingNamesReturnsOnCall map[int]struct { - result1 []*appsv1beta2.Deployment + result1 []*appsv1.Deployment result2 error } invocations map[string][][]interface{} @@ -273,11 +273,11 @@ func (fake *FakeInstallStrategyDeploymentInterface) EnsureServiceAccountReturnsO }{result1, result2} } -func (fake *FakeInstallStrategyDeploymentInterface) CreateDeployment(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) { +func (fake *FakeInstallStrategyDeploymentInterface) CreateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error) { fake.createDeploymentMutex.Lock() ret, specificReturn := fake.createDeploymentReturnsOnCall[len(fake.createDeploymentArgsForCall)] fake.createDeploymentArgsForCall = append(fake.createDeploymentArgsForCall, struct { - deployment *appsv1beta2.Deployment + deployment *appsv1.Deployment }{deployment}) fake.recordInvocation("CreateDeployment", []interface{}{deployment}) fake.createDeploymentMutex.Unlock() @@ -296,39 +296,39 @@ func (fake *FakeInstallStrategyDeploymentInterface) CreateDeploymentCallCount() return len(fake.createDeploymentArgsForCall) } -func (fake *FakeInstallStrategyDeploymentInterface) CreateDeploymentArgsForCall(i int) *appsv1beta2.Deployment { +func (fake *FakeInstallStrategyDeploymentInterface) CreateDeploymentArgsForCall(i int) *appsv1.Deployment { fake.createDeploymentMutex.RLock() defer fake.createDeploymentMutex.RUnlock() return fake.createDeploymentArgsForCall[i].deployment } -func (fake *FakeInstallStrategyDeploymentInterface) CreateDeploymentReturns(result1 *appsv1beta2.Deployment, result2 error) { +func (fake *FakeInstallStrategyDeploymentInterface) CreateDeploymentReturns(result1 *appsv1.Deployment, result2 error) { fake.CreateDeploymentStub = nil fake.createDeploymentReturns = struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error }{result1, result2} } -func (fake *FakeInstallStrategyDeploymentInterface) CreateDeploymentReturnsOnCall(i int, result1 *appsv1beta2.Deployment, result2 error) { +func (fake *FakeInstallStrategyDeploymentInterface) CreateDeploymentReturnsOnCall(i int, result1 *appsv1.Deployment, result2 error) { fake.CreateDeploymentStub = nil if fake.createDeploymentReturnsOnCall == nil { fake.createDeploymentReturnsOnCall = make(map[int]struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error }) } fake.createDeploymentReturnsOnCall[i] = struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error }{result1, result2} } -func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeployment(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) { +func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error) { fake.createOrUpdateDeploymentMutex.Lock() ret, specificReturn := fake.createOrUpdateDeploymentReturnsOnCall[len(fake.createOrUpdateDeploymentArgsForCall)] fake.createOrUpdateDeploymentArgsForCall = append(fake.createOrUpdateDeploymentArgsForCall, struct { - deployment *appsv1beta2.Deployment + deployment *appsv1.Deployment }{deployment}) fake.recordInvocation("CreateOrUpdateDeployment", []interface{}{deployment}) fake.createOrUpdateDeploymentMutex.Unlock() @@ -347,30 +347,30 @@ func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeploymentCall return len(fake.createOrUpdateDeploymentArgsForCall) } -func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeploymentArgsForCall(i int) *appsv1beta2.Deployment { +func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeploymentArgsForCall(i int) *appsv1.Deployment { fake.createOrUpdateDeploymentMutex.RLock() defer fake.createOrUpdateDeploymentMutex.RUnlock() return fake.createOrUpdateDeploymentArgsForCall[i].deployment } -func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeploymentReturns(result1 *appsv1beta2.Deployment, result2 error) { +func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeploymentReturns(result1 *appsv1.Deployment, result2 error) { fake.CreateOrUpdateDeploymentStub = nil fake.createOrUpdateDeploymentReturns = struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error }{result1, result2} } -func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeploymentReturnsOnCall(i int, result1 *appsv1beta2.Deployment, result2 error) { +func (fake *FakeInstallStrategyDeploymentInterface) CreateOrUpdateDeploymentReturnsOnCall(i int, result1 *appsv1.Deployment, result2 error) { fake.CreateOrUpdateDeploymentStub = nil if fake.createOrUpdateDeploymentReturnsOnCall == nil { fake.createOrUpdateDeploymentReturnsOnCall = make(map[int]struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error }) } fake.createOrUpdateDeploymentReturnsOnCall[i] = struct { - result1 *appsv1beta2.Deployment + result1 *appsv1.Deployment result2 error }{result1, result2} } @@ -474,7 +474,7 @@ func (fake *FakeInstallStrategyDeploymentInterface) GetServiceAccountByNameRetur }{result1, result2} } -func (fake *FakeInstallStrategyDeploymentInterface) FindAnyDeploymentsMatchingNames(depNames []string) ([]*appsv1beta2.Deployment, error) { +func (fake *FakeInstallStrategyDeploymentInterface) FindAnyDeploymentsMatchingNames(depNames []string) ([]*appsv1.Deployment, error) { var depNamesCopy []string if depNames != nil { depNamesCopy = make([]string, len(depNames)) @@ -508,24 +508,24 @@ func (fake *FakeInstallStrategyDeploymentInterface) FindAnyDeploymentsMatchingNa return fake.findAnyDeploymentsMatchingNamesArgsForCall[i].depNames } -func (fake *FakeInstallStrategyDeploymentInterface) FindAnyDeploymentsMatchingNamesReturns(result1 []*appsv1beta2.Deployment, result2 error) { +func (fake *FakeInstallStrategyDeploymentInterface) FindAnyDeploymentsMatchingNamesReturns(result1 []*appsv1.Deployment, result2 error) { fake.FindAnyDeploymentsMatchingNamesStub = nil fake.findAnyDeploymentsMatchingNamesReturns = struct { - result1 []*appsv1beta2.Deployment + result1 []*appsv1.Deployment result2 error }{result1, result2} } -func (fake *FakeInstallStrategyDeploymentInterface) FindAnyDeploymentsMatchingNamesReturnsOnCall(i int, result1 []*appsv1beta2.Deployment, result2 error) { +func (fake *FakeInstallStrategyDeploymentInterface) FindAnyDeploymentsMatchingNamesReturnsOnCall(i int, result1 []*appsv1.Deployment, result2 error) { fake.FindAnyDeploymentsMatchingNamesStub = nil if fake.findAnyDeploymentsMatchingNamesReturnsOnCall == nil { fake.findAnyDeploymentsMatchingNamesReturnsOnCall = make(map[int]struct { - result1 []*appsv1beta2.Deployment + result1 []*appsv1.Deployment result2 error }) } fake.findAnyDeploymentsMatchingNamesReturnsOnCall[i] = struct { - result1 []*appsv1beta2.Deployment + result1 []*appsv1.Deployment result2 error }{result1, result2} } diff --git a/pkg/api/client/deployment_install_client.go b/pkg/api/client/deployment_install_client.go index 87827cc335..10393b6eef 100644 --- a/pkg/api/client/deployment_install_client.go +++ b/pkg/api/client/deployment_install_client.go @@ -5,7 +5,7 @@ import ( "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient" "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil" "github.com/pkg/errors" - appsv1beta2 "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1beta1rbac "k8s.io/api/rbac/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -18,11 +18,11 @@ type InstallStrategyDeploymentInterface interface { CreateRole(role *v1beta1rbac.Role) (*v1beta1rbac.Role, error) CreateRoleBinding(roleBinding *v1beta1rbac.RoleBinding) (*v1beta1rbac.RoleBinding, error) EnsureServiceAccount(serviceAccount *corev1.ServiceAccount, owner ownerutil.Owner) (*corev1.ServiceAccount, error) - CreateDeployment(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) - CreateOrUpdateDeployment(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) + CreateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error) + CreateOrUpdateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error) DeleteDeployment(name string) error GetServiceAccountByName(serviceAccountName string) (*corev1.ServiceAccount, error) - FindAnyDeploymentsMatchingNames(depNames []string) ([]*appsv1beta2.Deployment, error) + FindAnyDeploymentsMatchingNames(depNames []string) ([]*appsv1.Deployment, error) } type InstallStrategyDeploymentClientForNamespace struct { @@ -79,7 +79,7 @@ func (c *InstallStrategyDeploymentClientForNamespace) EnsureServiceAccount(servi return c.opClient.UpdateServiceAccount(foundAccount) } -func (c *InstallStrategyDeploymentClientForNamespace) CreateDeployment(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) { +func (c *InstallStrategyDeploymentClientForNamespace) CreateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error) { return c.opClient.CreateDeployment(deployment) } @@ -90,7 +90,7 @@ func (c *InstallStrategyDeploymentClientForNamespace) DeleteDeployment(name stri return c.opClient.DeleteDeployment(c.Namespace, name, immediateForegroundDelete) } -func (c *InstallStrategyDeploymentClientForNamespace) CreateOrUpdateDeployment(deployment *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) { +func (c *InstallStrategyDeploymentClientForNamespace) CreateOrUpdateDeployment(deployment *appsv1.Deployment) (*appsv1.Deployment, error) { d, _, err := c.opClient.CreateOrRollingUpdateDeployment(deployment) return d, err } @@ -99,8 +99,8 @@ func (c *InstallStrategyDeploymentClientForNamespace) GetServiceAccountByName(se return c.opClient.KubernetesInterface().CoreV1().ServiceAccounts(c.Namespace).Get(serviceAccountName, metav1.GetOptions{}) } -func (c *InstallStrategyDeploymentClientForNamespace) FindAnyDeploymentsMatchingNames(depNames []string) ([]*appsv1beta2.Deployment, error) { - var deployments []*appsv1beta2.Deployment +func (c *InstallStrategyDeploymentClientForNamespace) FindAnyDeploymentsMatchingNames(depNames []string) ([]*appsv1.Deployment, error) { + var deployments []*appsv1.Deployment for _, depName := range depNames { fetchedDep, err := c.opClient.GetDeployment(c.Namespace, depName) diff --git a/pkg/controller/install/deployment.go b/pkg/controller/install/deployment.go index ae9f8fecc1..ea7974b040 100644 --- a/pkg/controller/install/deployment.go +++ b/pkg/controller/install/deployment.go @@ -4,7 +4,7 @@ import ( "fmt" log "github.com/sirupsen/logrus" - "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbac "k8s.io/api/rbac/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -25,8 +25,8 @@ type StrategyDeploymentPermissions struct { // StrategyDeploymentSpec contains the name and spec for the deployment ALM should create type StrategyDeploymentSpec struct { - Name string `json:"name"` - Spec v1beta2.DeploymentSpec `json:"spec"` + Name string `json:"name"` + Spec appsv1.DeploymentSpec `json:"spec"` } // StrategyDetailsDeployment represents the parsed details of a Deployment @@ -104,7 +104,7 @@ func (i *StrategyDeploymentInstaller) installPermissions(perms []StrategyDeploym func (i *StrategyDeploymentInstaller) installDeployments(deps []StrategyDeploymentSpec) error { for _, d := range deps { // Create or Update Deployment - dep := &v1beta2.Deployment{Spec: d.Spec} + dep := &appsv1.Deployment{Spec: d.Spec} dep.SetName(d.Name) dep.SetNamespace(i.owner.GetNamespace()) ownerutil.AddNonBlockingOwner(dep, i.owner) @@ -209,7 +209,7 @@ func (i *StrategyDeploymentInstaller) checkForDeployments(deploymentSpecs []Stra } // compare deployments to see if any need to be created/updated - existingMap := map[string]*v1beta2.Deployment{} + existingMap := map[string]*appsv1.Deployment{} for _, d := range existingDeployments { existingMap[d.GetName()] = d } diff --git a/pkg/controller/install/deployment_test.go b/pkg/controller/install/deployment_test.go index 86d003d502..c0abc4b328 100644 --- a/pkg/controller/install/deployment_test.go +++ b/pkg/controller/install/deployment_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1beta1rbac "k8s.io/api/rbac/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -24,10 +24,10 @@ var ( BlockOwnerDeletion = false ) -func testDeployment(name, namespace string, mockOwner ownerutil.Owner) v1beta2.Deployment { +func testDeployment(name, namespace string, mockOwner ownerutil.Owner) appsv1.Deployment { testDeploymentLabels := map[string]string{"alm-owner-name": mockOwner.GetName(), "alm-owner-namespace": mockOwner.GetNamespace()} - deployment := v1beta2.Deployment{ + deployment := appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Name: name, @@ -124,10 +124,10 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) { strategyDeploymentSpecs []StrategyDeploymentSpec } type setup struct { - existingDeployments []*v1beta2.Deployment + existingDeployments []*appsv1.Deployment } type createOrUpdateMock struct { - expectedDeployment v1beta2.Deployment + expectedDeployment appsv1.Deployment returnError error } tests := []struct { @@ -143,20 +143,20 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) { strategyDeploymentSpecs: []StrategyDeploymentSpec{ { Name: "test-deployment-1", - Spec: v1beta2.DeploymentSpec{}, + Spec: appsv1.DeploymentSpec{}, }, { Name: "test-deployment-2", - Spec: v1beta2.DeploymentSpec{}, + Spec: appsv1.DeploymentSpec{}, }, { Name: "test-deployment-3", - Spec: v1beta2.DeploymentSpec{}, + Spec: appsv1.DeploymentSpec{}, }, }, }, setup: setup{ - existingDeployments: []*v1beta2.Deployment{ + existingDeployments: []*appsv1.Deployment{ { ObjectMeta: metav1.ObjectMeta{ Name: "test-deployment-1", @@ -166,7 +166,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "test-deployment-3", }, - Spec: v1beta2.DeploymentSpec{ + Spec: appsv1.DeploymentSpec{ Paused: false, // arbitrary spec difference }, }, @@ -174,7 +174,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) { }, createOrUpdateMocks: []createOrUpdateMock{ { - expectedDeployment: v1beta2.Deployment{ + expectedDeployment: appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "test-deployment-1", Namespace: mockOwner.GetNamespace(), @@ -188,7 +188,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) { returnError: nil, }, { - expectedDeployment: v1beta2.Deployment{ + expectedDeployment: appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "test-deployment-2", Namespace: mockOwner.GetNamespace(), @@ -202,7 +202,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) { returnError: nil, }, { - expectedDeployment: v1beta2.Deployment{ + expectedDeployment: appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "test-deployment-3", Namespace: mockOwner.GetNamespace(), @@ -226,7 +226,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) { for i, m := range tt.createOrUpdateMocks { fakeClient.CreateDeploymentReturns(nil, m.returnError) - defer func(i int, expectedDeployment v1beta2.Deployment) { + defer func(i int, expectedDeployment appsv1.Deployment) { dep := fakeClient.CreateOrUpdateDeploymentArgsForCall(i) require.Equal(t, expectedDeployment, *dep) }(i, m.expectedDeployment) @@ -564,10 +564,10 @@ func TestInstallStrategyDeployment(t *testing.T) { }(i, p.Rules) } - var mockedDeps []*v1beta2.Deployment + var mockedDeps []*appsv1.Deployment for i := 1; i <= tt.numMockDeployments; i++ { dep := testDeployment(fmt.Sprintf("alm-dep-%d", i), namespace, &mockOwner) - dep.Spec = v1beta2.DeploymentSpec{Paused: true} // arbitrary + dep.Spec = appsv1.DeploymentSpec{Paused: true} // arbitrary mockedDeps = append(mockedDeps, &dep) } @@ -692,7 +692,7 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) { if tt.checkServiceAccountErr == nil { dep := testDeployment("alm-dep-1", namespace, &mockOwner) fakeClient.FindAnyDeploymentsMatchingNamesReturns( - []*v1beta2.Deployment{ + []*appsv1.Deployment{ &dep, }, nil, ) diff --git a/pkg/controller/install/status_viewer.go b/pkg/controller/install/status_viewer.go index 51bd1f80e6..67a857ef83 100644 --- a/pkg/controller/install/status_viewer.go +++ b/pkg/controller/install/status_viewer.go @@ -5,16 +5,16 @@ package install import ( "fmt" - "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" ) const TimedOutReason = "ProgressDeadlineExceeded" // Status returns a message describing deployment status, and a bool value indicating if the status is considered done. -func DeploymentStatus(deployment *v1beta2.Deployment) (string, bool, error) { +func DeploymentStatus(deployment *appsv1.Deployment) (string, bool, error) { if deployment.Generation <= deployment.Status.ObservedGeneration { // check if deployment has timed out - cond := getDeploymentCondition(deployment.Status, v1beta2.DeploymentProgressing) + cond := getDeploymentCondition(deployment.Status, appsv1.DeploymentProgressing) if cond != nil && cond.Reason == TimedOutReason { return "", false, fmt.Errorf("deployment %q exceeded its progress deadline", deployment.Name) } @@ -36,7 +36,7 @@ func DeploymentStatus(deployment *v1beta2.Deployment) (string, bool, error) { return fmt.Sprintf("Waiting for deployment spec update to be observed...\n"), false, nil } -func getDeploymentCondition(status v1beta2.DeploymentStatus, condType v1beta2.DeploymentConditionType) *v1beta2.DeploymentCondition { +func getDeploymentCondition(status appsv1.DeploymentStatus, condType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition { for i := range status.Conditions { c := status.Conditions[i] if c.Type == condType { diff --git a/pkg/controller/install/status_viewer_test.go b/pkg/controller/install/status_viewer_test.go index 32b88c15d8..8fcfee725c 100644 --- a/pkg/controller/install/status_viewer_test.go +++ b/pkg/controller/install/status_viewer_test.go @@ -3,7 +3,7 @@ package install import ( "testing" - apps "k8s.io/api/apps/v1beta2" + apps "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/lib/operatorclient/client.go b/pkg/lib/operatorclient/client.go index 1588eb07d1..d85b8adafa 100644 --- a/pkg/lib/operatorclient/client.go +++ b/pkg/lib/operatorclient/client.go @@ -2,7 +2,7 @@ package operatorclient import ( log "github.com/sirupsen/logrus" - appsv1beta2 "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" "k8s.io/api/core/v1" apiextensions "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -46,17 +46,17 @@ type ServiceAccountClient interface { // DeploymentClient contains methods for the Deployment resource. type DeploymentClient interface { - GetDeployment(namespace, name string) (*appsv1beta2.Deployment, error) - CreateDeployment(*appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) + GetDeployment(namespace, name string) (*appsv1.Deployment, error) + CreateDeployment(*appsv1.Deployment) (*appsv1.Deployment, error) DeleteDeployment(namespace, name string, options *metav1.DeleteOptions) error - UpdateDeployment(*appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) - PatchDeployment(*appsv1beta2.Deployment, *appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) - RollingUpdateDeployment(*appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) - RollingPatchDeployment(*appsv1beta2.Deployment, *appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) - RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*appsv1beta2.Deployment, bool, error) - RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*appsv1beta2.Deployment, bool, error) - CreateOrRollingUpdateDeployment(*appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) - ListDeploymentsWithLabels(namespace string, labels labels.Set) (*appsv1beta2.DeploymentList, error) + UpdateDeployment(*appsv1.Deployment) (*appsv1.Deployment, bool, error) + PatchDeployment(*appsv1.Deployment, *appsv1.Deployment) (*appsv1.Deployment, bool, error) + RollingUpdateDeployment(*appsv1.Deployment) (*appsv1.Deployment, bool, error) + RollingPatchDeployment(*appsv1.Deployment, *appsv1.Deployment) (*appsv1.Deployment, bool, error) + RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*appsv1.Deployment, bool, error) + RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*appsv1.Deployment, bool, error) + CreateOrRollingUpdateDeployment(*appsv1.Deployment) (*appsv1.Deployment, bool, error) + ListDeploymentsWithLabels(namespace string, labels labels.Set) (*appsv1.DeploymentList, error) } // Interface assertion. diff --git a/pkg/lib/operatorclient/deployment.go b/pkg/lib/operatorclient/deployment.go index d48a0e35b3..220c900ec5 100644 --- a/pkg/lib/operatorclient/deployment.go +++ b/pkg/lib/operatorclient/deployment.go @@ -6,7 +6,7 @@ import ( "time" "github.com/golang/glog" - appsv1beta2 "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -19,28 +19,28 @@ const ( ) // GetDeployment returns the Deployment object for the given namespace and name. -func (c *Client) GetDeployment(namespace, name string) (*appsv1beta2.Deployment, error) { +func (c *Client) GetDeployment(namespace, name string) (*appsv1.Deployment, error) { glog.V(4).Infof("[GET Deployment]: %s:%s", namespace, name) - return c.AppsV1beta2().Deployments(namespace).Get(name, metav1.GetOptions{}) + return c.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{}) } // CreateDeployment creates the Deployment object. -func (c *Client) CreateDeployment(dep *appsv1beta2.Deployment) (*appsv1beta2.Deployment, error) { +func (c *Client) CreateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, error) { glog.V(4).Infof("[CREATE Deployment]: %s:%s", dep.Namespace, dep.Name) - return c.AppsV1beta2().Deployments(dep.Namespace).Create(dep) + return c.AppsV1().Deployments(dep.Namespace).Create(dep) } // DeleteDeployment deletes the Deployment object. func (c *Client) DeleteDeployment(namespace, name string, options *metav1.DeleteOptions) error { glog.V(4).Infof("[DELETE Deployment]: %s:%s", namespace, name) - return c.AppsV1beta2().Deployments(namespace).Delete(name, options) + return c.AppsV1().Deployments(namespace).Delete(name, options) } // UpdateDeployment updates a Deployment object by performing a 2-way patch between the existing // Deployment and the result of the UpdateFunction. // // Returns the latest Deployment and true if it was updated, or an error. -func (c *Client) UpdateDeployment(dep *appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) { +func (c *Client) UpdateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, bool, error) { return c.PatchDeployment(nil, dep) } @@ -48,11 +48,11 @@ func (c *Client) UpdateDeployment(dep *appsv1beta2.Deployment) (*appsv1beta2.Dep // Deployment and `original` and `modified` manifests. // // Returns the latest Deployment and true if it was updated, or an error. -func (c *Client) PatchDeployment(original, modified *appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) { +func (c *Client) PatchDeployment(original, modified *appsv1.Deployment) (*appsv1.Deployment, bool, error) { namespace, name := modified.Namespace, modified.Name glog.V(4).Infof("[PATCH Deployment]: %s:%s", namespace, name) - current, err := c.AppsV1beta2().Deployments(namespace).Get(name, metav1.GetOptions{}) + current, err := c.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{}) if err != nil { return nil, false, err } @@ -67,7 +67,7 @@ func (c *Client) PatchDeployment(original, modified *appsv1beta2.Deployment) (*a if err != nil { return nil, false, err } - updated, err := c.AppsV1beta2().Deployments(namespace).Patch(name, types.StrategicMergePatchType, patchBytes) + updated, err := c.AppsV1().Deployments(namespace).Patch(name, types.StrategicMergePatchType, patchBytes) if err != nil { return nil, false, err } @@ -76,7 +76,7 @@ func (c *Client) PatchDeployment(original, modified *appsv1beta2.Deployment) (*a // RollingUpdateDeployment performs a rolling update on the given Deployment. It requires that the // Deployment uses the RollingUpdateDeploymentStrategyType update strategy. -func (c *Client) RollingUpdateDeployment(dep *appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) { +func (c *Client) RollingUpdateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, bool, error) { return c.RollingUpdateDeploymentMigrations(dep.Namespace, dep.Name, Update(dep)) } @@ -85,7 +85,7 @@ func (c *Client) RollingUpdateDeployment(dep *appsv1beta2.Deployment) (*appsv1be // // RollingUpdateDeploymentMigrations will run any before / during / after migrations that have been // specified in the upgrade options. -func (c *Client) RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*appsv1beta2.Deployment, bool, error) { +func (c *Client) RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*appsv1.Deployment, bool, error) { glog.V(4).Infof("[ROLLING UPDATE Deployment]: %s:%s", namespace, name) return c.RollingPatchDeploymentMigrations(namespace, name, updateToPatch(f)) } @@ -96,7 +96,7 @@ func (c *Client) RollingUpdateDeploymentMigrations(namespace, name string, f Upd // // RollingPatchDeployment will run any before / after migrations that have been specified in the // upgrade options. -func (c *Client) RollingPatchDeployment(original, modified *appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) { +func (c *Client) RollingPatchDeployment(original, modified *appsv1.Deployment) (*appsv1.Deployment, bool, error) { return c.RollingPatchDeploymentMigrations(modified.Namespace, modified.Name, Patch(original, modified)) } @@ -106,10 +106,10 @@ func (c *Client) RollingPatchDeployment(original, modified *appsv1beta2.Deployme // // RollingPatchDeploymentMigrations will run any before / after migrations that have been specified // in the upgrade options. -func (c *Client) RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*appsv1beta2.Deployment, bool, error) { +func (c *Client) RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*appsv1.Deployment, bool, error) { glog.V(4).Infof("[ROLLING PATCH Deployment]: %s:%s", namespace, name) - current, err := c.AppsV1beta2().Deployments(namespace).Get(name, metav1.GetOptions{}) + current, err := c.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{}) if err != nil { return nil, false, err } @@ -128,7 +128,7 @@ func (c *Client) RollingPatchDeploymentMigrations(namespace, name string, f Patc if originalObj == nil { originalObj = current // Emulate 2-way merge. } - original, modified := originalObj.(*appsv1beta2.Deployment), modifiedObj.(*appsv1beta2.Deployment) + original, modified := originalObj.(*appsv1.Deployment), modifiedObj.(*appsv1.Deployment) // Check for nil pointers. if modified == nil { return nil, false, errors.New("modified cannot be nil") @@ -141,7 +141,7 @@ func (c *Client) RollingPatchDeploymentMigrations(namespace, name string, f Patc if err != nil { return nil, false, err } - updated, err := c.AppsV1beta2().Deployments(namespace).Patch(name, types.StrategicMergePatchType, patchBytes) + updated, err := c.AppsV1().Deployments(namespace).Patch(name, types.StrategicMergePatchType, patchBytes) if err != nil { return nil, false, err } @@ -152,15 +152,15 @@ func (c *Client) RollingPatchDeploymentMigrations(namespace, name string, f Patc return updated, current.GetResourceVersion() != updated.GetResourceVersion(), nil } -func checkDeploymentRollingUpdateEnabled(dep *appsv1beta2.Deployment) error { - enabled := dep.Spec.Strategy.Type == appsv1beta2.RollingUpdateDeploymentStrategyType || dep.Spec.Strategy.Type == "" // Deployments rolling update by default +func checkDeploymentRollingUpdateEnabled(dep *appsv1.Deployment) error { + enabled := dep.Spec.Strategy.Type == appsv1.RollingUpdateDeploymentStrategyType || dep.Spec.Strategy.Type == "" // Deployments rolling update by default if !enabled { return fmt.Errorf("Deployment %s/%s does not have rolling update strategy enabled", dep.GetNamespace(), dep.GetName()) } return nil } -func (c *Client) waitForDeploymentRollout(dep *appsv1beta2.Deployment) error { +func (c *Client) waitForDeploymentRollout(dep *appsv1.Deployment) error { return wait.PollInfinite(deploymentRolloutPollInterval, func() (bool, error) { d, err := c.GetDeployment(dep.Namespace, dep.Name) if err != nil { @@ -179,7 +179,7 @@ func (c *Client) waitForDeploymentRollout(dep *appsv1beta2.Deployment) error { // CreateOrRollingUpdateDeployment creates the Deployment if it doesn't exist. If the Deployment // already exists, it will update the Deployment and wait for it to rollout. Returns true if the // Deployment was created or updated, false if there was no update. -func (c *Client) CreateOrRollingUpdateDeployment(dep *appsv1beta2.Deployment) (*appsv1beta2.Deployment, bool, error) { +func (c *Client) CreateOrRollingUpdateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, bool, error) { glog.V(4).Infof("[CREATE OR ROLLING UPDATE Deployment]: %s:%s", dep.Namespace, dep.Name) _, err := c.GetDeployment(dep.Namespace, dep.Name) @@ -198,9 +198,9 @@ func (c *Client) CreateOrRollingUpdateDeployment(dep *appsv1beta2.Deployment) (* // ListDeploymentsWithLabels returns a list of deployments that matches the label selector. // An empty list will be returned if no such deployments is found. -func (c *Client) ListDeploymentsWithLabels(namespace string, labels labels.Set) (*appsv1beta2.DeploymentList, error) { +func (c *Client) ListDeploymentsWithLabels(namespace string, labels labels.Set) (*appsv1.DeploymentList, error) { glog.V(4).Infof("[LIST Deployments] in %s, labels: %v", namespace, labels) opts := metav1.ListOptions{LabelSelector: labels.String()} - return c.AppsV1beta2().Deployments(namespace).List(opts) + return c.AppsV1().Deployments(namespace).List(opts) } diff --git a/pkg/lib/operatorclient/mock_client.go b/pkg/lib/operatorclient/mock_client.go index 1c5767f53d..2eabf328ca 100644 --- a/pkg/lib/operatorclient/mock_client.go +++ b/pkg/lib/operatorclient/mock_client.go @@ -6,10 +6,10 @@ package operatorclient import ( gomock "github.com/golang/mock/gomock" - v1beta2 "k8s.io/api/apps/v1beta2" - v1 "k8s.io/api/core/v1" + v1 "k8s.io/api/apps/v1" + v10 "k8s.io/api/core/v1" clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - v10 "k8s.io/apimachinery/pkg/apis/meta/v1" + v11 "k8s.io/apimachinery/pkg/apis/meta/v1" unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" labels "k8s.io/apimachinery/pkg/labels" kubernetes "k8s.io/client-go/kubernetes" @@ -200,9 +200,9 @@ func (mr *MockClientInterfaceMockRecorder) ListCustomResource(apiGroup, version, } // CreateServiceAccount mocks base method -func (m *MockClientInterface) CreateServiceAccount(arg0 *v1.ServiceAccount) (*v1.ServiceAccount, error) { +func (m *MockClientInterface) CreateServiceAccount(arg0 *v10.ServiceAccount) (*v10.ServiceAccount, error) { ret := m.ctrl.Call(m, "CreateServiceAccount", arg0) - ret0, _ := ret[0].(*v1.ServiceAccount) + ret0, _ := ret[0].(*v10.ServiceAccount) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -213,9 +213,9 @@ func (mr *MockClientInterfaceMockRecorder) CreateServiceAccount(arg0 interface{} } // GetServiceAccount mocks base method -func (m *MockClientInterface) GetServiceAccount(namespace, name string) (*v1.ServiceAccount, error) { +func (m *MockClientInterface) GetServiceAccount(namespace, name string) (*v10.ServiceAccount, error) { ret := m.ctrl.Call(m, "GetServiceAccount", namespace, name) - ret0, _ := ret[0].(*v1.ServiceAccount) + ret0, _ := ret[0].(*v10.ServiceAccount) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -226,9 +226,9 @@ func (mr *MockClientInterfaceMockRecorder) GetServiceAccount(namespace, name int } // UpdateServiceAccount mocks base method -func (m *MockClientInterface) UpdateServiceAccount(modified *v1.ServiceAccount) (*v1.ServiceAccount, error) { +func (m *MockClientInterface) UpdateServiceAccount(modified *v10.ServiceAccount) (*v10.ServiceAccount, error) { ret := m.ctrl.Call(m, "UpdateServiceAccount", modified) - ret0, _ := ret[0].(*v1.ServiceAccount) + ret0, _ := ret[0].(*v10.ServiceAccount) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -239,7 +239,7 @@ func (mr *MockClientInterfaceMockRecorder) UpdateServiceAccount(modified interfa } // DeleteServiceAccount mocks base method -func (m *MockClientInterface) DeleteServiceAccount(namespace, name string, options *v10.DeleteOptions) error { +func (m *MockClientInterface) DeleteServiceAccount(namespace, name string, options *v11.DeleteOptions) error { ret := m.ctrl.Call(m, "DeleteServiceAccount", namespace, name, options) ret0, _ := ret[0].(error) return ret0 @@ -251,9 +251,9 @@ func (mr *MockClientInterfaceMockRecorder) DeleteServiceAccount(namespace, name, } // GetDeployment mocks base method -func (m *MockClientInterface) GetDeployment(namespace, name string) (*v1beta2.Deployment, error) { +func (m *MockClientInterface) GetDeployment(namespace, name string) (*v1.Deployment, error) { ret := m.ctrl.Call(m, "GetDeployment", namespace, name) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -264,9 +264,9 @@ func (mr *MockClientInterfaceMockRecorder) GetDeployment(namespace, name interfa } // CreateDeployment mocks base method -func (m *MockClientInterface) CreateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, error) { +func (m *MockClientInterface) CreateDeployment(arg0 *v1.Deployment) (*v1.Deployment, error) { ret := m.ctrl.Call(m, "CreateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -277,7 +277,7 @@ func (mr *MockClientInterfaceMockRecorder) CreateDeployment(arg0 interface{}) *g } // DeleteDeployment mocks base method -func (m *MockClientInterface) DeleteDeployment(namespace, name string, options *v10.DeleteOptions) error { +func (m *MockClientInterface) DeleteDeployment(namespace, name string, options *v11.DeleteOptions) error { ret := m.ctrl.Call(m, "DeleteDeployment", namespace, name, options) ret0, _ := ret[0].(error) return ret0 @@ -289,9 +289,9 @@ func (mr *MockClientInterfaceMockRecorder) DeleteDeployment(namespace, name, opt } // UpdateDeployment mocks base method -func (m *MockClientInterface) UpdateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockClientInterface) UpdateDeployment(arg0 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "UpdateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -303,9 +303,9 @@ func (mr *MockClientInterfaceMockRecorder) UpdateDeployment(arg0 interface{}) *g } // PatchDeployment mocks base method -func (m *MockClientInterface) PatchDeployment(arg0, arg1 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockClientInterface) PatchDeployment(arg0, arg1 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "PatchDeployment", arg0, arg1) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -317,9 +317,9 @@ func (mr *MockClientInterfaceMockRecorder) PatchDeployment(arg0, arg1 interface{ } // RollingUpdateDeployment mocks base method -func (m *MockClientInterface) RollingUpdateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockClientInterface) RollingUpdateDeployment(arg0 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingUpdateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -331,9 +331,9 @@ func (mr *MockClientInterfaceMockRecorder) RollingUpdateDeployment(arg0 interfac } // RollingPatchDeployment mocks base method -func (m *MockClientInterface) RollingPatchDeployment(arg0, arg1 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockClientInterface) RollingPatchDeployment(arg0, arg1 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingPatchDeployment", arg0, arg1) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -345,9 +345,9 @@ func (mr *MockClientInterfaceMockRecorder) RollingPatchDeployment(arg0, arg1 int } // RollingUpdateDeploymentMigrations mocks base method -func (m *MockClientInterface) RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*v1beta2.Deployment, bool, error) { +func (m *MockClientInterface) RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingUpdateDeploymentMigrations", namespace, name, f) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -359,9 +359,9 @@ func (mr *MockClientInterfaceMockRecorder) RollingUpdateDeploymentMigrations(nam } // RollingPatchDeploymentMigrations mocks base method -func (m *MockClientInterface) RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*v1beta2.Deployment, bool, error) { +func (m *MockClientInterface) RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingPatchDeploymentMigrations", namespace, name, f) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -373,9 +373,9 @@ func (mr *MockClientInterfaceMockRecorder) RollingPatchDeploymentMigrations(name } // CreateOrRollingUpdateDeployment mocks base method -func (m *MockClientInterface) CreateOrRollingUpdateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockClientInterface) CreateOrRollingUpdateDeployment(arg0 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "CreateOrRollingUpdateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -387,9 +387,9 @@ func (mr *MockClientInterfaceMockRecorder) CreateOrRollingUpdateDeployment(arg0 } // ListDeploymentsWithLabels mocks base method -func (m *MockClientInterface) ListDeploymentsWithLabels(namespace string, labels labels.Set) (*v1beta2.DeploymentList, error) { +func (m *MockClientInterface) ListDeploymentsWithLabels(namespace string, labels labels.Set) (*v1.DeploymentList, error) { ret := m.ctrl.Call(m, "ListDeploymentsWithLabels", namespace, labels) - ret0, _ := ret[0].(*v1beta2.DeploymentList) + ret0, _ := ret[0].(*v1.DeploymentList) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -582,9 +582,9 @@ func (m *MockServiceAccountClient) EXPECT() *MockServiceAccountClientMockRecorde } // CreateServiceAccount mocks base method -func (m *MockServiceAccountClient) CreateServiceAccount(arg0 *v1.ServiceAccount) (*v1.ServiceAccount, error) { +func (m *MockServiceAccountClient) CreateServiceAccount(arg0 *v10.ServiceAccount) (*v10.ServiceAccount, error) { ret := m.ctrl.Call(m, "CreateServiceAccount", arg0) - ret0, _ := ret[0].(*v1.ServiceAccount) + ret0, _ := ret[0].(*v10.ServiceAccount) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -595,9 +595,9 @@ func (mr *MockServiceAccountClientMockRecorder) CreateServiceAccount(arg0 interf } // GetServiceAccount mocks base method -func (m *MockServiceAccountClient) GetServiceAccount(namespace, name string) (*v1.ServiceAccount, error) { +func (m *MockServiceAccountClient) GetServiceAccount(namespace, name string) (*v10.ServiceAccount, error) { ret := m.ctrl.Call(m, "GetServiceAccount", namespace, name) - ret0, _ := ret[0].(*v1.ServiceAccount) + ret0, _ := ret[0].(*v10.ServiceAccount) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -608,9 +608,9 @@ func (mr *MockServiceAccountClientMockRecorder) GetServiceAccount(namespace, nam } // UpdateServiceAccount mocks base method -func (m *MockServiceAccountClient) UpdateServiceAccount(modified *v1.ServiceAccount) (*v1.ServiceAccount, error) { +func (m *MockServiceAccountClient) UpdateServiceAccount(modified *v10.ServiceAccount) (*v10.ServiceAccount, error) { ret := m.ctrl.Call(m, "UpdateServiceAccount", modified) - ret0, _ := ret[0].(*v1.ServiceAccount) + ret0, _ := ret[0].(*v10.ServiceAccount) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -621,7 +621,7 @@ func (mr *MockServiceAccountClientMockRecorder) UpdateServiceAccount(modified in } // DeleteServiceAccount mocks base method -func (m *MockServiceAccountClient) DeleteServiceAccount(namespace, name string, options *v10.DeleteOptions) error { +func (m *MockServiceAccountClient) DeleteServiceAccount(namespace, name string, options *v11.DeleteOptions) error { ret := m.ctrl.Call(m, "DeleteServiceAccount", namespace, name, options) ret0, _ := ret[0].(error) return ret0 @@ -656,9 +656,9 @@ func (m *MockDeploymentClient) EXPECT() *MockDeploymentClientMockRecorder { } // GetDeployment mocks base method -func (m *MockDeploymentClient) GetDeployment(namespace, name string) (*v1beta2.Deployment, error) { +func (m *MockDeploymentClient) GetDeployment(namespace, name string) (*v1.Deployment, error) { ret := m.ctrl.Call(m, "GetDeployment", namespace, name) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -669,9 +669,9 @@ func (mr *MockDeploymentClientMockRecorder) GetDeployment(namespace, name interf } // CreateDeployment mocks base method -func (m *MockDeploymentClient) CreateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, error) { +func (m *MockDeploymentClient) CreateDeployment(arg0 *v1.Deployment) (*v1.Deployment, error) { ret := m.ctrl.Call(m, "CreateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -682,7 +682,7 @@ func (mr *MockDeploymentClientMockRecorder) CreateDeployment(arg0 interface{}) * } // DeleteDeployment mocks base method -func (m *MockDeploymentClient) DeleteDeployment(namespace, name string, options *v10.DeleteOptions) error { +func (m *MockDeploymentClient) DeleteDeployment(namespace, name string, options *v11.DeleteOptions) error { ret := m.ctrl.Call(m, "DeleteDeployment", namespace, name, options) ret0, _ := ret[0].(error) return ret0 @@ -694,9 +694,9 @@ func (mr *MockDeploymentClientMockRecorder) DeleteDeployment(namespace, name, op } // UpdateDeployment mocks base method -func (m *MockDeploymentClient) UpdateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockDeploymentClient) UpdateDeployment(arg0 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "UpdateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -708,9 +708,9 @@ func (mr *MockDeploymentClientMockRecorder) UpdateDeployment(arg0 interface{}) * } // PatchDeployment mocks base method -func (m *MockDeploymentClient) PatchDeployment(arg0, arg1 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockDeploymentClient) PatchDeployment(arg0, arg1 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "PatchDeployment", arg0, arg1) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -722,9 +722,9 @@ func (mr *MockDeploymentClientMockRecorder) PatchDeployment(arg0, arg1 interface } // RollingUpdateDeployment mocks base method -func (m *MockDeploymentClient) RollingUpdateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockDeploymentClient) RollingUpdateDeployment(arg0 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingUpdateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -736,9 +736,9 @@ func (mr *MockDeploymentClientMockRecorder) RollingUpdateDeployment(arg0 interfa } // RollingPatchDeployment mocks base method -func (m *MockDeploymentClient) RollingPatchDeployment(arg0, arg1 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockDeploymentClient) RollingPatchDeployment(arg0, arg1 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingPatchDeployment", arg0, arg1) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -750,9 +750,9 @@ func (mr *MockDeploymentClientMockRecorder) RollingPatchDeployment(arg0, arg1 in } // RollingUpdateDeploymentMigrations mocks base method -func (m *MockDeploymentClient) RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*v1beta2.Deployment, bool, error) { +func (m *MockDeploymentClient) RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingUpdateDeploymentMigrations", namespace, name, f) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -764,9 +764,9 @@ func (mr *MockDeploymentClientMockRecorder) RollingUpdateDeploymentMigrations(na } // RollingPatchDeploymentMigrations mocks base method -func (m *MockDeploymentClient) RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*v1beta2.Deployment, bool, error) { +func (m *MockDeploymentClient) RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "RollingPatchDeploymentMigrations", namespace, name, f) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -778,9 +778,9 @@ func (mr *MockDeploymentClientMockRecorder) RollingPatchDeploymentMigrations(nam } // CreateOrRollingUpdateDeployment mocks base method -func (m *MockDeploymentClient) CreateOrRollingUpdateDeployment(arg0 *v1beta2.Deployment) (*v1beta2.Deployment, bool, error) { +func (m *MockDeploymentClient) CreateOrRollingUpdateDeployment(arg0 *v1.Deployment) (*v1.Deployment, bool, error) { ret := m.ctrl.Call(m, "CreateOrRollingUpdateDeployment", arg0) - ret0, _ := ret[0].(*v1beta2.Deployment) + ret0, _ := ret[0].(*v1.Deployment) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 @@ -792,9 +792,9 @@ func (mr *MockDeploymentClientMockRecorder) CreateOrRollingUpdateDeployment(arg0 } // ListDeploymentsWithLabels mocks base method -func (m *MockDeploymentClient) ListDeploymentsWithLabels(namespace string, labels labels.Set) (*v1beta2.DeploymentList, error) { +func (m *MockDeploymentClient) ListDeploymentsWithLabels(namespace string, labels labels.Set) (*v1.DeploymentList, error) { ret := m.ctrl.Call(m, "ListDeploymentsWithLabels", namespace, labels) - ret0, _ := ret[0].(*v1beta2.DeploymentList) + ret0, _ := ret[0].(*v1.DeploymentList) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/pkg/lib/operatorclient/patch.go b/pkg/lib/operatorclient/patch.go index 64080ae0af..57122feab5 100644 --- a/pkg/lib/operatorclient/patch.go +++ b/pkg/lib/operatorclient/patch.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - appsv1beta2 "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" "k8s.io/api/core/v1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" v1beta1ext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -126,19 +126,19 @@ func cloneAndNormalizeObject(obj runtime.Object) (runtime.Object, error) { // Clone the object since it will be modified. obj = obj.DeepCopyObject() switch obj := obj.(type) { - case *appsv1beta2.DaemonSet: + case *appsv1.DaemonSet: if obj != nil { // These are only extracted from current; should not be considered for diffs. obj.ObjectMeta.ResourceVersion = "" obj.ObjectMeta.CreationTimestamp = metav1.Time{} - obj.Status = appsv1beta2.DaemonSetStatus{} + obj.Status = appsv1.DaemonSetStatus{} } - case *appsv1beta2.Deployment: + case *appsv1.Deployment: if obj != nil { // These are only extracted from current; should not be considered for diffs. obj.ObjectMeta.ResourceVersion = "" obj.ObjectMeta.CreationTimestamp = metav1.Time{} - obj.Status = appsv1beta2.DeploymentStatus{} + obj.Status = appsv1.DeploymentStatus{} } case *v1.Service: if obj != nil { @@ -187,43 +187,43 @@ func mergeAnnotationsAndLabels(original, modified, current runtime.Object) error } switch current := current.(type) { - case *appsv1beta2.DaemonSet: + case *appsv1.DaemonSet: getter := func(obj runtime.Object) (map[string]string, error) { - return obj.(*appsv1beta2.DaemonSet).Spec.Template.Annotations, nil + return obj.(*appsv1.DaemonSet).Spec.Template.Annotations, nil } setter := func(obj runtime.Object, val map[string]string) error { - obj.(*appsv1beta2.DaemonSet).Spec.Template.Annotations = val + obj.(*appsv1.DaemonSet).Spec.Template.Annotations = val return nil } if err := mergeMaps(original, modified, current, getter, setter); err != nil { return err } getter = func(obj runtime.Object) (map[string]string, error) { - return obj.(*appsv1beta2.DaemonSet).Spec.Template.Labels, nil + return obj.(*appsv1.DaemonSet).Spec.Template.Labels, nil } setter = func(obj runtime.Object, val map[string]string) error { - obj.(*appsv1beta2.DaemonSet).Spec.Template.Labels = val + obj.(*appsv1.DaemonSet).Spec.Template.Labels = val return nil } if err := mergeMaps(original, modified, current, getter, setter); err != nil { return err } - case *appsv1beta2.Deployment: + case *appsv1.Deployment: getter := func(obj runtime.Object) (map[string]string, error) { - return obj.(*appsv1beta2.Deployment).Spec.Template.Annotations, nil + return obj.(*appsv1.Deployment).Spec.Template.Annotations, nil } setter := func(obj runtime.Object, val map[string]string) error { - obj.(*appsv1beta2.Deployment).Spec.Template.Annotations = val + obj.(*appsv1.Deployment).Spec.Template.Annotations = val return nil } if err := mergeMaps(original, modified, current, getter, setter); err != nil { return err } getter = func(obj runtime.Object) (map[string]string, error) { - return obj.(*appsv1beta2.Deployment).Spec.Template.Labels, nil + return obj.(*appsv1.Deployment).Spec.Template.Labels, nil } setter = func(obj runtime.Object, val map[string]string) error { - obj.(*appsv1beta2.Deployment).Spec.Template.Labels = val + obj.(*appsv1.Deployment).Spec.Template.Labels = val return nil } if err := mergeMaps(original, modified, current, getter, setter); err != nil { diff --git a/test/e2e/csv_e2e_test.go b/test/e2e/csv_e2e_test.go index 58bd7de93e..6bf0c8595c 100644 --- a/test/e2e/csv_e2e_test.go +++ b/test/e2e/csv_e2e_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" "k8s.io/api/core/v1" rbacv1beta1 "k8s.io/api/rbac/v1beta1" extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -64,8 +64,8 @@ func createCRD(c operatorclient.ClientInterface, crd extv1beta1.CustomResourceDe } -func newNginxDeployment(name string) v1beta2.DeploymentSpec { - return v1beta2.DeploymentSpec{ +func newNginxDeployment(name string) appsv1.DeploymentSpec { + return appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app": name, diff --git a/test/e2e/installplan_e2e_test.go b/test/e2e/installplan_e2e_test.go index 646441f07f..972a86a74f 100644 --- a/test/e2e/installplan_e2e_test.go +++ b/test/e2e/installplan_e2e_test.go @@ -14,7 +14,7 @@ import ( "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client" "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned" "github.com/stretchr/testify/require" - "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -310,7 +310,7 @@ func TestCreateInstallPlanWithCSVsAcrossMultipleCatalogSources(t *testing.T) { DeploymentSpecs: []install.StrategyDeploymentSpec{ { Name: genName("dep-"), - Spec: v1beta2.DeploymentSpec{ + Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"app": "nginx"}, }, diff --git a/test/e2e/ocs_e2e_test.go b/test/e2e/ocs_e2e_test.go index 55edf1a8f0..a5b6663057 100644 --- a/test/e2e/ocs_e2e_test.go +++ b/test/e2e/ocs_e2e_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - appsv1beta2 "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -139,7 +139,7 @@ func TestInstallEtcdOCS(t *testing.T) { } for _, deploymentName := range []string{"etcd-operator"} { - var deployment *appsv1beta2.Deployment + var deployment *appsv1.Deployment t.Logf("Looking for Deployment %s in %s\n", deploymentName, testNamespace) err = wait.Poll(pollInterval, pollDuration, func() (bool, error) { @@ -279,7 +279,7 @@ func TestInstallPrometheusOCS(t *testing.T) { } for _, deploymentName := range []string{"prometheus-operator"} { - var deployment *appsv1beta2.Deployment + var deployment *appsv1.Deployment t.Logf("Looking for Deployment %s in %s\n", deploymentName, testNamespace) err = wait.Poll(pollInterval, pollDuration, func() (bool, error) { @@ -425,7 +425,7 @@ func TestInstallVaultOCS(t *testing.T) { } for _, deploymentName := range []string{"etcd-operator", "vault-operator"} { - var deployment *appsv1beta2.Deployment + var deployment *appsv1.Deployment t.Logf("Looking for Deployment %s in %s\n", deploymentName, testNamespace) err = wait.Poll(pollInterval, pollDuration, func() (bool, error) { diff --git a/test/e2e/subscription_e2e_test.go b/test/e2e/subscription_e2e_test.go index d05a2ef3c6..51f75f2552 100644 --- a/test/e2e/subscription_e2e_test.go +++ b/test/e2e/subscription_e2e_test.go @@ -7,7 +7,7 @@ import ( "github.com/coreos/go-semver/semver" "github.com/ghodss/yaml" "github.com/stretchr/testify/require" - "k8s.io/api/apps/v1beta2" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -139,7 +139,7 @@ var ( DeploymentSpecs: []install.StrategyDeploymentSpec{ { Name: genName("dep-"), - Spec: v1beta2.DeploymentSpec{ + Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"app": "nginx"}, }, From c03942b7ca649ab9f9e21c2bc62079b12fa317fa Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Thu, 2 Aug 2018 15:55:12 -0400 Subject: [PATCH 2/2] chore(deploy): update deployment resources to use apps/v1 --- deploy/chart/templates/12-alm-operator.deployment.yaml | 2 +- deploy/chart/templates/13-catalog-operator.deployment.yaml | 2 +- deploy/chart/templates/17-alm-servicebroker.deployment.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/chart/templates/12-alm-operator.deployment.yaml b/deploy/chart/templates/12-alm-operator.deployment.yaml index d0ade24703..cceb84c1d7 100644 --- a/deploy/chart/templates/12-alm-operator.deployment.yaml +++ b/deploy/chart/templates/12-alm-operator.deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: alm-operator diff --git a/deploy/chart/templates/13-catalog-operator.deployment.yaml b/deploy/chart/templates/13-catalog-operator.deployment.yaml index ce176ae2eb..9e36707f92 100644 --- a/deploy/chart/templates/13-catalog-operator.deployment.yaml +++ b/deploy/chart/templates/13-catalog-operator.deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: catalog-operator diff --git a/deploy/chart/templates/17-alm-servicebroker.deployment.yaml b/deploy/chart/templates/17-alm-servicebroker.deployment.yaml index 316eb384ea..2e5996bea9 100644 --- a/deploy/chart/templates/17-alm-servicebroker.deployment.yaml +++ b/deploy/chart/templates/17-alm-servicebroker.deployment.yaml @@ -1,5 +1,5 @@ {{ if .Values.servicebroker }} -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: alm-service-broker