github.com/argoproj/argo-cd@v1.8.7/pkg/client/informers/externalversions/application/v1alpha1/application.go (about) 1 // Code generated by informer-gen. DO NOT EDIT. 2 3 package v1alpha1 4 5 import ( 6 "context" 7 time "time" 8 9 applicationv1alpha1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" 10 versioned "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" 11 internalinterfaces "github.com/argoproj/argo-cd/pkg/client/informers/externalversions/internalinterfaces" 12 v1alpha1 "github.com/argoproj/argo-cd/pkg/client/listers/application/v1alpha1" 13 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 14 runtime "k8s.io/apimachinery/pkg/runtime" 15 watch "k8s.io/apimachinery/pkg/watch" 16 cache "k8s.io/client-go/tools/cache" 17 ) 18 19 // ApplicationInformer provides access to a shared informer and lister for 20 // Applications. 21 type ApplicationInformer interface { 22 Informer() cache.SharedIndexInformer 23 Lister() v1alpha1.ApplicationLister 24 } 25 26 type applicationInformer struct { 27 factory internalinterfaces.SharedInformerFactory 28 tweakListOptions internalinterfaces.TweakListOptionsFunc 29 namespace string 30 } 31 32 // NewApplicationInformer constructs a new informer for Application type. 33 // Always prefer using an informer factory to get a shared informer instead of getting an independent 34 // one. This reduces memory footprint and number of connections to the server. 35 func NewApplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 36 return NewFilteredApplicationInformer(client, namespace, resyncPeriod, indexers, nil) 37 } 38 39 // NewFilteredApplicationInformer constructs a new informer for Application type. 40 // Always prefer using an informer factory to get a shared informer instead of getting an independent 41 // one. This reduces memory footprint and number of connections to the server. 42 func NewFilteredApplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 43 return cache.NewSharedIndexInformer( 44 &cache.ListWatch{ 45 ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 46 if tweakListOptions != nil { 47 tweakListOptions(&options) 48 } 49 return client.ArgoprojV1alpha1().Applications(namespace).List(context.TODO(), options) 50 }, 51 WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 52 if tweakListOptions != nil { 53 tweakListOptions(&options) 54 } 55 return client.ArgoprojV1alpha1().Applications(namespace).Watch(context.TODO(), options) 56 }, 57 }, 58 &applicationv1alpha1.Application{}, 59 resyncPeriod, 60 indexers, 61 ) 62 } 63 64 func (f *applicationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 65 return NewFilteredApplicationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 66 } 67 68 func (f *applicationInformer) Informer() cache.SharedIndexInformer { 69 return f.factory.InformerFor(&applicationv1alpha1.Application{}, f.defaultInformer) 70 } 71 72 func (f *applicationInformer) Lister() v1alpha1.ApplicationLister { 73 return v1alpha1.NewApplicationLister(f.Informer().GetIndexer()) 74 }