github.com/k8snetworkplumbingwg/sriov-network-operator@v1.2.1-0.20240408194816-2d2e5a45d453/pkg/client/informers/externalversions/generic.go (about) 1 // Code generated by informer-gen. DO NOT EDIT. 2 3 package externalversions 4 5 import ( 6 "fmt" 7 8 schema "k8s.io/apimachinery/pkg/runtime/schema" 9 cache "k8s.io/client-go/tools/cache" 10 11 v1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" 12 ) 13 14 // GenericInformer is type of SharedIndexInformer which will locate and delegate to other 15 // sharedInformers based on type 16 type GenericInformer interface { 17 Informer() cache.SharedIndexInformer 18 Lister() cache.GenericLister 19 } 20 21 type genericInformer struct { 22 informer cache.SharedIndexInformer 23 resource schema.GroupResource 24 } 25 26 // Informer returns the SharedIndexInformer. 27 func (f *genericInformer) Informer() cache.SharedIndexInformer { 28 return f.informer 29 } 30 31 // Lister returns the GenericLister. 32 func (f *genericInformer) Lister() cache.GenericLister { 33 return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 34 } 35 36 // ForResource gives generic access to a shared informer of the matching type 37 // TODO extend this to unknown resources with a client pool 38 func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 39 switch resource { 40 // Group=sriovnetwork, Version=v1 41 case v1.SchemeGroupVersion.WithResource("sriovnetworks"): 42 return &genericInformer{resource: resource.GroupResource(), informer: f.Sriovnetwork().V1().SriovNetworks().Informer()}, nil 43 case v1.SchemeGroupVersion.WithResource("sriovnetworknodepolicies"): 44 return &genericInformer{resource: resource.GroupResource(), informer: f.Sriovnetwork().V1().SriovNetworkNodePolicies().Informer()}, nil 45 case v1.SchemeGroupVersion.WithResource("sriovnetworknodestates"): 46 return &genericInformer{resource: resource.GroupResource(), informer: f.Sriovnetwork().V1().SriovNetworkNodeStates().Informer()}, nil 47 case v1.SchemeGroupVersion.WithResource("sriovoperatorconfigs"): 48 return &genericInformer{resource: resource.GroupResource(), informer: f.Sriovnetwork().V1().SriovOperatorConfigs().Informer()}, nil 49 50 } 51 52 return nil, fmt.Errorf("no informer found for %v", resource) 53 }