From 50ad2d05d61c84f0cc27e984ae0329460a64903f Mon Sep 17 00:00:00 2001 From: Kubermatic Bot <41968677+kubermatic-bot@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:54:32 +0200 Subject: [PATCH] Refactor annotation propagation order (#67) Signed-off-by: Waleed Malik Co-authored-by: Waleed Malik --- internal/controllers/kubelb/shared.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/controllers/kubelb/shared.go b/internal/controllers/kubelb/shared.go index da9ee3b..1e28b35 100644 --- a/internal/controllers/kubelb/shared.go +++ b/internal/controllers/kubelb/shared.go @@ -61,15 +61,16 @@ func GetConfig(ctx context.Context, client ctrlclient.Client, configNamespace st func GetAnnotations(tenant *kubelbv1alpha1.Tenant, config *kubelbv1alpha1.Config) kubelbv1alpha1.AnnotationSettings { var annotations kubelbv1alpha1.AnnotationSettings - if tenant.Spec.AnnotationSettings.PropagatedAnnotations != nil { + if tenant.Spec.AnnotationSettings.PropagateAllAnnotations != nil && *tenant.Spec.AnnotationSettings.PropagateAllAnnotations { + annotations.PropagateAllAnnotations = tenant.Spec.AnnotationSettings.PropagateAllAnnotations + } else if tenant.Spec.AnnotationSettings.PropagatedAnnotations != nil { annotations.PropagatedAnnotations = tenant.Spec.AnnotationSettings.PropagatedAnnotations - } else if config.Spec.AnnotationSettings.PropagatedAnnotations != nil { - annotations.PropagatedAnnotations = config.Spec.AnnotationSettings.PropagatedAnnotations } - if tenant.Spec.AnnotationSettings.PropagateAllAnnotations == nil { - annotations.PropagateAllAnnotations = tenant.Spec.AnnotationSettings.PropagateAllAnnotations - } else if config.Spec.AnnotationSettings.PropagateAllAnnotations == nil { + + if config.Spec.AnnotationSettings.PropagateAllAnnotations != nil && *config.Spec.AnnotationSettings.PropagateAllAnnotations { annotations.PropagateAllAnnotations = config.Spec.AnnotationSettings.PropagateAllAnnotations + } else if config.Spec.AnnotationSettings.PropagatedAnnotations != nil { + annotations.PropagatedAnnotations = config.Spec.AnnotationSettings.PropagatedAnnotations } return annotations }