github.com/argoproj/argo-cd@v1.8.7/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 v1alpha1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" 9 schema "k8s.io/apimachinery/pkg/runtime/schema" 10 cache "k8s.io/client-go/tools/cache" 11 ) 12 13 // GenericInformer is type of SharedIndexInformer which will locate and delegate to other 14 // sharedInformers based on type 15 type GenericInformer interface { 16 Informer() cache.SharedIndexInformer 17 Lister() cache.GenericLister 18 } 19 20 type genericInformer struct { 21 informer cache.SharedIndexInformer 22 resource schema.GroupResource 23 } 24 25 // Informer returns the SharedIndexInformer. 26 func (f *genericInformer) Informer() cache.SharedIndexInformer { 27 return f.informer 28 } 29 30 // Lister returns the GenericLister. 31 func (f *genericInformer) Lister() cache.GenericLister { 32 return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 33 } 34 35 // ForResource gives generic access to a shared informer of the matching type 36 // TODO extend this to unknown resources with a client pool 37 func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 38 switch resource { 39 // Group=argoproj.io, Version=v1alpha1 40 case v1alpha1.SchemeGroupVersion.WithResource("appprojects"): 41 return &genericInformer{resource: resource.GroupResource(), informer: f.Argoproj().V1alpha1().AppProjects().Informer()}, nil 42 case v1alpha1.SchemeGroupVersion.WithResource("applications"): 43 return &genericInformer{resource: resource.GroupResource(), informer: f.Argoproj().V1alpha1().Applications().Informer()}, nil 44 45 } 46 47 return nil, fmt.Errorf("no informer found for %v", resource) 48 }