github.com/cilium/cilium@v1.16.2/pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumnode.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 // CiliumNodeInformer provides access to a shared informer and lister for 23 // CiliumNodes. 24 type CiliumNodeInformer interface { 25 Informer() cache.SharedIndexInformer 26 Lister() v2.CiliumNodeLister 27 } 28 29 type ciliumNodeInformer struct { 30 factory internalinterfaces.SharedInformerFactory 31 tweakListOptions internalinterfaces.TweakListOptionsFunc 32 } 33 34 // NewCiliumNodeInformer constructs a new informer for CiliumNode type. 35 // Always prefer using an informer factory to get a shared informer instead of getting an independent 36 // one. This reduces memory footprint and number of connections to the server. 37 func NewCiliumNodeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 38 return NewFilteredCiliumNodeInformer(client, resyncPeriod, indexers, nil) 39 } 40 41 // NewFilteredCiliumNodeInformer constructs a new informer for CiliumNode type. 42 // Always prefer using an informer factory to get a shared informer instead of getting an independent 43 // one. This reduces memory footprint and number of connections to the server. 44 func NewFilteredCiliumNodeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 45 return cache.NewSharedIndexInformer( 46 &cache.ListWatch{ 47 ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 48 if tweakListOptions != nil { 49 tweakListOptions(&options) 50 } 51 return client.CiliumV2().CiliumNodes().List(context.TODO(), options) 52 }, 53 WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 54 if tweakListOptions != nil { 55 tweakListOptions(&options) 56 } 57 return client.CiliumV2().CiliumNodes().Watch(context.TODO(), options) 58 }, 59 }, 60 &ciliumiov2.CiliumNode{}, 61 resyncPeriod, 62 indexers, 63 ) 64 } 65 66 func (f *ciliumNodeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 67 return NewFilteredCiliumNodeInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 68 } 69 70 func (f *ciliumNodeInformer) Informer() cache.SharedIndexInformer { 71 return f.factory.InformerFor(&ciliumiov2.CiliumNode{}, f.defaultInformer) 72 } 73 74 func (f *ciliumNodeInformer) Lister() v2.CiliumNodeLister { 75 return v2.NewCiliumNodeLister(f.Informer().GetIndexer()) 76 }