Skip to content

Commit

Permalink
Ensure that enqueuemapped's mapper gets deps
Browse files Browse the repository at this point in the history
Previously, we weren't injecting dependencies into the Mapper in the
enqueue-mapped handler.  This makes more complicated to things that
require clients, etc.
  • Loading branch information
DirectXMan12 committed Feb 13, 2019
1 parent 6443f37 commit c1cf624
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/handler/enqueue_mapped.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"
)

var _ EventHandler = &EnqueueRequestsFromMapFunc{}
Expand Down Expand Up @@ -68,6 +69,16 @@ func (e *EnqueueRequestsFromMapFunc) mapAndEnqueue(q workqueue.RateLimitingInter
}
}

// EnqueueRequestsFromMapFunc can inject fields into the mapper.

// InjectFunc implements inject.Injector.
func (e *EnqueueRequestsFromMapFunc) InjectFunc(f inject.Func) error {
if f == nil {
return nil
}
return f(e.ToRequests)
}

// Mapper maps an object to a collection of keys to be enqueued
type Mapper interface {
// Map maps an object
Expand Down

0 comments on commit c1cf624

Please sign in to comment.