// 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"
)

// KlusterletInformer provides access to a shared informer and lister for
// Klusterlets.
type KlusterletInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() operatorv1.KlusterletLister
}

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

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

// NewFilteredKlusterletInformer constructs a new informer for Klusterlet 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 NewFilteredKlusterletInformer(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().Klusterlets().List(context.Background(), options)
			},
			WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().Klusterlets().Watch(context.Background(), options)
			},
			ListWithContextFunc: func(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().Klusterlets().List(ctx, options)
			},
			WatchFuncWithContext: func(ctx context.Context, options metav1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().Klusterlets().Watch(ctx, options)
			},
		},
		&apioperatorv1.Klusterlet{},
		resyncPeriod,
		indexers,
	)
}

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

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

func (f *klusterletInformer) Lister() operatorv1.KlusterletLister {
	return operatorv1.NewKlusterletLister(f.Informer().GetIndexer())
}
