// Copyright Contributors to the Open Cluster Management project
// Code generated by informer-gen. DO NOT EDIT.

package v1

import (
	context "context"
	time "time"

	metav1 "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"
	versioned "open-cluster-management.io/api/client/operator/clientset/versioned"
	internalinterfaces "open-cluster-management.io/api/client/operator/informers/externalversions/internalinterfaces"
	operatorv1 "open-cluster-management.io/api/client/operator/listers/operator/v1"
	apioperatorv1 "open-cluster-management.io/api/operator/v1"
)

// ClusterManagerInformer provides access to a shared informer and lister for
// ClusterManagers.
type ClusterManagerInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() operatorv1.ClusterManagerLister
}

type clusterManagerInformer struct {
	factory          internalinterfaces.SharedInformerFactory
	tweakListOptions internalinterfaces.TweakListOptionsFunc
}

// NewClusterManagerInformer constructs a new informer for ClusterManager type.
// 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.
func NewClusterManagerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewFilteredClusterManagerInformer(client, resyncPeriod, indexers, nil)
}

// NewFilteredClusterManagerInformer constructs a new informer for ClusterManager type.
// 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.
func NewFilteredClusterManagerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
	return cache.NewSharedIndexInformer(
		&cache.ListWatch{
			ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().ClusterManagers().List(context.Background(), options)
			},
			WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().ClusterManagers().Watch(context.Background(), options)
			},
			ListWithContextFunc: func(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().ClusterManagers().List(ctx, options)
			},
			WatchFuncWithContext: func(ctx context.Context, options metav1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().ClusterManagers().Watch(ctx, options)
			},
		},
		&apioperatorv1.ClusterManager{},
		resyncPeriod,
		indexers,
	)
}

func (f *clusterManagerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
	return NewFilteredClusterManagerInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}

func (f *clusterManagerInformer) Informer() cache.SharedIndexInformer {
	return f.factory.InformerFor(&apioperatorv1.ClusterManager{}, f.defaultInformer)
}

func (f *clusterManagerInformer) Lister() operatorv1.ClusterManagerLister {
	return operatorv1.NewClusterManagerLister(f.Informer().GetIndexer())
}
