github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/client/informers_generated/externalversions/projectcalico/v3/packetcapture.go (about)

     1  // Copyright (c) 2024 Tigera, Inc. All rights reserved.
     2  
     3  // Code generated by informer-gen. DO NOT EDIT.
     4  
     5  package v3
     6  
     7  import (
     8  	"context"
     9  	time "time"
    10  
    11  	projectcalicov3 "github.com/tigera/api/pkg/apis/projectcalico/v3"
    12  	clientset "github.com/tigera/api/pkg/client/clientset_generated/clientset"
    13  	internalinterfaces "github.com/tigera/api/pkg/client/informers_generated/externalversions/internalinterfaces"
    14  	v3 "github.com/tigera/api/pkg/client/listers_generated/projectcalico/v3"
    15  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    16  	runtime "k8s.io/apimachinery/pkg/runtime"
    17  	watch "k8s.io/apimachinery/pkg/watch"
    18  	cache "k8s.io/client-go/tools/cache"
    19  )
    20  
    21  // PacketCaptureInformer provides access to a shared informer and lister for
    22  // PacketCaptures.
    23  type PacketCaptureInformer interface {
    24  	Informer() cache.SharedIndexInformer
    25  	Lister() v3.PacketCaptureLister
    26  }
    27  
    28  type packetCaptureInformer struct {
    29  	factory          internalinterfaces.SharedInformerFactory
    30  	tweakListOptions internalinterfaces.TweakListOptionsFunc
    31  	namespace        string
    32  }
    33  
    34  // NewPacketCaptureInformer constructs a new informer for PacketCapture 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 NewPacketCaptureInformer(client clientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
    38  	return NewFilteredPacketCaptureInformer(client, namespace, resyncPeriod, indexers, nil)
    39  }
    40  
    41  // NewFilteredPacketCaptureInformer constructs a new informer for PacketCapture 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 NewFilteredPacketCaptureInformer(client clientset.Interface, namespace string, 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.ProjectcalicoV3().PacketCaptures(namespace).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.ProjectcalicoV3().PacketCaptures(namespace).Watch(context.TODO(), options)
    58  			},
    59  		},
    60  		&projectcalicov3.PacketCapture{},
    61  		resyncPeriod,
    62  		indexers,
    63  	)
    64  }
    65  
    66  func (f *packetCaptureInformer) defaultInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
    67  	return NewFilteredPacketCaptureInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
    68  }
    69  
    70  func (f *packetCaptureInformer) Informer() cache.SharedIndexInformer {
    71  	return f.factory.InformerFor(&projectcalicov3.PacketCapture{}, f.defaultInformer)
    72  }
    73  
    74  func (f *packetCaptureInformer) Lister() v3.PacketCaptureLister {
    75  	return v3.NewPacketCaptureLister(f.Informer().GetIndexer())
    76  }