Skip to content

Commit 929b286

Browse files
author
Shawn Hurley
committed
adding string methods for the channel sources.
1 parent ddf0390 commit 929b286

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pkg/source/source.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimiting
9595
return nil
9696
}
9797

98+
func (ks *Kind) String() string {
99+
return fmt.Sprintf("kind source: %v", ks.Type.GetObjectKind().GroupVersionKind().String())
100+
}
101+
98102
var _ inject.Cache = &Kind{}
99103

100104
// InjectCache is internal should be called only by the Controller. InjectCache is used to inject
@@ -132,6 +136,10 @@ type Channel struct {
132136
destLock sync.Mutex
133137
}
134138

139+
func (c *Channel) String() string {
140+
return fmt.Sprintf("channel source: %p", c)
141+
}
142+
135143
var _ inject.Stoppable = &Channel{}
136144

137145
// InjectStopChannel is internal should be called only by the Controller.
@@ -240,18 +248,22 @@ var _ Source = &Informer{}
240248

241249
// Start is internal and should be called only by the Controller to register an EventHandler with the Informer
242250
// to enqueue reconcile.Requests.
243-
func (ks *Informer) Start(handler handler.EventHandler, queue workqueue.RateLimitingInterface,
251+
func (is *Informer) Start(handler handler.EventHandler, queue workqueue.RateLimitingInterface,
244252
prct ...predicate.Predicate) error {
245253

246254
// Informer should have been specified by the user.
247-
if ks.Informer == nil {
255+
if is.Informer == nil {
248256
return fmt.Errorf("must specify Informer.Informer")
249257
}
250258

251-
ks.Informer.AddEventHandler(internal.EventHandler{Queue: queue, EventHandler: handler, Predicates: prct})
259+
is.Informer.AddEventHandler(internal.EventHandler{Queue: queue, EventHandler: handler, Predicates: prct})
252260
return nil
253261
}
254262

263+
func (is *Informer) String() string {
264+
return fmt.Sprintf("informer source: %p", is.Informer)
265+
}
266+
255267
// Func is a function that implements Source
256268
type Func func(handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error
257269

@@ -260,3 +272,7 @@ func (f Func) Start(evt handler.EventHandler, queue workqueue.RateLimitingInterf
260272
pr ...predicate.Predicate) error {
261273
return f(evt, queue, pr...)
262274
}
275+
276+
func (f Func) String() string {
277+
return fmt.Sprintf("func source: %p", f)
278+
}

0 commit comments

Comments
 (0)