Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Sep 19, 2022
1 parent d0f460a commit d201818
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
10 changes: 5 additions & 5 deletions operator/api/v1alpha1/service_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion operator/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions operator/config/samples/lifecycle_v1alpha1_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
spec:
application: Application12
preDeploymentChecks:
service: service-test
application: Application12
job:
backoffLimit: 5
activeDeadlineSeconds: 100
Expand Down
8 changes: 4 additions & 4 deletions operator/controllers/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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++ {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit d201818

Please sign in to comment.