diff --git a/main.go b/main.go index 859bb0be..ffd2dee4 100644 --- a/main.go +++ b/main.go @@ -83,9 +83,9 @@ func main() { os.Exit(0) } - watchNamespace, err := utils.GetWatchNamespace() - if err != nil { - klog.Error(err, "unable to get WatchNamespace, "+ + watchNamespace, envSet := utils.GetWatchNamespace() + if !envSet { + klog.Warning("unable to get WatchNamespace, " + "the manager will watch and manage resources in all namespaces") } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 23ac8ca7..b23d341a 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -16,21 +16,15 @@ limitations under the License. package utils import ( - "fmt" "os" ) -// GetWatchNamespace returns the Namespace the operator should be watching for changes -func GetWatchNamespace() (string, error) { - // WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE - // which specifies the Namespace to watch. - // An empty value means the operator is running with cluster scope. - var watchNamespaceEnvVar = "WATCH_NAMESPACE" - - ns, found := os.LookupEnv(watchNamespaceEnvVar) - if !found { - return "", fmt.Errorf("%s must be set", watchNamespaceEnvVar) - } +// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE +// which specifies the Namespace to watch. +// An empty value means the operator is running with cluster scope. +const WatchNamespaceEnvVar = "WATCH_NAMESPACE" - return ns, nil +// GetWatchNamespace returns the Namespace the operator should be watching for changes +func GetWatchNamespace() (string, bool) { + return os.LookupEnv(WatchNamespaceEnvVar) }