Skip to content

Commit 37b5117

Browse files
authored
Correctly parse manged namespaces when specified as env var (#8513)
Workaround spf13/viper#380 by using `viper.UnmarshalKey`
1 parent 289fcc0 commit 37b5117

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmd/manager/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,12 @@ func startOperator(ctx context.Context) error {
572572
}
573573

574574
// configure the manager cache based on the number of managed namespaces
575-
managedNamespaces := viper.GetStringSlice(operator.NamespacesFlag)
575+
var managedNamespaces []string
576+
// do not use viper.GetStringSlice here as it suffers from https://github.com/spf13/viper/issues/380
577+
if err := viper.UnmarshalKey(operator.NamespacesFlag, &managedNamespaces); err != nil {
578+
log.Error(err, "Failed to parse managed namespaces flag")
579+
return err
580+
}
576581
switch {
577582
case len(managedNamespaces) == 0:
578583
log.Info("Operator configured to manage all namespaces")

0 commit comments

Comments
 (0)