From 649bfc4fb806e420a3e42443bb9f56270d0e9c40 Mon Sep 17 00:00:00 2001 From: shubham Date: Mon, 29 Jun 2020 19:03:16 +0530 Subject: [PATCH] renamed imports for v1aplha1 apis Signed-off-by: shubham --- cmd/upgrade/executor/resource.go | 8 +++--- pkg/upgrade/upgrader/cstor_cspc.go | 6 ++-- pkg/upgrade/upgrader/cstor_cspi.go | 24 ++++++++-------- pkg/upgrade/upgrader/cstor_volume.go | 28 +++++++++---------- pkg/upgrade/upgrader/upgradetask.go | 42 ++++++++++++++-------------- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/cmd/upgrade/executor/resource.go b/cmd/upgrade/executor/resource.go index 8521fadc..4eb3f4e9 100644 --- a/cmd/upgrade/executor/resource.go +++ b/cmd/upgrade/executor/resource.go @@ -23,7 +23,7 @@ import ( "k8s.io/client-go/rest" "k8s.io/klog" - apis "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" + v1Alpha1API "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" openebsclientset "github.com/openebs/api/pkg/client/clientset/versioned" "github.com/openebs/maya/pkg/util" cmdUtil "github.com/openebs/upgrade/cmd/util" @@ -87,7 +87,7 @@ func NewUpgradeResourceJob() *cobra.Command { } utaskObj.Status.Retries = utaskObj.Status.Retries + 1 if utaskObj.Status.Retries == backoffLimit { - utaskObj.Status.Phase = apis.UpgradeError + utaskObj.Status.Phase = v1Alpha1API.UpgradeError utaskObj.Status.CompletedTime = metav1.Now() } _, err = client.OpenebsV1alpha1().UpgradeTasks(openebsNamespace). @@ -101,7 +101,7 @@ func NewUpgradeResourceJob() *cobra.Command { if err != nil { util.Fatal(err.Error()) } - utaskObj.Status.Phase = apis.UpgradeSuccess + utaskObj.Status.Phase = v1Alpha1API.UpgradeSuccess utaskObj.Status.CompletedTime = metav1.Now() _, err = client.OpenebsV1alpha1().UpgradeTasks(openebsNamespace). Update(utaskObj) @@ -117,7 +117,7 @@ func NewUpgradeResourceJob() *cobra.Command { // InitializeFromUpgradeTaskResource will populate the UpgradeOptions from given UpgradeTask func (u *UpgradeOptions) InitializeFromUpgradeTaskResource( - upgradeTaskCRObj apis.UpgradeTask) error { + upgradeTaskCRObj v1Alpha1API.UpgradeTask) error { if len(strings.TrimSpace(u.openebsNamespace)) == 0 { return errors.Errorf("Cannot execute upgrade job: namespace is missing") diff --git a/pkg/upgrade/upgrader/cstor_cspc.go b/pkg/upgrade/upgrader/cstor_cspc.go index 08a03fc1..f1acc00b 100644 --- a/pkg/upgrade/upgrader/cstor_cspc.go +++ b/pkg/upgrade/upgrader/cstor_cspc.go @@ -20,7 +20,7 @@ import ( "time" cstor "github.com/openebs/api/pkg/apis/cstor/v1" - apis "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" + v1Alpha1API "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" "github.com/openebs/upgrade/pkg/upgrade/patch" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" @@ -148,7 +148,7 @@ func (obj *CSPCPatch) Upgrade() error { } utaskObj.Status.Retries = utaskObj.Status.Retries + 1 if utaskObj.Status.Retries == backoffLimit { - utaskObj.Status.Phase = apis.UpgradeError + utaskObj.Status.Phase = v1Alpha1API.UpgradeError utaskObj.Status.CompletedTime = metav1.Now() } _, uerr = obj.OpenebsClientset.OpenebsV1alpha1().UpgradeTasks(obj.OpenebsNamespace). @@ -163,7 +163,7 @@ func (obj *CSPCPatch) Upgrade() error { if uerr != nil && isUpgradeTaskJob { return uerr } - utaskObj.Status.Phase = apis.UpgradeSuccess + utaskObj.Status.Phase = v1Alpha1API.UpgradeSuccess utaskObj.Status.CompletedTime = metav1.Now() _, uerr = obj.OpenebsClientset.OpenebsV1alpha1().UpgradeTasks(obj.OpenebsNamespace). Update(utaskObj) diff --git a/pkg/upgrade/upgrader/cstor_cspi.go b/pkg/upgrade/upgrader/cstor_cspi.go index 7a5747f1..518fa9be 100644 --- a/pkg/upgrade/upgrader/cstor_cspi.go +++ b/pkg/upgrade/upgrader/cstor_cspi.go @@ -20,7 +20,7 @@ import ( "time" cstor "github.com/openebs/api/pkg/apis/cstor/v1" - apis "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" + v1Alpha1API "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" "github.com/openebs/upgrade/pkg/upgrade/patch" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" @@ -33,7 +33,7 @@ type CSPIPatch struct { Namespace string Deploy *patch.Deployment CSPI *patch.CSPI - Utask *apis.UpgradeTask + Utask *v1Alpha1API.UpgradeTask *Client } @@ -112,13 +112,13 @@ func (obj *CSPIPatch) Upgrade() error { if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj := apis.UpgradeDetailedStatuses{Step: apis.PreUpgrade} - statusObj.Phase = apis.StepWaiting + statusObj := v1Alpha1API.UpgradeDetailedStatuses{Step: v1Alpha1API.PreUpgrade} + statusObj.Phase = v1Alpha1API.StepWaiting obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj.Phase = apis.StepErrored + statusObj.Phase = v1Alpha1API.StepErrored msg, err := obj.Init() if err != nil { statusObj.Message = msg @@ -139,7 +139,7 @@ func (obj *CSPIPatch) Upgrade() error { } return errors.Wrap(err, msg) } - statusObj.Phase = apis.StepCompleted + statusObj.Phase = v1Alpha1API.StepCompleted statusObj.Message = "Pre-upgrade steps were successful" statusObj.Reason = "" obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) @@ -147,13 +147,13 @@ func (obj *CSPIPatch) Upgrade() error { return uerr } - statusObj = apis.UpgradeDetailedStatuses{Step: apis.PoolInstanceUpgrade} - statusObj.Phase = apis.StepWaiting + statusObj = v1Alpha1API.UpgradeDetailedStatuses{Step: v1Alpha1API.PoolInstanceUpgrade} + statusObj.Phase = v1Alpha1API.StepWaiting obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj.Phase = apis.StepErrored + statusObj.Phase = v1Alpha1API.StepErrored msg, err = obj.DeployUpgrade() if err != nil { statusObj.Message = msg @@ -184,7 +184,7 @@ func (obj *CSPIPatch) Upgrade() error { } return errors.Wrap(err, msg) } - statusObj.Phase = apis.StepCompleted + statusObj.Phase = v1Alpha1API.StepCompleted statusObj.Message = "Pre-upgrade steps were successful" statusObj.Reason = "" obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) @@ -197,8 +197,8 @@ func (obj *CSPIPatch) Upgrade() error { // Init initializes all the fields of the CSPIPatch func (obj *CSPIPatch) Init() (string, error) { var err error - statusObj := apis.UpgradeDetailedStatuses{Step: apis.PreUpgrade} - statusObj.Phase = apis.StepErrored + statusObj := v1Alpha1API.UpgradeDetailedStatuses{Step: v1Alpha1API.PreUpgrade} + statusObj.Phase = v1Alpha1API.StepErrored obj.Deploy = patch.NewDeployment( patch.WithDeploymentClient(obj.KubeClientset), ) diff --git a/pkg/upgrade/upgrader/cstor_volume.go b/pkg/upgrade/upgrader/cstor_volume.go index e4682c9c..6124ae08 100644 --- a/pkg/upgrade/upgrader/cstor_volume.go +++ b/pkg/upgrade/upgrader/cstor_volume.go @@ -20,7 +20,7 @@ import ( "time" cstor "github.com/openebs/api/pkg/apis/cstor/v1" - apis "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" + v1Alpha1API "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" "github.com/openebs/upgrade/pkg/upgrade/patch" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" @@ -37,7 +37,7 @@ type CStorVolumePatch struct { CV *patch.CV Deploy *patch.Deployment Service *patch.Service - Utask *apis.UpgradeTask + Utask *v1Alpha1API.UpgradeTask *Client } @@ -260,13 +260,13 @@ func (obj *CStorVolumePatch) Upgrade() error { if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj := apis.UpgradeDetailedStatuses{Step: apis.PreUpgrade} - statusObj.Phase = apis.StepWaiting + statusObj := v1Alpha1API.UpgradeDetailedStatuses{Step: v1Alpha1API.PreUpgrade} + statusObj.Phase = v1Alpha1API.StepWaiting obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj.Phase = apis.StepErrored + statusObj.Phase = v1Alpha1API.StepErrored msg, err := obj.Init() if err != nil { statusObj.Message = msg @@ -287,7 +287,7 @@ func (obj *CStorVolumePatch) Upgrade() error { } return errors.Wrap(err, msg) } - statusObj.Phase = apis.StepCompleted + statusObj.Phase = v1Alpha1API.StepCompleted statusObj.Message = "Pre-upgrade steps were successful" statusObj.Reason = "" obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) @@ -295,13 +295,13 @@ func (obj *CStorVolumePatch) Upgrade() error { return uerr } - statusObj = apis.UpgradeDetailedStatuses{Step: apis.ReplicaUpgrade} - statusObj.Phase = apis.StepWaiting + statusObj = v1Alpha1API.UpgradeDetailedStatuses{Step: v1Alpha1API.ReplicaUpgrade} + statusObj.Phase = v1Alpha1API.StepWaiting obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj.Phase = apis.StepErrored + statusObj.Phase = v1Alpha1API.StepErrored res := *obj.ResourcePatch cvrList, err := obj.Client.OpenebsClientset.CstorV1(). CStorVolumeReplicas(obj.Namespace).List( @@ -337,20 +337,20 @@ func (obj *CStorVolumePatch) Upgrade() error { return errors.Wrap(err, msg) } } - statusObj.Phase = apis.StepCompleted + statusObj.Phase = v1Alpha1API.StepCompleted statusObj.Message = "Replica upgrade was successful" statusObj.Reason = "" obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj = apis.UpgradeDetailedStatuses{Step: apis.TargetUpgrade} - statusObj.Phase = apis.StepWaiting + statusObj = v1Alpha1API.UpgradeDetailedStatuses{Step: v1Alpha1API.TargetUpgrade} + statusObj.Phase = v1Alpha1API.StepWaiting obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) if uerr != nil && isUpgradeTaskJob { return uerr } - statusObj.Phase = apis.StepErrored + statusObj.Phase = v1Alpha1API.StepErrored msg, err = obj.CStorVolumeUpgrade() if err != nil { statusObj.Message = msg @@ -361,7 +361,7 @@ func (obj *CStorVolumePatch) Upgrade() error { } return errors.Wrap(err, msg) } - statusObj.Phase = apis.StepCompleted + statusObj.Phase = v1Alpha1API.StepCompleted statusObj.Message = "Target upgrade was successful" statusObj.Reason = "" obj.Utask, uerr = updateUpgradeDetailedStatus(obj.Utask, statusObj, obj.OpenebsNamespace, obj.Client) diff --git a/pkg/upgrade/upgrader/upgradetask.go b/pkg/upgrade/upgrader/upgradetask.go index 6597b586..481f8d9c 100644 --- a/pkg/upgrade/upgrader/upgradetask.go +++ b/pkg/upgrade/upgrader/upgradetask.go @@ -19,16 +19,16 @@ package upgrader import ( "os" - apis "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" + v1Alpha1API "github.com/openebs/api/pkg/apis/openebs.io/v1alpha1" "github.com/pkg/errors" k8serror "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func updateUpgradeDetailedStatus(utaskObj *apis.UpgradeTask, - uStatusObj apis.UpgradeDetailedStatuses, +func updateUpgradeDetailedStatus(utaskObj *v1Alpha1API.UpgradeTask, + uStatusObj v1Alpha1API.UpgradeDetailedStatuses, openebsNamespace string, client *Client, -) (*apis.UpgradeTask, error) { +) (*v1Alpha1API.UpgradeTask, error) { var err error if !isValidStatus(uStatusObj) { return nil, errors.Errorf( @@ -37,7 +37,7 @@ func updateUpgradeDetailedStatus(utaskObj *apis.UpgradeTask, ) } uStatusObj.LastUpdatedTime = metav1.Now() - if uStatusObj.Phase == apis.StepWaiting { + if uStatusObj.Phase == v1Alpha1API.StepWaiting { uStatusObj.StartTime = uStatusObj.LastUpdatedTime utaskObj.Status.UpgradeDetailedStatuses = append( utaskObj.Status.UpgradeDetailedStatuses, @@ -57,25 +57,25 @@ func updateUpgradeDetailedStatus(utaskObj *apis.UpgradeTask, } // isValidStatus is used to validate IsValidStatus -func isValidStatus(o apis.UpgradeDetailedStatuses) bool { +func isValidStatus(o v1Alpha1API.UpgradeDetailedStatuses) bool { if o.Step == "" { return false } if o.Phase == "" { return false } - if o.Message == "" && o.Phase != apis.StepWaiting { + if o.Message == "" && o.Phase != v1Alpha1API.StepWaiting { return false } - if o.Reason == "" && o.Phase == apis.StepErrored { + if o.Reason == "" && o.Phase == v1Alpha1API.StepErrored { return false } return true } // getOrCreateUpgradeTask fetches upgrade task if provided or creates a new upgradetask CR -func getOrCreateUpgradeTask(kind string, r *ResourcePatch, client *Client) (*apis.UpgradeTask, error) { - var utaskObj *apis.UpgradeTask +func getOrCreateUpgradeTask(kind string, r *ResourcePatch, client *Client) (*v1Alpha1API.UpgradeTask, error) { + var utaskObj *v1Alpha1API.UpgradeTask var err error if r.OpenebsNamespace == "" { return nil, errors.Errorf("missing openebsNamespace") @@ -107,11 +107,11 @@ func getOrCreateUpgradeTask(kind string, r *ResourcePatch, client *Client) (*api } if utaskObj.Status.StartTime.IsZero() { - utaskObj.Status.Phase = apis.UpgradeStarted + utaskObj.Status.Phase = v1Alpha1API.UpgradeStarted utaskObj.Status.StartTime = metav1.Now() } - utaskObj.Status.UpgradeDetailedStatuses = []apis.UpgradeDetailedStatuses{} + utaskObj.Status.UpgradeDetailedStatuses = []v1Alpha1API.UpgradeDetailedStatuses{} utaskObj, err = client.OpenebsClientset.OpenebsV1alpha1(). UpgradeTasks(r.OpenebsNamespace). Update(utaskObj) @@ -121,35 +121,35 @@ func getOrCreateUpgradeTask(kind string, r *ResourcePatch, client *Client) (*api return utaskObj, nil } -func buildUpgradeTask(kind string, r *ResourcePatch) *apis.UpgradeTask { +func buildUpgradeTask(kind string, r *ResourcePatch) *v1Alpha1API.UpgradeTask { // TODO builder - utaskObj := &apis.UpgradeTask{ + utaskObj := &v1Alpha1API.UpgradeTask{ ObjectMeta: metav1.ObjectMeta{ Namespace: r.OpenebsNamespace, }, - Spec: apis.UpgradeTaskSpec{ + Spec: v1Alpha1API.UpgradeTaskSpec{ FromVersion: r.From, ToVersion: r.To, ImageTag: r.ImageTag, ImagePrefix: r.BaseURL, }, - Status: apis.UpgradeTaskStatus{ - Phase: apis.UpgradeStarted, + Status: v1Alpha1API.UpgradeTaskStatus{ + Phase: v1Alpha1API.UpgradeStarted, StartTime: metav1.Now(), }, } switch kind { case "cstorpoolinstance": utaskObj.Name = "upgrade-cstor-cspi-" + r.Name - utaskObj.Spec.ResourceSpec = apis.ResourceSpec{ - CStorPoolInstance: &apis.CStorPoolInstance{ + utaskObj.Spec.ResourceSpec = v1Alpha1API.ResourceSpec{ + CStorPoolInstance: &v1Alpha1API.CStorPoolInstance{ CSPIName: r.Name, }, } case "cstorVolume": utaskObj.Name = "upgrade-cstor-csi-volume-" + r.Name - utaskObj.Spec.ResourceSpec = apis.ResourceSpec{ - CStorVolume: &apis.CStorVolume{ + utaskObj.Spec.ResourceSpec = v1Alpha1API.ResourceSpec{ + CStorVolume: &v1Alpha1API.CStorVolume{ PVName: r.Name, }, }