Skip to content

Commit

Permalink
✨Cache: Export NewInformer
Browse files Browse the repository at this point in the history
Overwrting NewInformer may be useful for testing purposes and allows to
bring a custom Informer implementation.
  • Loading branch information
alvaroaleman committed Jan 7, 2025
1 parent 711b48b commit 44e8990
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ type Options struct {
// If unset, this will fall through to the Default* settings.
ByObject map[client.Object]ByObject

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

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

0 comments on commit 44e8990

Please sign in to comment.