Skip to content

Commit

Permalink
exclude comp labels when updating labels
Browse files Browse the repository at this point in the history
  • Loading branch information
cjc7373 committed Jan 20, 2025
1 parent 3851918 commit d1262f4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion controllers/apps/component/transformer_component_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,21 @@ func isLifecycleActionsEnabled(compDef *appsv1.ComponentDefinition) bool {
}

func labelAndAnnotationEqual(old, new metav1.Object) bool {
return equality.Semantic.DeepEqual(old.GetLabels(), new.GetLabels()) &&
// exclude component labels, since they are different for each component
compLabels := constant.GetCompLabels("", "")
oldLabels := make(map[string]string)
for k, v := range old.GetLabels() {
if _, ok := compLabels[k]; !ok {
oldLabels[k] = v
}
}
newLabels := make(map[string]string)
for k, v := range new.GetLabels() {
if _, ok := compLabels[k]; !ok {
newLabels[k] = v
}
}
return equality.Semantic.DeepEqual(oldLabels, newLabels) &&
equality.Semantic.DeepEqual(old.GetAnnotations(), new.GetAnnotations())
}

Expand Down

0 comments on commit d1262f4

Please sign in to comment.