Skip to content

Commit 298dd08

Browse files
committed
add a single test for initcontainer
Signed-off-by: Mangaal <[email protected]>
1 parent 0da2924 commit 298dd08

File tree

2 files changed

+6
-41
lines changed

2 files changed

+6
-41
lines changed

controllers/argocd/deployment.go

+3-19
Original file line numberDiff line numberDiff line change
@@ -851,12 +851,12 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
851851
explanation += "container volume mounts"
852852
changed = true
853853
}
854-
if !reflect.DeepEqual(deploy.Spec.Template.Spec.InitContainers[0].Env, existing.Spec.Template.Spec.InitContainers[0].Env) {
855-
existing.Spec.Template.Spec.InitContainers[0].Env = deploy.Spec.Template.Spec.InitContainers[0].Env
854+
if !reflect.DeepEqual(deploy.Spec.Template.Spec.InitContainers, existing.Spec.Template.Spec.InitContainers) {
855+
existing.Spec.Template.Spec.InitContainers = deploy.Spec.Template.Spec.InitContainers
856856
if changed {
857857
explanation += ", "
858858
}
859-
explanation += "init containers env"
859+
explanation += "init containers"
860860
changed = true
861861
}
862862
if !reflect.DeepEqual(deploy.Spec.Template.Spec.Containers[0].Env,
@@ -884,22 +884,6 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
884884
explanation += "container security context"
885885
changed = true
886886
}
887-
if !reflect.DeepEqual(deploy.Spec.Template.Spec.InitContainers[0].Resources, existing.Spec.Template.Spec.InitContainers[0].Resources) {
888-
existing.Spec.Template.Spec.InitContainers[0].Resources = deploy.Spec.Template.Spec.InitContainers[0].Resources
889-
if changed {
890-
explanation += ", "
891-
}
892-
explanation += "init container resources"
893-
changed = true
894-
}
895-
if !reflect.DeepEqual(deploy.Spec.Template.Spec.InitContainers[0].SecurityContext, existing.Spec.Template.Spec.InitContainers[0].SecurityContext) {
896-
existing.Spec.Template.Spec.InitContainers[0].SecurityContext = deploy.Spec.Template.Spec.InitContainers[0].SecurityContext
897-
if changed {
898-
explanation += ", "
899-
}
900-
explanation += "init container security context"
901-
changed = true
902-
}
903887
if changed {
904888
argoutil.LogResourceUpdate(log, existing, "updating", explanation)
905889
return r.Client.Update(context.TODO(), existing)

controllers/argocd/statefulset.go

+3-22
Original file line numberDiff line numberDiff line change
@@ -496,33 +496,14 @@ func (r *ReconcileArgoCD) reconcileRedisStatefulSet(cr *argoproj.ArgoCD) error {
496496
explanation += "volumes"
497497
changed = true
498498
}
499-
if !reflect.DeepEqual(ss.Spec.Template.Spec.InitContainers[0].Resources, existing.Spec.Template.Spec.InitContainers[0].Resources) {
500-
existing.Spec.Template.Spec.InitContainers[0].Resources = ss.Spec.Template.Spec.InitContainers[0].Resources
501-
if changed {
502-
explanation += ", "
503-
}
504-
explanation += fmt.Sprintf("init container '%s' resources", existing.Spec.Template.Spec.InitContainers[0].Name)
505-
changed = true
506-
}
507-
508-
if !reflect.DeepEqual(ss.Spec.Template.Spec.InitContainers[0].SecurityContext, existing.Spec.Template.Spec.InitContainers[0].SecurityContext) {
509-
existing.Spec.Template.Spec.InitContainers[0].SecurityContext = ss.Spec.Template.Spec.InitContainers[0].SecurityContext
510-
if changed {
511-
explanation += ", "
512-
}
513-
explanation += fmt.Sprintf("init container '%s' security context", existing.Spec.Template.Spec.InitContainers[0].Name)
514-
changed = true
515-
}
516-
517-
if !reflect.DeepEqual(ss.Spec.Template.Spec.InitContainers[0].Env, existing.Spec.Template.Spec.InitContainers[0].Env) {
518-
existing.Spec.Template.Spec.InitContainers[0].Env = ss.Spec.Template.Spec.InitContainers[0].Env
499+
if !reflect.DeepEqual(ss.Spec.Template.Spec.InitContainers, existing.Spec.Template.Spec.InitContainers) {
500+
existing.Spec.Template.Spec.InitContainers = ss.Spec.Template.Spec.InitContainers
519501
if changed {
520502
explanation += ", "
521503
}
522-
explanation += fmt.Sprintf("init container '%s' env", existing.Spec.Template.Spec.InitContainers[0].Name)
504+
explanation += "init containers"
523505
changed = true
524506
}
525-
526507
if changed {
527508
argoutil.LogResourceUpdate(log, existing, "updating", explanation)
528509
return r.Client.Update(context.TODO(), existing)

0 commit comments

Comments
 (0)