@@ -66,7 +66,7 @@ func newSpecificInformersMap(config *rest.Config,
66
66
startWait : make (chan struct {}),
67
67
createListWatcher : createListWatcher ,
68
68
namespace : namespace ,
69
- selectors : selectors ,
69
+ selectors : selectors . forGVK ,
70
70
disableDeepCopy : disableDeepCopy ,
71
71
}
72
72
return ip
@@ -131,7 +131,7 @@ type specificInformersMap struct {
131
131
132
132
// selectors are the label or field selectors that will be added to the
133
133
// ListWatch ListOptions.
134
- selectors SelectorsByGVK
134
+ selectors func ( gvk schema. GroupVersionKind ) Selector
135
135
136
136
// disableDeepCopy indicates not to deep copy objects during get or list objects.
137
137
disableDeepCopy DisableDeepCopyByGVK
@@ -277,19 +277,19 @@ func createStructuredListWatch(gvk schema.GroupVersionKind, ip *specificInformer
277
277
// Create a new ListWatch for the obj
278
278
return & cache.ListWatch {
279
279
ListFunc : func (opts metav1.ListOptions ) (runtime.Object , error ) {
280
- ip .selectors . forGVK (gvk ).ApplyToList (& opts )
280
+ ip .selectors (gvk ).ApplyToList (& opts )
281
281
res := listObj .DeepCopyObject ()
282
- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors . forGVK (gvk ))
282
+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors (gvk ))
283
283
isNamespaceScoped := namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot
284
284
err := client .Get ().NamespaceIfScoped (namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Do (ctx ).Into (res )
285
285
return res , err
286
286
},
287
287
// Setup the watch function
288
288
WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
289
- ip .selectors . forGVK (gvk ).ApplyToList (& opts )
289
+ ip .selectors (gvk ).ApplyToList (& opts )
290
290
// Watch needs to be set to true separately
291
291
opts .Watch = true
292
- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors . forGVK (gvk ))
292
+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors (gvk ))
293
293
isNamespaceScoped := namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot
294
294
return client .Get ().NamespaceIfScoped (namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Watch (ctx )
295
295
},
@@ -319,19 +319,19 @@ func createUnstructuredListWatch(gvk schema.GroupVersionKind, ip *specificInform
319
319
// Create a new ListWatch for the obj
320
320
return & cache.ListWatch {
321
321
ListFunc : func (opts metav1.ListOptions ) (runtime.Object , error ) {
322
- ip .selectors [ gvk ] .ApplyToList (& opts )
323
- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors [ gvk ] )
322
+ ip .selectors ( gvk ) .ApplyToList (& opts )
323
+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors ( gvk ) )
324
324
if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
325
325
return dynamicClient .Resource (mapping .Resource ).Namespace (namespace ).List (ctx , opts )
326
326
}
327
327
return dynamicClient .Resource (mapping .Resource ).List (ctx , opts )
328
328
},
329
329
// Setup the watch function
330
330
WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
331
- ip .selectors [ gvk ] .ApplyToList (& opts )
331
+ ip .selectors ( gvk ) .ApplyToList (& opts )
332
332
// Watch needs to be set to true separately
333
333
opts .Watch = true
334
- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors [ gvk ] )
334
+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors ( gvk ) )
335
335
if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
336
336
return dynamicClient .Resource (mapping .Resource ).Namespace (namespace ).Watch (ctx , opts )
337
337
}
@@ -366,13 +366,13 @@ func createMetadataListWatch(gvk schema.GroupVersionKind, ip *specificInformersM
366
366
// create the relevant listwatch
367
367
return & cache.ListWatch {
368
368
ListFunc : func (opts metav1.ListOptions ) (runtime.Object , error ) {
369
- ip .selectors [ gvk ] .ApplyToList (& opts )
369
+ ip .selectors ( gvk ) .ApplyToList (& opts )
370
370
371
371
var (
372
372
list * metav1.PartialObjectMetadataList
373
373
err error
374
374
)
375
- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors [ gvk ] )
375
+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors ( gvk ) )
376
376
if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
377
377
list , err = client .Resource (mapping .Resource ).Namespace (namespace ).List (ctx , opts )
378
378
} else {
@@ -387,15 +387,15 @@ func createMetadataListWatch(gvk schema.GroupVersionKind, ip *specificInformersM
387
387
},
388
388
// Setup the watch function
389
389
WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
390
- ip .selectors [ gvk ] .ApplyToList (& opts )
390
+ ip .selectors ( gvk ) .ApplyToList (& opts )
391
391
// Watch needs to be set to true separately
392
392
opts .Watch = true
393
393
394
394
var (
395
395
watcher watch.Interface
396
396
err error
397
397
)
398
- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors [ gvk ] )
398
+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors ( gvk ) )
399
399
if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
400
400
watcher , err = client .Resource (mapping .Resource ).Namespace (namespace ).Watch (ctx , opts )
401
401
} else {
0 commit comments