Skip to content

Commit

Permalink
Allow ClusterCacheTracker to set CacheByObject
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <vince@prigna.com>
  • Loading branch information
vincepri committed Jul 26, 2024
1 parent d36541f commit bb69699
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/remote/cluster_cache_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ var ErrClusterLocked = errors.New("cluster is locked already")
type ClusterCacheTracker struct {
log logr.Logger

cacheByObject map[client.Object]cache.ByObject

clientUncachedObjects []client.Object
clientQPS float32
clientBurst int
Expand Down Expand Up @@ -115,6 +117,9 @@ type ClusterCacheTrackerOptions struct {
// Defaults to a no-op logger if it's not set.
Log *logr.Logger

// CacheByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
CacheByObject map[client.Object]cache.ByObject

// ClientUncachedObjects instructs the Client to never cache the following objects,
// it'll instead query the API server directly.
// Defaults to never caching ConfigMap and Secret if not set.
Expand Down Expand Up @@ -191,6 +196,7 @@ func NewClusterCacheTracker(manager ctrl.Manager, options ClusterCacheTrackerOpt
controllerPodMetadata: controllerPodMetadata,
log: *options.Log,
clientUncachedObjects: options.ClientUncachedObjects,
cacheByObject: options.CacheByObject,
clientQPS: options.ClientQPS,
clientBurst: options.ClientBurst,
client: manager.GetClient(),
Expand Down Expand Up @@ -485,6 +491,7 @@ func (t *ClusterCacheTracker) createCachedClient(ctx context.Context, config *re
HTTPClient: httpClient,
Scheme: t.scheme,
Mapper: mapper,
ByObject: t.cacheByObject,
}
remoteCache, err := cache.New(config, cacheOptions)
if err != nil {
Expand Down

0 comments on commit bb69699

Please sign in to comment.