diff --git a/codegen/cmd/injection-gen/generators/reconciler_controller.go b/codegen/cmd/injection-gen/generators/reconciler_controller.go index 9471b5db8a..c97f8108dd 100644 --- a/codegen/cmd/injection-gen/generators/reconciler_controller.go +++ b/codegen/cmd/injection-gen/generators/reconciler_controller.go @@ -217,6 +217,8 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValu lister := {{.type|lowercaseSingular}}Informer.Lister() + var promoteFilterFunc func(obj interface{}) bool + rec := &reconcilerImpl{ LeaderAwareFuncs: {{.reconcilerLeaderAwareFuncs|raw}}{ PromoteFunc: func(bkt {{.reconcilerBucket|raw}}, enq func({{.reconcilerBucket|raw}}, {{.typesNamespacedName|raw}})) error { @@ -225,7 +227,11 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValu return err } for _, elt := range all { - // TODO: Consider letting users specify a filter in options. + if promoteFilterFunc != nil { + if ok := promoteFilterFunc(elt); !ok { + continue + } + } enq(bkt, {{.typesNamespacedName|raw}}{ Namespace: elt.GetNamespace(), Name: elt.GetName(), @@ -274,6 +280,9 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValu if opts.DemoteFunc != nil { rec.DemoteFunc = opts.DemoteFunc } + if opts.PromoteFilterFunc != nil { + promoteFilterFunc = opts.PromoteFilterFunc + } } rec.Recorder = createRecorder(ctx, agentName)