@@ -57,20 +57,15 @@ type ReceiverReconciler struct {
5757
5858type ReceiverReconcilerOptions struct {
5959 RateLimiter workqueue.TypedRateLimiter [reconcile.Request ]
60+ WatchConfigs bool
6061 WatchConfigsPredicate predicate.Predicate
6162}
6263
63- func (r * ReceiverReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
64- return r .SetupWithManagerAndOptions (mgr , ReceiverReconcilerOptions {
65- WatchConfigsPredicate : predicate .Not (predicate.Funcs {}),
66- })
67- }
68-
6964const (
7065 secretRefIndex = ".metadata.secretRef"
7166)
7267
73- func (r * ReceiverReconciler ) SetupWithManagerAndOptions (mgr ctrl.Manager , opts ReceiverReconcilerOptions ) error {
68+ func (r * ReceiverReconciler ) SetupWithManager (mgr ctrl.Manager , opts ReceiverReconcilerOptions ) error {
7469 // This index is used to list Receivers by their webhook path after the receiver server
7570 // gets a request.
7671 if err := mgr .GetFieldIndexer ().IndexField (context .Background (), & apiv1.Receiver {},
@@ -87,19 +82,21 @@ func (r *ReceiverReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts R
8782 }); err != nil {
8883 }
8984
90- return ctrl .NewControllerManagedBy (mgr ).
85+ ctrlBuilder := ctrl .NewControllerManagedBy (mgr ).
9186 For (& apiv1.Receiver {}, builder .WithPredicates (
9287 predicate .Or (predicate.GenerationChangedPredicate {}, predicates.ReconcileRequestedPredicate {}),
93- )).
94- WatchesMetadata (
95- & corev1.Secret {},
96- handler .EnqueueRequestsFromMapFunc (r .enqueueRequestsForChangeOf ),
97- builder .WithPredicates (predicate.ResourceVersionChangedPredicate {}, opts .WatchConfigsPredicate ),
98- ).
99- WithOptions (controller.Options {
100- RateLimiter : opts .RateLimiter ,
101- }).
102- Complete (r )
88+ ))
89+
90+ if opts .WatchConfigs {
91+ ctrlBuilder = ctrlBuilder .
92+ WatchesMetadata (
93+ & corev1.Secret {},
94+ handler .EnqueueRequestsFromMapFunc (r .enqueueRequestsForChangeOf ),
95+ builder .WithPredicates (predicate.ResourceVersionChangedPredicate {}, opts .WatchConfigsPredicate ),
96+ )
97+ }
98+
99+ return ctrlBuilder .WithOptions (controller.Options {RateLimiter : opts .RateLimiter }).Complete (r )
103100}
104101
105102// enqueueRequestsForChangeOf enqueues Receiver requests for changes in referenced Secret objects.
0 commit comments