Skip to content

Commit

Permalink
fixup! update deps; controller-runtime to v0.16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yorugac committed Oct 13, 2023
1 parent e986d6e commit 91d2a8a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseDevMode(true)))

watchNamespace := getWatchNamespace()

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
mgrOpts := ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
Expand All @@ -75,12 +73,16 @@ func main() {
LeaderElection: enableLeaderElection,
LeaderElectionID: "fcdfce80.io",
LeaderElectionResourceLock: "leases",
Cache: cache.Options{
}
if watchNamespace, namespaced := getWatchNamespace(); namespaced {
mgrOpts.Cache = cache.Options{
DefaultNamespaces: map[string]cache.Config{
watchNamespace: cache.Config{},
},
},
})
}
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), mgrOpts)
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
Expand Down Expand Up @@ -123,12 +125,8 @@ func main() {
}
}

func getWatchNamespace() string {
func getWatchNamespace() (string, bool) {
var watchNamespaceEnvVar = "WATCH_NAMESPACE"

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

0 comments on commit 91d2a8a

Please sign in to comment.