Skip to content

Commit b9a31b6

Browse files
committed
Add watch-filter flag to enable controller to watch for label
1 parent 6f11bfa commit b9a31b6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var (
6262
logOptions = logs.NewOptions()
6363
webhookPort int
6464
webhookCertDir string
65+
watchFilterValue string
6566

6667
scheme = runtime.NewScheme()
6768
setupLog = ctrl.Log.WithName("setup")
@@ -130,6 +131,9 @@ func initFlags(fs *pflag.FlagSet) {
130131
fs.StringVar(&webhookCertDir, "webhook-cert-dir", "/tmp/k8s-webhook-server/serving-certs/",
131132
"The webhook certificate directory, where the server should find the TLS certificate and key.")
132133

134+
fs.StringVar(&watchFilterValue, "watch-filter", "",
135+
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", capiv1beta1.WatchLabel))
136+
133137
logsv1.AddFlags(logOptions, fs)
134138
flags.AddManagerOptions(fs, &managerOptions)
135139
}
@@ -277,10 +281,11 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, serviceEndpoint []e
277281
}
278282

279283
if err := (&controllers.IBMPowerVSMachineReconciler{
280-
Client: mgr.GetClient(),
281-
Recorder: mgr.GetEventRecorderFor("ibmpowervsmachine-controller"),
282-
ServiceEndpoint: serviceEndpoint,
283-
Scheme: mgr.GetScheme(),
284+
Client: mgr.GetClient(),
285+
Recorder: mgr.GetEventRecorderFor("ibmpowervsmachine-controller"),
286+
ServiceEndpoint: serviceEndpoint,
287+
Scheme: mgr.GetScheme(),
288+
WatchFilterValue: watchFilterValue,
284289
}).SetupWithManager(ctx, mgr); err != nil {
285290
setupLog.Error(err, "unable to create controller", "controller", "IBMPowerVSMachine")
286291
os.Exit(1)

0 commit comments

Comments
 (0)