Skip to content

Commit c1cf624

Browse files
committed
Ensure that enqueuemapped's mapper gets deps
Previously, we weren't injecting dependencies into the Mapper in the enqueue-mapped handler. This makes more complicated to things that require clients, etc.
1 parent 6443f37 commit c1cf624

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/handler/enqueue_mapped.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"k8s.io/client-go/util/workqueue"
2323
"sigs.k8s.io/controller-runtime/pkg/event"
2424
"sigs.k8s.io/controller-runtime/pkg/reconcile"
25+
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"
2526
)
2627

2728
var _ EventHandler = &EnqueueRequestsFromMapFunc{}
@@ -68,6 +69,16 @@ func (e *EnqueueRequestsFromMapFunc) mapAndEnqueue(q workqueue.RateLimitingInter
6869
}
6970
}
7071

72+
// EnqueueRequestsFromMapFunc can inject fields into the mapper.
73+
74+
// InjectFunc implements inject.Injector.
75+
func (e *EnqueueRequestsFromMapFunc) InjectFunc(f inject.Func) error {
76+
if f == nil {
77+
return nil
78+
}
79+
return f(e.ToRequests)
80+
}
81+
7182
// Mapper maps an object to a collection of keys to be enqueued
7283
type Mapper interface {
7384
// Map maps an object

0 commit comments

Comments
 (0)