@@ -77,6 +77,7 @@ type Reconciler struct {
7777 selectorPredicate predicate.Predicate
7878 overrideValues map [string ]string
7979 skipDependentWatches bool
80+ extraWatchSources []source.Source
8081 maxConcurrentReconciles int
8182 reconcilePeriod time.Duration
8283 waitForDeletionTimeout time.Duration
@@ -495,6 +496,16 @@ func WithValueMapper(m values.Mapper) Option {
495496 }
496497}
497498
499+ // WithExtraWatch is an Option that adds an extra event watch.
500+ // Use this if you want your controller to respond to events other than coming from the primary custom resource,
501+ // the helm release secret, or resources created by your helm chart.
502+ func WithExtraWatch (src source.Source ) Option {
503+ return func (r * Reconciler ) error {
504+ r .extraWatchSources = append (r .extraWatchSources , src )
505+ return nil
506+ }
507+ }
508+
498509// WithSelector is an Option that configures the reconciler to creates a
499510// predicate that is used to filter resources based on the specified selector
500511func WithSelector (s metav1.LabelSelector ) Option {
@@ -1015,6 +1026,12 @@ func (r *Reconciler) setupWatches(mgr ctrl.Manager, c controller.Controller) err
10151026 return err
10161027 }
10171028
1029+ for _ , s := range r .extraWatchSources {
1030+ if err := c .Watch (s ); err != nil {
1031+ return err
1032+ }
1033+ }
1034+
10181035 if ! r .skipDependentWatches {
10191036 r .postHooks = append ([]hook.PostHook {internalhook .NewDependentResourceWatcher (c , mgr .GetRESTMapper (), mgr .GetCache (), mgr .GetScheme ())}, r .postHooks ... )
10201037 }
0 commit comments