From d201818152f579d4f0ca6e34b2ccbe7977ac9fe6 Mon Sep 17 00:00:00 2001 From: odubajDT Date: Mon, 19 Sep 2022 09:00:38 +0200 Subject: [PATCH] pr review Signed-off-by: odubajDT --- operator/api/v1alpha1/service_types.go | 10 +++++----- operator/api/v1alpha1/zz_generated.deepcopy.go | 2 +- .../config/samples/lifecycle_v1alpha1_service.yaml | 2 -- operator/controllers/service_controller.go | 8 ++++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/operator/api/v1alpha1/service_types.go b/operator/api/v1alpha1/service_types.go index ec421a500e7..b783b3a9ec5 100644 --- a/operator/api/v1alpha1/service_types.go +++ b/operator/api/v1alpha1/service_types.go @@ -25,14 +25,14 @@ import ( // ServiceSpec defines the desired state of Service type ServiceSpec struct { - ApplicationName string `json:"application,omitempty"` - PreDeplymentChecks EventSpec `json:"preDeploymentChecks"` + ApplicationName string `json:"application,omitempty"` + PreDeplymentCheck EventSpec `json:"preDeploymentChecks"` } // ServiceStatus defines the observed state of Service type ServiceStatus struct { - Phase ServicePhase `json:"phase"` - PreDeploymentChecksName string `json:"preDeploymentChecksName"` + Phase ServicePhase `json:"phase"` + PreDeploymentCheckName string `json:"preDeploymentChecksName"` } type ServicePhase string @@ -84,7 +84,7 @@ func (s Service) IsCompleted() bool { } func (s Service) IsDeploymentCheckNotCreated() bool { - if s.Status.Phase == ServicePending || s.Status.PreDeploymentChecksName == "" { + if s.Status.Phase == ServicePending || s.Status.PreDeploymentCheckName == "" { return true } return false diff --git a/operator/api/v1alpha1/zz_generated.deepcopy.go b/operator/api/v1alpha1/zz_generated.deepcopy.go index f9c60c57b07..fd1803e64b4 100644 --- a/operator/api/v1alpha1/zz_generated.deepcopy.go +++ b/operator/api/v1alpha1/zz_generated.deepcopy.go @@ -283,7 +283,7 @@ func (in *ServiceList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { *out = *in - in.PreDeplymentChecks.DeepCopyInto(&out.PreDeplymentChecks) + in.PreDeplymentCheck.DeepCopyInto(&out.PreDeplymentCheck) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. diff --git a/operator/config/samples/lifecycle_v1alpha1_service.yaml b/operator/config/samples/lifecycle_v1alpha1_service.yaml index e299e0214c1..3d53ea9548d 100644 --- a/operator/config/samples/lifecycle_v1alpha1_service.yaml +++ b/operator/config/samples/lifecycle_v1alpha1_service.yaml @@ -5,8 +5,6 @@ metadata: spec: application: Application12 preDeploymentChecks: - service: service-test - application: Application12 job: backoffLimit: 5 activeDeadlineSeconds: 100 diff --git a/operator/controllers/service_controller.go b/operator/controllers/service_controller.go index b6263e978b4..194544b21e4 100644 --- a/operator/controllers/service_controller.go +++ b/operator/controllers/service_controller.go @@ -82,13 +82,13 @@ func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if service.IsDeploymentCheckNotCreated() { logger.Info("Deployment checks do not exist, creating") - preDeploymentCheksName, err := r.startPreDeploymentChecks(ctx, service) + preDeploymentCheckName, err := r.startPreDeploymentChecks(ctx, service) if err != nil { logger.Error(err, "Could not start pre-deployment checks") return reconcile.Result{}, err } - service.Status.PreDeploymentChecksName = preDeploymentCheksName + service.Status.PreDeploymentCheckName = preDeploymentCheckName service.Status.Phase = v1alpha1.ServiceRunning k8sEvent := r.generateK8sEvent(service, "started") @@ -166,7 +166,7 @@ func (r *ServiceReconciler) startPreDeploymentChecks(ctx context.Context, servic Spec: v1alpha1.EventSpec{ Service: service.Name, Application: service.Spec.ApplicationName, - JobSpec: service.Spec.PreDeplymentChecks.JobSpec, + JobSpec: service.Spec.PreDeplymentCheck.JobSpec, }, } for i := 0; i < 5; i++ { @@ -221,7 +221,7 @@ func (r *ServiceReconciler) generateK8sEvent(service *v1alpha1.Service, eventTyp func (r *ServiceReconciler) getPreDeploymentChecksEvent(ctx context.Context, service *v1alpha1.Service) (*v1alpha1.Event, error) { event := &v1alpha1.Event{} - err := r.Get(ctx, types.NamespacedName{Name: service.Status.PreDeploymentChecksName, Namespace: service.Namespace}, event) + err := r.Get(ctx, types.NamespacedName{Name: service.Status.PreDeploymentCheckName, Namespace: service.Namespace}, event) if errors.IsNotFound(err) { return nil, err }