@@ -74,11 +74,10 @@ func ControllerManagedBy(m manager.Manager) *Builder {
74
74
75
75
// ForInput represents the information set by the For method.
76
76
type 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
82
81
}
83
82
84
83
// 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 {
101
100
102
101
// OwnsInput represents the information set by Owns method.
103
102
type 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
109
107
}
110
108
111
109
// 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 {
128
126
129
127
// WatchesInput represents the information set by Watches method.
130
128
type 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
136
133
}
137
134
138
135
// 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 {
287
284
if err != nil {
288
285
return err
289
286
}
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 )
294
288
hdler := & handler.EnqueueRequestForObject {}
295
289
allPredicates := append ([]predicate.Predicate (nil ), blder .globalPredicates ... )
296
290
allPredicates = append (allPredicates , blder .forInput .predicates ... )
@@ -308,10 +302,7 @@ func (blder *Builder) doWatch() error {
308
302
if err != nil {
309
303
return err
310
304
}
311
- src := clusterAwareSource {
312
- DeepCopyableSyncingSource : source .Kind (blder .cluster .GetCache (), obj ),
313
- forceDefaultCluster : own .forceDefaultCluster ,
314
- }
305
+ src := source .Kind (blder .cluster .GetCache (), obj )
315
306
opts := []handler.OwnerOption {}
316
307
if ! own .matchEveryOwner {
317
308
opts = append (opts , handler .OnlyControllerOwner ())
@@ -334,17 +325,12 @@ func (blder *Builder) doWatch() error {
334
325
}
335
326
for _ , w := range blder .watchesInput {
336
327
// If the source of this watch is of type Kind, project it.
337
- src := w .src
338
328
if srcKind , ok := w .src .(* internalsource.Kind ); ok {
339
329
typeForSrc , err := blder .project (srcKind .Type , w .objectProjection )
340
330
if err != nil {
341
331
return err
342
332
}
343
333
srcKind .Type = typeForSrc
344
- src = clusterAwareSource {
345
- DeepCopyableSyncingSource : srcKind ,
346
- forceDefaultCluster : w .forceDefaultCluster ,
347
- }
348
334
} else if ! ok {
349
335
// If we're building a cluster-aware controller, raw watches are not allowed
350
336
// given that the cache cannot be validated to be coming from the same cluster.
@@ -356,7 +342,7 @@ func (blder *Builder) doWatch() error {
356
342
}
357
343
allPredicates := append ([]predicate.Predicate (nil ), blder .globalPredicates ... )
358
344
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 {
360
346
return err
361
347
}
362
348
}
@@ -445,12 +431,3 @@ func (blder *Builder) doController(r reconcile.Reconciler) error {
445
431
blder .ctrl , err = newController (controllerName , blder .mgr , ctrlOptions )
446
432
return err
447
433
}
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