@@ -181,7 +181,7 @@ func NewClusterCacheTracker(manager ctrl.Manager, options ClusterCacheTrackerOpt
181
181
182
182
// GetClient returns a cached client for the given cluster.
183
183
func (t * ClusterCacheTracker ) GetClient (ctx context.Context , cluster client.ObjectKey ) (client.Client , error ) {
184
- accessor , err := t .getClusterAccessor (ctx , cluster , t . indexes ... )
184
+ accessor , err := t .getClusterAccessor (ctx , cluster )
185
185
if err != nil {
186
186
return nil , err
187
187
}
@@ -196,7 +196,7 @@ func (t *ClusterCacheTracker) GetReader(ctx context.Context, cluster client.Obje
196
196
197
197
// GetRESTConfig returns a cached REST config for the given cluster.
198
198
func (t * ClusterCacheTracker ) GetRESTConfig (ctc context.Context , cluster client.ObjectKey ) (* rest.Config , error ) {
199
- accessor , err := t .getClusterAccessor (ctc , cluster , t . indexes ... )
199
+ accessor , err := t .getClusterAccessor (ctc , cluster )
200
200
if err != nil {
201
201
return nil , err
202
202
}
@@ -206,7 +206,7 @@ func (t *ClusterCacheTracker) GetRESTConfig(ctc context.Context, cluster client.
206
206
207
207
// GetEtcdClientCertificateKey returns a cached certificate key to be used for generating certificates for accessing etcd in the given cluster.
208
208
func (t * ClusterCacheTracker ) GetEtcdClientCertificateKey (ctx context.Context , cluster client.ObjectKey ) (* rsa.PrivateKey , error ) {
209
- accessor , err := t .getClusterAccessor (ctx , cluster , t . indexes ... )
209
+ accessor , err := t .getClusterAccessor (ctx , cluster )
210
210
if err != nil {
211
211
return nil , err
212
212
}
@@ -254,7 +254,7 @@ func (t *ClusterCacheTracker) storeAccessor(cluster client.ObjectKey, accessor *
254
254
// It then falls back to create a new clusterAccessor if needed.
255
255
// If there is already another go routine trying to create a clusterAccessor
256
256
// for the same cluster, an error is returned.
257
- func (t * ClusterCacheTracker ) getClusterAccessor (ctx context.Context , cluster client.ObjectKey , indexes ... Index ) (* clusterAccessor , error ) {
257
+ func (t * ClusterCacheTracker ) getClusterAccessor (ctx context.Context , cluster client.ObjectKey ) (* clusterAccessor , error ) {
258
258
log := ctrl .LoggerFrom (ctx , "cluster" , klog .KRef (cluster .Namespace , cluster .Name ))
259
259
260
260
// If the clusterAccessor already exists, return early.
@@ -279,7 +279,7 @@ func (t *ClusterCacheTracker) getClusterAccessor(ctx context.Context, cluster cl
279
279
280
280
// We are the go routine who has to initialize the clusterAccessor.
281
281
log .V (4 ).Info ("Creating new cluster accessor" )
282
- accessor , err := t .newClusterAccessor (ctx , cluster , indexes ... )
282
+ accessor , err := t .newClusterAccessor (ctx , cluster )
283
283
if err != nil {
284
284
return nil , errors .Wrap (err , "failed to create cluster accessor" )
285
285
}
@@ -290,7 +290,7 @@ func (t *ClusterCacheTracker) getClusterAccessor(ctx context.Context, cluster cl
290
290
}
291
291
292
292
// newClusterAccessor creates a new clusterAccessor.
293
- func (t * ClusterCacheTracker ) newClusterAccessor (ctx context.Context , cluster client.ObjectKey , indexes ... Index ) (* clusterAccessor , error ) {
293
+ func (t * ClusterCacheTracker ) newClusterAccessor (ctx context.Context , cluster client.ObjectKey ) (* clusterAccessor , error ) {
294
294
log := ctrl .LoggerFrom (ctx )
295
295
296
296
// Get a rest config for the remote cluster.
@@ -348,7 +348,7 @@ func (t *ClusterCacheTracker) newClusterAccessor(ctx context.Context, cluster cl
348
348
}
349
349
350
350
// Create a client and a cache for the cluster.
351
- cachedClient , err := t .createCachedClient (ctx , config , cluster , httpClient , mapper , indexes )
351
+ cachedClient , err := t .createCachedClient (ctx , config , cluster , httpClient , mapper )
352
352
if err != nil {
353
353
return nil , err
354
354
}
@@ -442,7 +442,7 @@ type cachedClientOutput struct {
442
442
}
443
443
444
444
// createCachedClient creates a cached client for the given cluster, based on a rest.Config.
445
- func (t * ClusterCacheTracker ) createCachedClient (ctx context.Context , config * rest.Config , cluster client.ObjectKey , httpClient * http.Client , mapper meta.RESTMapper , indexes [] Index ) (* cachedClientOutput , error ) {
445
+ func (t * ClusterCacheTracker ) createCachedClient (ctx context.Context , config * rest.Config , cluster client.ObjectKey , httpClient * http.Client , mapper meta.RESTMapper ) (* cachedClientOutput , error ) {
446
446
// Create the cache for the remote cluster
447
447
cacheOptions := cache.Options {
448
448
HTTPClient : httpClient ,
@@ -462,7 +462,7 @@ func (t *ClusterCacheTracker) createCachedClient(ctx context.Context, config *re
462
462
cancelFunc : cacheCtxCancel ,
463
463
}
464
464
465
- for _ , index := range indexes {
465
+ for _ , index := range t . indexes {
466
466
if err := cache .IndexField (ctx , index .Object , index .Field , index .ExtractValue ); err != nil {
467
467
return nil , errors .Wrapf (err , "error creating cached client for remote cluster %q: error adding index for field %q to cache" , cluster .String (), index .Field )
468
468
}
@@ -566,7 +566,7 @@ func (t *ClusterCacheTracker) Watch(ctx context.Context, input WatchInput) error
566
566
return errors .New ("input.Name is required" )
567
567
}
568
568
569
- accessor , err := t .getClusterAccessor (ctx , input .Cluster , t . indexes ... )
569
+ accessor , err := t .getClusterAccessor (ctx , input .Cluster )
570
570
if err != nil {
571
571
return errors .Wrapf (err , "failed to add %s watch on cluster %s" , input .Kind , klog .KRef (input .Cluster .Namespace , input .Cluster .Name ))
572
572
}
0 commit comments