Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Dec 23, 2024
1 parent afe9128 commit 0cb82b5
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ func main() {
LeaderElectionID: "19fd6fcc.emqx.io",
LeaseDuration: ptr.To(time.Second * 30),
RenewDeadline: ptr.To(time.Second * 20),
Cache: getCacheOptions(),
Cache: cache.Options{
DefaultNamespaces: getWatchNamespace(),
},
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down Expand Up @@ -176,26 +178,15 @@ func main() {
}
}

func getCacheOptions() cache.Options {
// getWatchNamespace returns the Namespace the operator should be watching for changes
func getWatchNamespace() map[string]cache.Config {
var watchNamespaceEnvVar = "WATCH_NAMESPACE"

ns, found := os.LookupEnv(watchNamespaceEnvVar)
if !found {
return cache.Options{}
}

return cache.Options{
DefaultNamespaces: map[string]cache.Config{ns: {}},
if found {
return map[string]cache.Config{
ns: {},
}
}
return nil
}

// getWatchNamespace returns the Namespace the operator should be watching for changes
// func getWatchNamespace() string {
// var watchNamespaceEnvVar = "WATCH_NAMESPACE"

// ns, found := os.LookupEnv(watchNamespaceEnvVar)
// if !found {
// return metav1.NamespaceAll
// }
// return ns
// }

0 comments on commit 0cb82b5

Please sign in to comment.