From e3d24344203c6f351c2401d12d48c1d1479e81e1 Mon Sep 17 00:00:00 2001 From: Sergey Dudoladov Date: Fri, 16 Feb 2018 15:20:26 +0100 Subject: [PATCH] Use '*' as an alias to denote all namespaces --- pkg/controller/controller.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 7dacef524..62046ab7f 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -109,11 +109,10 @@ func (c *Controller) initOperatorConfig() { if (isPresentInOperatorConfigMap) && (!isPresentInOperatorEnv) { - // explicitly specify the policy for handling the empty string - // v1.NamespaceAll currently also evaluates to the empty string - // so when the param is set to this value, we watch all ns - if watchedNsConfigMapVar == "" { - c.logger.Infof("The watched namespace field in the operator config map evaluates to the empty string, falling back to watching all namespaces.\n") + // explicitly specify the policy for handling all namespaces + // note that '*' is not a valid namespace name + if watchedNsConfigMapVar == "*" { + c.logger.Infof("The watched namespace field in the operator config map evaluates to '*', meaning watching all namespaces.\n") configMapData["watched_namespace"] = v1.NamespaceAll } } @@ -124,9 +123,9 @@ func (c *Controller) initOperatorConfig() { c.logger.Infof("Both WATCHED_NAMESPACE=%q env var and wacthed_namespace=%q field in operator config map are defined. The env variable takes priority over the configMap param\n", watchedNsEnvVar, watchedNsConfigMapVar) } - // handle the empty string consistently - if watchedNsEnvVar == "" { - c.logger.Infoln("The WATCHED_NAMESPACE env var evaluates to the empty string, falling back to watching all namespaces") + // handle all namespaces consistently + if watchedNsEnvVar == "*" { + c.logger.Infof("The watched namespace field in the operator config map evaluates to '*', meaning watching all namespaces.\n") configMapData["watched_namespace"] = v1.NamespaceAll } else { c.logger.Infof("Watch the %q namespace specified in the env variable WATCHED_NAMESPACE\n", watchedNsEnvVar)