Skip to content

Commit

Permalink
fix(feature): preserves original target namespace (opendatahub-io#1148)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bartoszmajsak authored Aug 1, 2024
1 parent e80dcbe commit a890ffa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/feature/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit a890ffa

Please sign in to comment.