From 75ef622c9e2ac38fe5cfa86767f1a7cb86978ef0 Mon Sep 17 00:00:00 2001 From: wouter remijn Date: Thu, 21 May 2026 11:12:51 +0200 Subject: [PATCH 1/2] new label function --- pkg/util/util.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/util/util.go b/pkg/util/util.go index a1ff589..f2d9d4b 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -87,6 +87,18 @@ func FinalizeIfNecessary(ctx context.Context, c client.Client, obj client.Object return false, err } +// CombineLabels combines multiple sets of labels into one set of labels +// if a label key exists in multiple labelSets, the value of last labelSet with that key will be returned +func CombineLabels(labelSets ...map[string]string) map[string]string { + labels := make(map[string]string) + for _, labelSet := range labelSets { + maps.Copy(labels, labelSet) + } + return labels +} + +// SetImmutableLabels +// Deprecated: immutability check can cause conflicts with external mutators, use CombineLabels instead func SetImmutableLabels(c client.Client, obj client.Object, labels map[string]string) error { objLabels := obj.GetLabels() if obj.GetResourceVersion() != "" || len(objLabels) > 0 { From 7a4d60aef861242624fad6fa8696182fd7d528d7 Mon Sep 17 00:00:00 2001 From: wouter remijn Date: Thu, 21 May 2026 11:44:11 +0200 Subject: [PATCH 2/2] link --- pkg/util/util.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/util/util.go b/pkg/util/util.go index f2d9d4b..707b975 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -98,6 +98,7 @@ func CombineLabels(labelSets ...map[string]string) map[string]string { } // SetImmutableLabels +// // Deprecated: immutability check can cause conflicts with external mutators, use CombineLabels instead func SetImmutableLabels(c client.Client, obj client.Object, labels map[string]string) error { objLabels := obj.GetLabels()