Skip to content

Commit 2579036

Browse files
committed
Add watch-filter flag to enable controller to watch for label
1 parent b375131 commit 2579036

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
@@ -63,6 +63,7 @@ var (
6363
logOptions = logs.NewOptions()
6464
webhookPort int
6565
webhookCertDir string
66+
watchFilterValue string
6667

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

135+
fs.StringVar(&watchFilterValue, "watch-filter", "",
136+
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))
137+
134138
logsv1.AddFlags(logOptions, fs)
135139
flags.AddManagerOptions(fs, &managerOptions)
136140
}
@@ -278,10 +282,11 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, serviceEndpoint []e
278282
}
279283

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

0 commit comments

Comments
 (0)