github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/cloud/pkg/client/informers/externalversions/devices/v1alpha1/device.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 // DeviceInformer provides access to a shared informer and lister for 34 // Devices. 35 type DeviceInformer interface { 36 Informer() cache.SharedIndexInformer 37 Lister() v1alpha1.DeviceLister 38 } 39 40 type deviceInformer struct { 41 factory internalinterfaces.SharedInformerFactory 42 tweakListOptions internalinterfaces.TweakListOptionsFunc 43 namespace string 44 } 45 46 // NewDeviceInformer constructs a new informer for Device 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 NewDeviceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 50 return NewFilteredDeviceInformer(client, namespace, resyncPeriod, indexers, nil) 51 } 52 53 // NewFilteredDeviceInformer constructs a new informer for Device 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 NewFilteredDeviceInformer(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().Devices(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().Devices(namespace).Watch(options) 70 }, 71 }, 72 &devicesv1alpha1.Device{}, 73 resyncPeriod, 74 indexers, 75 ) 76 } 77 78 func (f *deviceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 79 return NewFilteredDeviceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 80 } 81 82 func (f *deviceInformer) Informer() cache.SharedIndexInformer { 83 return f.factory.InformerFor(&devicesv1alpha1.Device{}, f.defaultInformer) 84 } 85 86 func (f *deviceInformer) Lister() v1alpha1.DeviceLister { 87 return v1alpha1.NewDeviceLister(f.Informer().GetIndexer()) 88 }