Skip to content

Commit dac93a0

Browse files
committed
✨Cache: Export NewInformer
Overwriting NewInformer may be useful for testing purposes and allows to bring a custom Informer implementation.
1 parent 711b48b commit dac93a0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/cache/cache.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ type Options struct {
239239
// If unset, this will fall through to the Default* settings.
240240
ByObject map[client.Object]ByObject
241241

242-
// newInformer allows overriding of NewSharedIndexInformer for testing.
243-
newInformer *func(toolscache.ListerWatcher, runtime.Object, time.Duration, toolscache.Indexers) toolscache.SharedIndexInformer
242+
// NewInformer allows overriding of NewSharedIndexInformer, for example for testing
243+
// or if someone wants to write their own Informer.
244+
NewInformer *func(toolscache.ListerWatcher, runtime.Object, time.Duration, toolscache.Indexers) toolscache.SharedIndexInformer
244245
}
245246

246247
// ByObject offers more fine-grained control over the cache's ListWatch by object.
@@ -432,7 +433,7 @@ func newCache(restConfig *rest.Config, opts Options) newCacheFunc {
432433
WatchErrorHandler: opts.DefaultWatchErrorHandler,
433434
UnsafeDisableDeepCopy: ptr.Deref(config.UnsafeDisableDeepCopy, false),
434435
EnableWatchBookmarks: ptr.Deref(config.EnableWatchBookmarks, true),
435-
NewInformer: opts.newInformer,
436+
NewInformer: opts.NewInformer,
436437
}),
437438
readerFailOnMissingInformer: opts.ReaderFailOnMissingInformer,
438439
}

0 commit comments

Comments
 (0)