From a890ffa6b32e5ec3e2c1e458adcfcab44b03e8ca Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 1 Aug 2024 09:41:47 +0200 Subject: [PATCH] fix(feature): preserves original target namespace (#1148) This change ensures that original target namespace is used when invoked directly in the builder. Typically subsequent calls of .TargetNamespace in the feature builder indicate coding/copy-paste error and should be reduced to one. However,in the FeatureHandler, where we group features together we do not have to specify target namespace for each feature, as it is defaulted to the one defined on the handler level. This is convenient, but limits application of features to a single namespace, as the value is always overwritten. --- pkg/feature/builder.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/feature/builder.go b/pkg/feature/builder.go index cf31a1ee047..7ddfbbeb6bd 100644 --- a/pkg/feature/builder.go +++ b/pkg/feature/builder.go @@ -67,9 +67,11 @@ func (fb *featureBuilder) Source(source featurev1.Source) *featureBuilder { } // TargetNamespace sets the namespace in which the feature should be applied. -// If not set, the feature will be applied in the application namespace. +// Calling it multiple times in the builder chain will have no effect, as the first value is used. func (fb *featureBuilder) TargetNamespace(targetNs string) *featureBuilder { - fb.targetNs = targetNs + if fb.targetNs == "" { + fb.targetNs = targetNs + } return fb }