github.phpd.cn/cilium/cilium@v1.6.12/pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumidentity.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 // CiliumIdentityInformer provides access to a shared informer and lister for 33 // CiliumIdentities. 34 type CiliumIdentityInformer interface { 35 Informer() cache.SharedIndexInformer 36 Lister() v2.CiliumIdentityLister 37 } 38 39 type ciliumIdentityInformer struct { 40 factory internalinterfaces.SharedInformerFactory 41 tweakListOptions internalinterfaces.TweakListOptionsFunc 42 } 43 44 // NewCiliumIdentityInformer constructs a new informer for CiliumIdentity 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 NewCiliumIdentityInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 48 return NewFilteredCiliumIdentityInformer(client, resyncPeriod, indexers, nil) 49 } 50 51 // NewFilteredCiliumIdentityInformer constructs a new informer for CiliumIdentity 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 NewFilteredCiliumIdentityInformer(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().CiliumIdentities().List(options) 62 }, 63 WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 64 if tweakListOptions != nil { 65 tweakListOptions(&options) 66 } 67 return client.CiliumV2().CiliumIdentities().Watch(options) 68 }, 69 }, 70 &ciliumiov2.CiliumIdentity{}, 71 resyncPeriod, 72 indexers, 73 ) 74 } 75 76 func (f *ciliumIdentityInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 77 return NewFilteredCiliumIdentityInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 78 } 79 80 func (f *ciliumIdentityInformer) Informer() cache.SharedIndexInformer { 81 return f.factory.InformerFor(&ciliumiov2.CiliumIdentity{}, f.defaultInformer) 82 } 83 84 func (f *ciliumIdentityInformer) Lister() v2.CiliumIdentityLister { 85 return v2.NewCiliumIdentityLister(f.Informer().GetIndexer()) 86 }