From f893a2da701ceaa59086cb29de74e43653ace312 Mon Sep 17 00:00:00 2001 From: Priyank Upadhyay Date: Tue, 12 Nov 2024 10:03:55 +0530 Subject: [PATCH] fix(): append missing labels instead of replacing Signed-off-by: Priyank Upadhyay --- service/namespace_service.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/service/namespace_service.go b/service/namespace_service.go index 5eea0f42..d93cf3ea 100644 --- a/service/namespace_service.go +++ b/service/namespace_service.go @@ -88,7 +88,12 @@ func (n *NamespaceService) ReconcileProjectNamespace(ctx context.Context, namesp } else { // check if the namespace has the correct labels if !util.CompareLabels(nsResource.Labels, n.getResourceLabel(namespace, owner)) { - nsResource.Labels = n.getResourceLabel(namespace, owner) + // append missing labels + for key, value := range n.getResourceLabel(namespace, owner) { + if nsResource.Labels[key] != value { + nsResource.Labels[key] = value + } + } err := util.UpdateResource(ctx, nsResource) nsResource.Namespace = ControllerNamespace if err != nil {