@@ -55,29 +55,37 @@ func main() {
5555 concurrent int
5656 logLevel string
5757 logJSON bool
58+ watchAllNamespaces bool
5859 )
60+
5961 flag .StringVar (& metricsAddr , "metrics-addr" , ":8080" , "The address the metric endpoint binds to." )
6062 flag .StringVar (& eventsAddr , "events-addr" , ":9090" , "The address the event endpoint binds to." )
6163 flag .StringVar (& receiverAddr , "receiverAddr" , ":9292" , "The address the webhook receiver endpoint binds to." )
62-
6364 flag .BoolVar (& enableLeaderElection , "enable-leader-election" , false ,
6465 "Enable leader election for controller manager. " +
6566 "Enabling this will ensure there is only one active controller manager." )
6667 flag .IntVar (& concurrent , "concurrent" , 4 , "The number of concurrent notification reconciles." )
6768 flag .StringVar (& logLevel , "log-level" , "info" , "Set logging level. Can be debug, info or error." )
6869 flag .BoolVar (& logJSON , "log-json" , false , "Set logging to JSON format." )
70+ flag .BoolVar (& watchAllNamespaces , "watch-all-namespaces" , true ,
71+ "Watch for custom resources in all namespaces, if set to false it will only watch the runtime namespace." )
6972 flag .Parse ()
7073
7174 zapLogger := logger .NewLogger (logLevel , logJSON )
7275 ctrl .SetLogger (zapLogger )
7376
77+ watchNamespace := ""
78+ if ! watchAllNamespaces {
79+ watchNamespace = os .Getenv ("RUNTIME_NAMESPACE" )
80+ }
81+
7482 mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
7583 Scheme : scheme ,
7684 MetricsBindAddress : metricsAddr ,
7785 Port : 9443 ,
7886 LeaderElection : enableLeaderElection ,
7987 LeaderElectionID : "4ae6d3b3.fluxcd.io" ,
80- Namespace : os . Getenv ( "RUNTIME_NAMESPACE" ) ,
88+ Namespace : watchNamespace ,
8189 Logger : ctrl .Log ,
8290 })
8391 if err != nil {
0 commit comments