diff --git a/main.go b/main.go index 1507e584e..a4c3ef59c 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ package main import ( "flag" "os" + "strings" redisv1beta1 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta1" redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2" @@ -86,8 +87,13 @@ func main() { LeaderElectionID: "6cab913b.redis.opstreelabs.in", } - if ns := os.Getenv("WATCH_NAMESPACE"); ns != "" { - options.Cache.DefaultNamespaces = map[string]cache.Config{ns: {}} + if namespaces := strings.TrimSpace(os.Getenv("WATCH_NAMESPACE")); namespaces != "" { + options.Cache.DefaultNamespaces = map[string]cache.Config{} + for _, ns := range strings.Split(namespaces, ",") { + if ns = strings.TrimSpace(ns); ns != "" { + options.Cache.DefaultNamespaces[ns] = cache.Config{} + } + } } mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options)