@@ -50,9 +50,9 @@ import (
5050)
5151
5252var (
53- scheme = runtime .NewScheme ()
54- setupLog = ctrl .Log .WithName ("setup" )
55- diagnosticsOptions = flags.DiagnosticsOptions {}
53+ scheme = runtime .NewScheme ()
54+ setupLog = ctrl .Log .WithName ("setup" )
55+ managerOptions = flags.ManagerOptions {}
5656)
5757
5858func init () {
@@ -93,7 +93,10 @@ func main() {
9393 pflag .CommandLine .AddGoFlagSet (flag .CommandLine )
9494 pflag .Parse ()
9595
96- diagnosticsOpts := flags .GetDiagnosticsOptions (diagnosticsOptions )
96+ _ , metricsOptions , err := flags .GetManagerOptions (managerOptions )
97+ if err != nil {
98+ setupLog .Error (err , "Unable to start manager: invalid flags" )
99+ }
97100
98101 var watchNamespaces map [string ]cache.Config
99102 if watchNamespace != "" {
@@ -130,7 +133,7 @@ func main() {
130133
131134 mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
132135 Scheme : scheme ,
133- Metrics : diagnosticsOpts ,
136+ Metrics : * metricsOptions ,
134137 LeaderElection : enableLeaderElection ,
135138 LeaderElectionID : "controller-leader-election-capg" ,
136139 LeaderElectionNamespace : leaderElectionNamespace ,
@@ -371,7 +374,7 @@ func initFlags(fs *pflag.FlagSet) {
371374 "The maximum duration a reconcile loop can run (e.g. 90m)" ,
372375 )
373376
374- flags .AddDiagnosticsOptions (fs , & diagnosticsOptions )
377+ flags .AddManagerOptions (fs , & managerOptions )
375378
376379 feature .MutableGates .AddFlag (fs )
377380}
0 commit comments