@@ -81,6 +81,7 @@ type Reconciler struct {
81
81
selectorPredicate predicate.Predicate
82
82
overrideValues map [string ]string
83
83
skipDependentWatches bool
84
+ extraWatchSources []source.Source
84
85
maxConcurrentReconciles int
85
86
reconcilePeriod time.Duration
86
87
waitForDeletionTimeout time.Duration
@@ -555,6 +556,16 @@ func WithValueMapper(m values.Mapper) Option {
555
556
}
556
557
}
557
558
559
+ // WithExtraWatch is an Option that adds an extra event watch.
560
+ // Use this if you want your controller to respond to events other than coming from the primary custom resource,
561
+ // the helm release secret, or resources created by your helm chart.
562
+ func WithExtraWatch (src source.Source ) Option {
563
+ return func (r * Reconciler ) error {
564
+ r .extraWatchSources = append (r .extraWatchSources , src )
565
+ return nil
566
+ }
567
+ }
568
+
558
569
// WithSelector is an Option that configures the reconciler to creates a
559
570
// predicate that is used to filter resources based on the specified selector
560
571
func WithSelector (s metav1.LabelSelector ) Option {
@@ -1144,6 +1155,12 @@ func (r *Reconciler) setupWatches(mgr ctrl.Manager, c controller.Controller) err
1144
1155
return err
1145
1156
}
1146
1157
1158
+ for _ , s := range r .extraWatchSources {
1159
+ if err := c .Watch (s ); err != nil {
1160
+ return err
1161
+ }
1162
+ }
1163
+
1147
1164
if ! r .skipDependentWatches {
1148
1165
r .postHooks = append ([]hook.PostHook {internalhook .NewDependentResourceWatcher (c , mgr .GetRESTMapper (), mgr .GetCache (), mgr .GetScheme ())}, r .postHooks ... )
1149
1166
}
0 commit comments