github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/cloud/pkg/client/informers/externalversions/reliablesyncs/v1alpha1/clusterobjectsync.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  	reliablesyncsv1alpha1 "github.com/kubeedge/kubeedge/cloud/pkg/apis/reliablesyncs/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/reliablesyncs/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  // ClusterObjectSyncInformer provides access to a shared informer and lister for
    34  // ClusterObjectSyncs.
    35  type ClusterObjectSyncInformer interface {
    36  	Informer() cache.SharedIndexInformer
    37  	Lister() v1alpha1.ClusterObjectSyncLister
    38  }
    39  
    40  type clusterObjectSyncInformer struct {
    41  	factory          internalinterfaces.SharedInformerFactory
    42  	tweakListOptions internalinterfaces.TweakListOptionsFunc
    43  }
    44  
    45  // NewClusterObjectSyncInformer constructs a new informer for ClusterObjectSync 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 NewClusterObjectSyncInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
    49  	return NewFilteredClusterObjectSyncInformer(client, resyncPeriod, indexers, nil)
    50  }
    51  
    52  // NewFilteredClusterObjectSyncInformer constructs a new informer for ClusterObjectSync 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 NewFilteredClusterObjectSyncInformer(client versioned.Interface, 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.ReliablesyncsV1alpha1().ClusterObjectSyncs().List(options)
    63  			},
    64  			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
    65  				if tweakListOptions != nil {
    66  					tweakListOptions(&options)
    67  				}
    68  				return client.ReliablesyncsV1alpha1().ClusterObjectSyncs().Watch(options)
    69  			},
    70  		},
    71  		&reliablesyncsv1alpha1.ClusterObjectSync{},
    72  		resyncPeriod,
    73  		indexers,
    74  	)
    75  }
    76  
    77  func (f *clusterObjectSyncInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
    78  	return NewFilteredClusterObjectSyncInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
    79  }
    80  
    81  func (f *clusterObjectSyncInformer) Informer() cache.SharedIndexInformer {
    82  	return f.factory.InformerFor(&reliablesyncsv1alpha1.ClusterObjectSync{}, f.defaultInformer)
    83  }
    84  
    85  func (f *clusterObjectSyncInformer) Lister() v1alpha1.ClusterObjectSyncLister {
    86  	return v1alpha1.NewClusterObjectSyncLister(f.Informer().GetIndexer())
    87  }