Skip to content

Commit bb69699

Browse files
committed
Allow ClusterCacheTracker to set CacheByObject
Signed-off-by: Vince Prignano <[email protected]>
1 parent d36541f commit bb69699

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

controllers/remote/cluster_cache_tracker.go

+7
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ var ErrClusterLocked = errors.New("cluster is locked already")
6969
type ClusterCacheTracker struct {
7070
log logr.Logger
7171

72+
cacheByObject map[client.Object]cache.ByObject
73+
7274
clientUncachedObjects []client.Object
7375
clientQPS float32
7476
clientBurst int
@@ -115,6 +117,9 @@ type ClusterCacheTrackerOptions struct {
115117
// Defaults to a no-op logger if it's not set.
116118
Log *logr.Logger
117119

120+
// CacheByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
121+
CacheByObject map[client.Object]cache.ByObject
122+
118123
// ClientUncachedObjects instructs the Client to never cache the following objects,
119124
// it'll instead query the API server directly.
120125
// Defaults to never caching ConfigMap and Secret if not set.
@@ -191,6 +196,7 @@ func NewClusterCacheTracker(manager ctrl.Manager, options ClusterCacheTrackerOpt
191196
controllerPodMetadata: controllerPodMetadata,
192197
log: *options.Log,
193198
clientUncachedObjects: options.ClientUncachedObjects,
199+
cacheByObject: options.CacheByObject,
194200
clientQPS: options.ClientQPS,
195201
clientBurst: options.ClientBurst,
196202
client: manager.GetClient(),
@@ -485,6 +491,7 @@ func (t *ClusterCacheTracker) createCachedClient(ctx context.Context, config *re
485491
HTTPClient: httpClient,
486492
Scheme: t.scheme,
487493
Mapper: mapper,
494+
ByObject: t.cacheByObject,
488495
}
489496
remoteCache, err := cache.New(config, cacheOptions)
490497
if err != nil {

0 commit comments

Comments
 (0)