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