Skip to content

Commit

Permalink
Add ability to filter objects on injection controller promotion
Browse files Browse the repository at this point in the history
Currently we enqueue every object with no way to filter, which causes
problems for eventing's source controller which reconciles duck CRDs.
  • Loading branch information
Ben Moss committed Jun 24, 2021
1 parent a1bc850 commit 048e517
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion codegen/cmd/injection-gen/generators/reconciler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 048e517

Please sign in to comment.