@@ -74,11 +74,10 @@ func ControllerManagedBy(m manager.Manager) *Builder {
7474
7575// ForInput represents the information set by the For method.
7676type ForInput struct {
77- object client.Object
78- forceDefaultCluster bool // in cluster-aware mode, force the object to be watched in the default cluster
79- predicates []predicate.Predicate
80- objectProjection objectProjection
81- err error
77+ object client.Object
78+ predicates []predicate.Predicate
79+ objectProjection objectProjection
80+ err error
8281}
8382
8483// For defines the type of Object being *reconciled*, and configures the ControllerManagedBy to respond to create / delete /
@@ -101,11 +100,10 @@ func (blder *Builder) For(object client.Object, opts ...ForOption) *Builder {
101100
102101// OwnsInput represents the information set by Owns method.
103102type OwnsInput struct {
104- matchEveryOwner bool
105- object client.Object
106- forceDefaultCluster bool // in cluster-aware mode, force the object to be watched in the default cluster
107- predicates []predicate.Predicate
108- objectProjection objectProjection
103+ matchEveryOwner bool
104+ object client.Object
105+ predicates []predicate.Predicate
106+ objectProjection objectProjection
109107}
110108
111109// Owns defines types of Objects being *generated* by the ControllerManagedBy, and configures the ControllerManagedBy to respond to
@@ -128,11 +126,10 @@ func (blder *Builder) Owns(object client.Object, opts ...OwnsOption) *Builder {
128126
129127// WatchesInput represents the information set by Watches method.
130128type WatchesInput struct {
131- src source.Source
132- forceDefaultCluster bool // in cluster-aware mode, force the object to be watched in the default cluster
133- eventHandler handler.EventHandler
134- predicates []predicate.Predicate
135- objectProjection objectProjection
129+ src source.Source
130+ eventHandler handler.EventHandler
131+ predicates []predicate.Predicate
132+ objectProjection objectProjection
136133}
137134
138135// Watches defines the type of Object to watch, and configures the ControllerManagedBy to respond to create / delete /
@@ -287,10 +284,7 @@ func (blder *Builder) doWatch() error {
287284 if err != nil {
288285 return err
289286 }
290- src := clusterAwareSource {
291- DeepCopyableSyncingSource : source .Kind (blder .cluster .GetCache (), obj ),
292- forceDefaultCluster : blder .forInput .forceDefaultCluster ,
293- }
287+ src := source .Kind (blder .cluster .GetCache (), obj )
294288 hdler := & handler.EnqueueRequestForObject {}
295289 allPredicates := append ([]predicate.Predicate (nil ), blder .globalPredicates ... )
296290 allPredicates = append (allPredicates , blder .forInput .predicates ... )
@@ -308,10 +302,7 @@ func (blder *Builder) doWatch() error {
308302 if err != nil {
309303 return err
310304 }
311- src := clusterAwareSource {
312- DeepCopyableSyncingSource : source .Kind (blder .cluster .GetCache (), obj ),
313- forceDefaultCluster : own .forceDefaultCluster ,
314- }
305+ src := source .Kind (blder .cluster .GetCache (), obj )
315306 opts := []handler.OwnerOption {}
316307 if ! own .matchEveryOwner {
317308 opts = append (opts , handler .OnlyControllerOwner ())
@@ -334,17 +325,12 @@ func (blder *Builder) doWatch() error {
334325 }
335326 for _ , w := range blder .watchesInput {
336327 // If the source of this watch is of type Kind, project it.
337- src := w .src
338328 if srcKind , ok := w .src .(* internalsource.Kind ); ok {
339329 typeForSrc , err := blder .project (srcKind .Type , w .objectProjection )
340330 if err != nil {
341331 return err
342332 }
343333 srcKind .Type = typeForSrc
344- src = clusterAwareSource {
345- DeepCopyableSyncingSource : srcKind ,
346- forceDefaultCluster : w .forceDefaultCluster ,
347- }
348334 } else if ! ok {
349335 // If we're building a cluster-aware controller, raw watches are not allowed
350336 // given that the cache cannot be validated to be coming from the same cluster.
@@ -356,7 +342,7 @@ func (blder *Builder) doWatch() error {
356342 }
357343 allPredicates := append ([]predicate.Predicate (nil ), blder .globalPredicates ... )
358344 allPredicates = append (allPredicates , w .predicates ... )
359- if err := blder .ctrl .Watch (src , w .eventHandler , allPredicates ... ); err != nil {
345+ if err := blder .ctrl .Watch (w . src , w .eventHandler , allPredicates ... ); err != nil {
360346 return err
361347 }
362348 }
@@ -445,12 +431,3 @@ func (blder *Builder) doController(r reconcile.Reconciler) error {
445431 blder .ctrl , err = newController (controllerName , blder .mgr , ctrlOptions )
446432 return err
447433}
448-
449- type clusterAwareSource struct {
450- source.DeepCopyableSyncingSource
451- forceDefaultCluster bool
452- }
453-
454- func (s clusterAwareSource ) ForceDefaultCluster () bool {
455- return s .forceDefaultCluster
456- }
0 commit comments