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

package v1

import (
	"context"
	time "time"

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

// KlusterletInformer provides access to a shared informer and lister for
// Klusterlets.
type KlusterletInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() v1.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.TODO(), options)
			},
			WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.OperatorV1().Klusterlets().Watch(context.TODO(), options)
			},
		},
		&operatorv1.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(&operatorv1.Klusterlet{}, f.defaultInformer)
}

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