diff --git a/pkg/source/source.go b/pkg/source/source.go index 4cdb2ab3e8..faae6e97da 100644 --- a/pkg/source/source.go +++ b/pkg/source/source.go @@ -95,6 +95,13 @@ func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimiting return nil } +func (ks *Kind) String() string { + if ks.Type != nil && ks.Type.GetObjectKind() != nil { + return fmt.Sprintf("kind source: %v", ks.Type.GetObjectKind().GroupVersionKind().String()) + } + return fmt.Sprintf("kind source: unknown GVK") +} + var _ inject.Cache = &Kind{} // InjectCache is internal should be called only by the Controller. InjectCache is used to inject @@ -132,6 +139,10 @@ type Channel struct { destLock sync.Mutex } +func (cs *Channel) String() string { + return fmt.Sprintf("channel source: %p", cs) +} + var _ inject.Stoppable = &Channel{} // InjectStopChannel is internal should be called only by the Controller. @@ -240,18 +251,22 @@ var _ Source = &Informer{} // Start is internal and should be called only by the Controller to register an EventHandler with the Informer // to enqueue reconcile.Requests. -func (ks *Informer) Start(handler handler.EventHandler, queue workqueue.RateLimitingInterface, +func (is *Informer) Start(handler handler.EventHandler, queue workqueue.RateLimitingInterface, prct ...predicate.Predicate) error { // Informer should have been specified by the user. - if ks.Informer == nil { + if is.Informer == nil { return fmt.Errorf("must specify Informer.Informer") } - ks.Informer.AddEventHandler(internal.EventHandler{Queue: queue, EventHandler: handler, Predicates: prct}) + is.Informer.AddEventHandler(internal.EventHandler{Queue: queue, EventHandler: handler, Predicates: prct}) return nil } +func (is *Informer) String() string { + return fmt.Sprintf("informer source: %p", is.Informer) +} + // Func is a function that implements Source type Func func(handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error @@ -260,3 +275,7 @@ func (f Func) Start(evt handler.EventHandler, queue workqueue.RateLimitingInterf pr ...predicate.Predicate) error { return f(evt, queue, pr...) } + +func (f Func) String() string { + return fmt.Sprintf("func source: %p", f) +}