Skip to content

Commit

Permalink
feat: WATCH_NAMESPACE support multi namespace (OT-CONTAINER-KIT#919)
Browse files Browse the repository at this point in the history
* feat: WATCH_NAMESPACE support multi namespace

Signed-off-by: drivebyer <[email protected]>

* format

Signed-off-by: drivebyer <[email protected]>

---------

Signed-off-by: drivebyer <[email protected]>
Signed-off-by: Matt Robinson <[email protected]>
  • Loading branch information
drivebyer authored and mattrobinsonsre committed Jul 11, 2024
1 parent aeab02a commit 1d6bb99
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1d6bb99

Please sign in to comment.