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

package v1alpha1

import (
	context "context"
	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"
	apiaddonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
	versioned "open-cluster-management.io/api/client/addon/clientset/versioned"
	internalinterfaces "open-cluster-management.io/api/client/addon/informers/externalversions/internalinterfaces"
	addonv1alpha1 "open-cluster-management.io/api/client/addon/listers/addon/v1alpha1"
)

// AddOnTemplateInformer provides access to a shared informer and lister for
// AddOnTemplates.
type AddOnTemplateInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() addonv1alpha1.AddOnTemplateLister
}

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

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

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

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

func (f *addOnTemplateInformer) Informer() cache.SharedIndexInformer {
	return f.factory.InformerFor(&apiaddonv1alpha1.AddOnTemplate{}, f.defaultInformer)
}

func (f *addOnTemplateInformer) Lister() addonv1alpha1.AddOnTemplateLister {
	return addonv1alpha1.NewAddOnTemplateLister(f.Informer().GetIndexer())
}
