github.com/imran-kn/cilium-fork@v1.6.9/pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumnode.go (about)

     1  // Copyright 2017-2019 Authors of Cilium
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Code generated by informer-gen. DO NOT EDIT.
    16  
    17  package v2
    18  
    19  import (
    20  	time "time"
    21  
    22  	ciliumiov2 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2"
    23  	versioned "github.com/cilium/cilium/pkg/k8s/client/clientset/versioned"
    24  	internalinterfaces "github.com/cilium/cilium/pkg/k8s/client/informers/externalversions/internalinterfaces"
    25  	v2 "github.com/cilium/cilium/pkg/k8s/client/listers/cilium.io/v2"
    26  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    27  	runtime "k8s.io/apimachinery/pkg/runtime"
    28  	watch "k8s.io/apimachinery/pkg/watch"
    29  	cache "k8s.io/client-go/tools/cache"
    30  )
    31  
    32  // CiliumNodeInformer provides access to a shared informer and lister for
    33  // CiliumNodes.
    34  type CiliumNodeInformer interface {
    35  	Informer() cache.SharedIndexInformer
    36  	Lister() v2.CiliumNodeLister
    37  }
    38  
    39  type ciliumNodeInformer struct {
    40  	factory          internalinterfaces.SharedInformerFactory
    41  	tweakListOptions internalinterfaces.TweakListOptionsFunc
    42  }
    43  
    44  // NewCiliumNodeInformer constructs a new informer for CiliumNode type.
    45  // Always prefer using an informer factory to get a shared informer instead of getting an independent
    46  // one. This reduces memory footprint and number of connections to the server.
    47  func NewCiliumNodeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
    48  	return NewFilteredCiliumNodeInformer(client, resyncPeriod, indexers, nil)
    49  }
    50  
    51  // NewFilteredCiliumNodeInformer constructs a new informer for CiliumNode type.
    52  // Always prefer using an informer factory to get a shared informer instead of getting an independent
    53  // one. This reduces memory footprint and number of connections to the server.
    54  func NewFilteredCiliumNodeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
    55  	return cache.NewSharedIndexInformer(
    56  		&cache.ListWatch{
    57  			ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
    58  				if tweakListOptions != nil {
    59  					tweakListOptions(&options)
    60  				}
    61  				return client.CiliumV2().CiliumNodes().List(options)
    62  			},
    63  			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
    64  				if tweakListOptions != nil {
    65  					tweakListOptions(&options)
    66  				}
    67  				return client.CiliumV2().CiliumNodes().Watch(options)
    68  			},
    69  		},
    70  		&ciliumiov2.CiliumNode{},
    71  		resyncPeriod,
    72  		indexers,
    73  	)
    74  }
    75  
    76  func (f *ciliumNodeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
    77  	return NewFilteredCiliumNodeInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
    78  }
    79  
    80  func (f *ciliumNodeInformer) Informer() cache.SharedIndexInformer {
    81  	return f.factory.InformerFor(&ciliumiov2.CiliumNode{}, f.defaultInformer)
    82  }
    83  
    84  func (f *ciliumNodeInformer) Lister() v2.CiliumNodeLister {
    85  	return v2.NewCiliumNodeLister(f.Informer().GetIndexer())
    86  }