github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/client/informers_generated/externalversions/projectcalico/v3/bgpconfiguration.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  // BGPConfigurationInformer provides access to a shared informer and lister for
    22  // BGPConfigurations.
    23  type BGPConfigurationInformer interface {
    24  	Informer() cache.SharedIndexInformer
    25  	Lister() v3.BGPConfigurationLister
    26  }
    27  
    28  type bGPConfigurationInformer struct {
    29  	factory          internalinterfaces.SharedInformerFactory
    30  	tweakListOptions internalinterfaces.TweakListOptionsFunc
    31  }
    32  
    33  // NewBGPConfigurationInformer constructs a new informer for BGPConfiguration type.
    34  // Always prefer using an informer factory to get a shared informer instead of getting an independent
    35  // one. This reduces memory footprint and number of connections to the server.
    36  func NewBGPConfigurationInformer(client clientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
    37  	return NewFilteredBGPConfigurationInformer(client, resyncPeriod, indexers, nil)
    38  }
    39  
    40  // NewFilteredBGPConfigurationInformer constructs a new informer for BGPConfiguration type.
    41  // Always prefer using an informer factory to get a shared informer instead of getting an independent
    42  // one. This reduces memory footprint and number of connections to the server.
    43  func NewFilteredBGPConfigurationInformer(client clientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
    44  	return cache.NewSharedIndexInformer(
    45  		&cache.ListWatch{
    46  			ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
    47  				if tweakListOptions != nil {
    48  					tweakListOptions(&options)
    49  				}
    50  				return client.ProjectcalicoV3().BGPConfigurations().List(context.TODO(), options)
    51  			},
    52  			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
    53  				if tweakListOptions != nil {
    54  					tweakListOptions(&options)
    55  				}
    56  				return client.ProjectcalicoV3().BGPConfigurations().Watch(context.TODO(), options)
    57  			},
    58  		},
    59  		&projectcalicov3.BGPConfiguration{},
    60  		resyncPeriod,
    61  		indexers,
    62  	)
    63  }
    64  
    65  func (f *bGPConfigurationInformer) defaultInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
    66  	return NewFilteredBGPConfigurationInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
    67  }
    68  
    69  func (f *bGPConfigurationInformer) Informer() cache.SharedIndexInformer {
    70  	return f.factory.InformerFor(&projectcalicov3.BGPConfiguration{}, f.defaultInformer)
    71  }
    72  
    73  func (f *bGPConfigurationInformer) Lister() v3.BGPConfigurationLister {
    74  	return v3.NewBGPConfigurationLister(f.Informer().GetIndexer())
    75  }