cluster.go 3.4 KB
Newer Older
Z
zryfish 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
Copyright 2019 The KubeSphere authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Code generated by informer-gen. DO NOT EDIT.

package v1alpha1

import (
	time "time"

	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	runtime "k8s.io/apimachinery/pkg/runtime"
	watch "k8s.io/apimachinery/pkg/watch"
	cache "k8s.io/client-go/tools/cache"
Z
zryfish 已提交
28
	clusterv1alpha1 "kubesphere.io/kubesphere/pkg/apis/cluster/v1alpha1"
Z
zryfish 已提交
29 30
	versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
	internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
Z
zryfish 已提交
31
	v1alpha1 "kubesphere.io/kubesphere/pkg/client/listers/cluster/v1alpha1"
Z
zryfish 已提交
32 33
)

Z
zryfish 已提交
34 35 36
// ClusterInformer provides access to a shared informer and lister for
// Clusters.
type ClusterInformer interface {
Z
zryfish 已提交
37
	Informer() cache.SharedIndexInformer
Z
zryfish 已提交
38
	Lister() v1alpha1.ClusterLister
Z
zryfish 已提交
39 40
}

Z
zryfish 已提交
41
type clusterInformer struct {
Z
zryfish 已提交
42 43 44 45
	factory          internalinterfaces.SharedInformerFactory
	tweakListOptions internalinterfaces.TweakListOptionsFunc
}

Z
zryfish 已提交
46
// NewClusterInformer constructs a new informer for Cluster type.
Z
zryfish 已提交
47 48
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
Z
zryfish 已提交
49 50
func NewClusterInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewFilteredClusterInformer(client, resyncPeriod, indexers, nil)
Z
zryfish 已提交
51 52
}

Z
zryfish 已提交
53
// NewFilteredClusterInformer constructs a new informer for Cluster type.
Z
zryfish 已提交
54 55
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
Z
zryfish 已提交
56
func NewFilteredClusterInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
Z
zryfish 已提交
57 58 59 60 61 62
	return cache.NewSharedIndexInformer(
		&cache.ListWatch{
			ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
Z
zryfish 已提交
63
				return client.ClusterV1alpha1().Clusters().List(options)
Z
zryfish 已提交
64 65 66 67 68
			},
			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
Z
zryfish 已提交
69
				return client.ClusterV1alpha1().Clusters().Watch(options)
Z
zryfish 已提交
70 71
			},
		},
Z
zryfish 已提交
72
		&clusterv1alpha1.Cluster{},
Z
zryfish 已提交
73 74 75 76 77
		resyncPeriod,
		indexers,
	)
}

Z
zryfish 已提交
78 79
func (f *clusterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
	return NewFilteredClusterInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
Z
zryfish 已提交
80 81
}

Z
zryfish 已提交
82 83
func (f *clusterInformer) Informer() cache.SharedIndexInformer {
	return f.factory.InformerFor(&clusterv1alpha1.Cluster{}, f.defaultInformer)
Z
zryfish 已提交
84 85
}

Z
zryfish 已提交
86 87
func (f *clusterInformer) Lister() v1alpha1.ClusterLister {
	return v1alpha1.NewClusterLister(f.Informer().GetIndexer())
Z
zryfish 已提交
88
}