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