@@ -66,7 +66,7 @@ func newSpecificInformersMap(config *rest.Config,
6666 startWait : make (chan struct {}),
6767 createListWatcher : createListWatcher ,
6868 namespace : namespace ,
69- selectors : selectors ,
69+ selectors : selectors . forGVK ,
7070 disableDeepCopy : disableDeepCopy ,
7171 }
7272 return ip
@@ -131,7 +131,7 @@ type specificInformersMap struct {
131131
132132 // selectors are the label or field selectors that will be added to the
133133 // ListWatch ListOptions.
134- selectors SelectorsByGVK
134+ selectors func ( gvk schema. GroupVersionKind ) Selector
135135
136136 // disableDeepCopy indicates not to deep copy objects during get or list objects.
137137 disableDeepCopy DisableDeepCopyByGVK
@@ -277,19 +277,19 @@ func createStructuredListWatch(gvk schema.GroupVersionKind, ip *specificInformer
277277 // Create a new ListWatch for the obj
278278 return & cache.ListWatch {
279279 ListFunc : func (opts metav1.ListOptions ) (runtime.Object , error ) {
280- ip .selectors . forGVK (gvk ).ApplyToList (& opts )
280+ ip .selectors (gvk ).ApplyToList (& opts )
281281 res := listObj .DeepCopyObject ()
282- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors . forGVK (gvk ))
282+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors (gvk ))
283283 isNamespaceScoped := namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot
284284 err := client .Get ().NamespaceIfScoped (namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Do (ctx ).Into (res )
285285 return res , err
286286 },
287287 // Setup the watch function
288288 WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
289- ip .selectors . forGVK (gvk ).ApplyToList (& opts )
289+ ip .selectors (gvk ).ApplyToList (& opts )
290290 // Watch needs to be set to true separately
291291 opts .Watch = true
292- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors . forGVK (gvk ))
292+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors (gvk ))
293293 isNamespaceScoped := namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot
294294 return client .Get ().NamespaceIfScoped (namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Watch (ctx )
295295 },
@@ -319,19 +319,19 @@ func createUnstructuredListWatch(gvk schema.GroupVersionKind, ip *specificInform
319319 // Create a new ListWatch for the obj
320320 return & cache.ListWatch {
321321 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 ) )
324324 if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
325325 return dynamicClient .Resource (mapping .Resource ).Namespace (namespace ).List (ctx , opts )
326326 }
327327 return dynamicClient .Resource (mapping .Resource ).List (ctx , opts )
328328 },
329329 // Setup the watch function
330330 WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
331- ip .selectors [ gvk ] .ApplyToList (& opts )
331+ ip .selectors ( gvk ) .ApplyToList (& opts )
332332 // Watch needs to be set to true separately
333333 opts .Watch = true
334- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors [ gvk ] )
334+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors ( gvk ) )
335335 if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
336336 return dynamicClient .Resource (mapping .Resource ).Namespace (namespace ).Watch (ctx , opts )
337337 }
@@ -366,13 +366,13 @@ func createMetadataListWatch(gvk schema.GroupVersionKind, ip *specificInformersM
366366 // create the relevant listwatch
367367 return & cache.ListWatch {
368368 ListFunc : func (opts metav1.ListOptions ) (runtime.Object , error ) {
369- ip .selectors [ gvk ] .ApplyToList (& opts )
369+ ip .selectors ( gvk ) .ApplyToList (& opts )
370370
371371 var (
372372 list * metav1.PartialObjectMetadataList
373373 err error
374374 )
375- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors [ gvk ] )
375+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors ( gvk ) )
376376 if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
377377 list , err = client .Resource (mapping .Resource ).Namespace (namespace ).List (ctx , opts )
378378 } else {
@@ -387,15 +387,15 @@ func createMetadataListWatch(gvk schema.GroupVersionKind, ip *specificInformersM
387387 },
388388 // Setup the watch function
389389 WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
390- ip .selectors [ gvk ] .ApplyToList (& opts )
390+ ip .selectors ( gvk ) .ApplyToList (& opts )
391391 // Watch needs to be set to true separately
392392 opts .Watch = true
393393
394394 var (
395395 watcher watch.Interface
396396 err error
397397 )
398- namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors [ gvk ] )
398+ namespace := restrictNamespaceBySelector (ip .namespace , ip .selectors ( gvk ) )
399399 if namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
400400 watcher , err = client .Resource (mapping .Resource ).Namespace (namespace ).Watch (ctx , opts )
401401 } else {
0 commit comments