github.com/nginxinc/kubernetes-ingress@v1.12.5/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 v1 "github.com/nginxinc/kubernetes-ingress/pkg/apis/configuration/v1" 9 v1alpha1 "github.com/nginxinc/kubernetes-ingress/pkg/apis/configuration/v1alpha1" 10 schema "k8s.io/apimachinery/pkg/runtime/schema" 11 cache "k8s.io/client-go/tools/cache" 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=k8s.nginx.org, Version=v1 41 case v1.SchemeGroupVersion.WithResource("policies"): 42 return &genericInformer{resource: resource.GroupResource(), informer: f.K8s().V1().Policies().Informer()}, nil 43 case v1.SchemeGroupVersion.WithResource("virtualservers"): 44 return &genericInformer{resource: resource.GroupResource(), informer: f.K8s().V1().VirtualServers().Informer()}, nil 45 case v1.SchemeGroupVersion.WithResource("virtualserverroutes"): 46 return &genericInformer{resource: resource.GroupResource(), informer: f.K8s().V1().VirtualServerRoutes().Informer()}, nil 47 48 // Group=k8s.nginx.org, Version=v1alpha1 49 case v1alpha1.SchemeGroupVersion.WithResource("globalconfigurations"): 50 return &genericInformer{resource: resource.GroupResource(), informer: f.K8s().V1alpha1().GlobalConfigurations().Informer()}, nil 51 case v1alpha1.SchemeGroupVersion.WithResource("transportservers"): 52 return &genericInformer{resource: resource.GroupResource(), informer: f.K8s().V1alpha1().TransportServers().Informer()}, nil 53 54 } 55 56 return nil, fmt.Errorf("no informer found for %v", resource) 57 }