Skip to content

Commit e065e6e

Browse files
committed
Added logic for annotations custom labels
Signed-off-by: Alka Kumari <alkumari@redhat.com>
1 parent 37fdd7f commit e065e6e

File tree

5 files changed

+118
-83
lines changed

5 files changed

+118
-83
lines changed

controllers/argocd/applicationset.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ func (r *ReconcileArgoCD) reconcileApplicationSetDeployment(cr *argoproj.ArgoCD,
292292
existing.Spec.Template.Spec.NodeSelector = deploy.Spec.Template.Spec.NodeSelector
293293
existing.Spec.Template.Spec.Tolerations = deploy.Spec.Template.Spec.Tolerations
294294
existing.Spec.Template.Spec.Containers[0].SecurityContext = deploy.Spec.Template.Spec.Containers[0].SecurityContext
295-
existing.Spec.Template.Annotations = deploy.Spec.Template.Annotations
296295

297296
argoutil.LogResourceUpdate(log, existing, "due to difference in", deploymentsDifferent)
298297
return r.Update(context.TODO(), existing)

controllers/argocd/deployment.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,11 +1250,7 @@ func (r *ReconcileArgoCD) reconcileServerDeployment(cr *argoproj.ArgoCD, useTLSF
12501250
}
12511251

12521252
//Check if labels/annotations have changed
1253-
UpdateMapValues(&existing.Spec.Template.Labels, deploy.Spec.Template.Labels)
1254-
UpdateMapValues(&existing.Spec.Template.Annotations, deploy.Spec.Template.Annotations)
1255-
1256-
if !reflect.DeepEqual(deploy.Spec.Template.Annotations, existing.Spec.Template.Annotations) {
1257-
existing.Spec.Template.Annotations = deploy.Spec.Template.Annotations
1253+
if UpdateMapValues(&existing.Spec.Template.Annotations, deploy.Spec.Template.Annotations) {
12581254
if changed {
12591255
explanation += ", "
12601256
}

controllers/argocd/repo_server.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,8 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argocdoperatorv1beta1.Argo
513513
changed = true
514514
}
515515

516-
// Add Kubernetes-specific labels/annotations from the live object in the source to preserve metadata.
517-
UpdateMapValues(&existing.Spec.Template.Labels, deploy.Spec.Template.Labels)
518-
UpdateMapValues(&existing.Spec.Template.Annotations, deploy.Spec.Template.Annotations)
519-
520-
if !reflect.DeepEqual(deploy.Spec.Template.Annotations, existing.Spec.Template.Annotations) {
521-
existing.Spec.Template.Annotations = deploy.Spec.Template.Annotations
516+
//Check if labels/annotations have changed
517+
if UpdateMapValues(&existing.Spec.Template.Annotations, deploy.Spec.Template.Annotations) {
522518
if changed {
523519
explanation += ", "
524520
}

controllers/argocd/statefulset.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -985,20 +985,15 @@ func (r *ReconcileArgoCD) reconcileApplicationControllerStatefulSet(cr *argoproj
985985
}
986986

987987
//Check if labels/annotations have changed
988-
UpdateMapValues(&existing.Spec.Template.Labels, ss.Spec.Template.Labels)
989-
UpdateMapValues(&existing.Spec.Template.Annotations, ss.Spec.Template.Annotations)
990-
991-
if !reflect.DeepEqual(ss.Spec.Template.Annotations, existing.Spec.Template.Annotations) {
992-
existing.Spec.Template.Annotations = ss.Spec.Template.Annotations
988+
if UpdateMapValues(&existing.Spec.Template.Annotations, ss.Spec.Template.Annotations) {
993989
if changed {
994990
explanation += ", "
995991
}
996992
explanation += "annotations"
997993
changed = true
998994
}
999995

1000-
if !reflect.DeepEqual(ss.Spec.Template.Labels, existing.Spec.Template.Labels) {
1001-
existing.Spec.Template.Labels = ss.Spec.Template.Labels
996+
if UpdateMapValues(&existing.Spec.Template.Labels, ss.Spec.Template.Labels) {
1002997
if changed {
1003998
explanation += ", "
1004999
}

0 commit comments

Comments
 (0)