@@ -70,6 +70,7 @@ type informerCache struct {
70
70
scheme * runtime.Scheme
71
71
* internal.Informers
72
72
readerFailOnMissingInformer bool
73
+ clusterIndexes bool
73
74
}
74
75
75
76
// Get implements Reader.
@@ -219,10 +220,10 @@ func (ic *informerCache) IndexField(ctx context.Context, obj client.Object, fiel
219
220
if err != nil {
220
221
return err
221
222
}
222
- return indexByField (informer , field , extractValue )
223
+ return indexByField (informer , field , extractValue , ic . clusterIndexes )
223
224
}
224
225
225
- func indexByField (informer Informer , field string , extractValue client.IndexerFunc ) error {
226
+ func indexByField (informer Informer , field string , extractValue client.IndexerFunc , clusterIndexes bool ) error {
226
227
indexFunc := func (objRaw interface {}) ([]string , error ) {
227
228
// TODO(directxman12): check if this is the correct type?
228
229
obj , isObj := objRaw .(client.Object )
@@ -236,7 +237,7 @@ func indexByField(informer Informer, field string, extractValue client.IndexerFu
236
237
ns := meta .GetNamespace ()
237
238
238
239
keyFunc := internal .KeyToNamespacedKey
239
- if clusterName := logicalcluster .From (obj ); ! clusterName .Empty () {
240
+ if clusterName := logicalcluster .From (obj ); clusterIndexes && ! clusterName .Empty () {
240
241
keyFunc = func (ns , val string ) string {
241
242
return internal .KeyToClusteredKey (clusterName .String (), ns , val )
242
243
}
0 commit comments