github.com/cilium/cilium@v1.16.2/pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumexternalworkload.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  // CiliumExternalWorkloadInformer provides access to a shared informer and lister for
    23  // CiliumExternalWorkloads.
    24  type CiliumExternalWorkloadInformer interface {
    25  	Informer() cache.SharedIndexInformer
    26  	Lister() v2.CiliumExternalWorkloadLister
    27  }
    28  
    29  type ciliumExternalWorkloadInformer struct {
    30  	factory          internalinterfaces.SharedInformerFactory
    31  	tweakListOptions internalinterfaces.TweakListOptionsFunc
    32  }
    33  
    34  // NewCiliumExternalWorkloadInformer constructs a new informer for CiliumExternalWorkload 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 NewCiliumExternalWorkloadInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
    38  	return NewFilteredCiliumExternalWorkloadInformer(client, resyncPeriod, indexers, nil)
    39  }
    40  
    41  // NewFilteredCiliumExternalWorkloadInformer constructs a new informer for CiliumExternalWorkload 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 NewFilteredCiliumExternalWorkloadInformer(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().CiliumExternalWorkloads().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().CiliumExternalWorkloads().Watch(context.TODO(), options)
    58  			},
    59  		},
    60  		&ciliumiov2.CiliumExternalWorkload{},
    61  		resyncPeriod,
    62  		indexers,
    63  	)
    64  }
    65  
    66  func (f *ciliumExternalWorkloadInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
    67  	return NewFilteredCiliumExternalWorkloadInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
    68  }
    69  
    70  func (f *ciliumExternalWorkloadInformer) Informer() cache.SharedIndexInformer {
    71  	return f.factory.InformerFor(&ciliumiov2.CiliumExternalWorkload{}, f.defaultInformer)
    72  }
    73  
    74  func (f *ciliumExternalWorkloadInformer) Lister() v2.CiliumExternalWorkloadLister {
    75  	return v2.NewCiliumExternalWorkloadLister(f.Informer().GetIndexer())
    76  }