github.com/imran-kn/cilium-fork@v1.6.9/pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumnetworkpolicy.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 // CiliumNetworkPolicyInformer provides access to a shared informer and lister for 33 // CiliumNetworkPolicies. 34 type CiliumNetworkPolicyInformer interface { 35 Informer() cache.SharedIndexInformer 36 Lister() v2.CiliumNetworkPolicyLister 37 } 38 39 type ciliumNetworkPolicyInformer struct { 40 factory internalinterfaces.SharedInformerFactory 41 tweakListOptions internalinterfaces.TweakListOptionsFunc 42 namespace string 43 } 44 45 // NewCiliumNetworkPolicyInformer constructs a new informer for CiliumNetworkPolicy type. 46 // Always prefer using an informer factory to get a shared informer instead of getting an independent 47 // one. This reduces memory footprint and number of connections to the server. 48 func NewCiliumNetworkPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 49 return NewFilteredCiliumNetworkPolicyInformer(client, namespace, resyncPeriod, indexers, nil) 50 } 51 52 // NewFilteredCiliumNetworkPolicyInformer constructs a new informer for CiliumNetworkPolicy type. 53 // Always prefer using an informer factory to get a shared informer instead of getting an independent 54 // one. This reduces memory footprint and number of connections to the server. 55 func NewFilteredCiliumNetworkPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 56 return cache.NewSharedIndexInformer( 57 &cache.ListWatch{ 58 ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 59 if tweakListOptions != nil { 60 tweakListOptions(&options) 61 } 62 return client.CiliumV2().CiliumNetworkPolicies(namespace).List(options) 63 }, 64 WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 65 if tweakListOptions != nil { 66 tweakListOptions(&options) 67 } 68 return client.CiliumV2().CiliumNetworkPolicies(namespace).Watch(options) 69 }, 70 }, 71 &ciliumiov2.CiliumNetworkPolicy{}, 72 resyncPeriod, 73 indexers, 74 ) 75 } 76 77 func (f *ciliumNetworkPolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 78 return NewFilteredCiliumNetworkPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 79 } 80 81 func (f *ciliumNetworkPolicyInformer) Informer() cache.SharedIndexInformer { 82 return f.factory.InformerFor(&ciliumiov2.CiliumNetworkPolicy{}, f.defaultInformer) 83 } 84 85 func (f *ciliumNetworkPolicyInformer) Lister() v2.CiliumNetworkPolicyLister { 86 return v2.NewCiliumNetworkPolicyLister(f.Informer().GetIndexer()) 87 }