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

package v1alpha1

import (
	"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"
	addonv1alpha1 "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"
	v1alpha1 "open-cluster-management.io/api/client/addon/listers/addon/v1alpha1"
)

// ManagedClusterAddOnInformer provides access to a shared informer and lister for
// ManagedClusterAddOns.
type ManagedClusterAddOnInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() v1alpha1.ManagedClusterAddOnLister
}

type managedClusterAddOnInformer struct {
	factory          internalinterfaces.SharedInformerFactory
	tweakListOptions internalinterfaces.TweakListOptionsFunc
	namespace        string
}

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

// NewFilteredManagedClusterAddOnInformer constructs a new informer for ManagedClusterAddOn 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 NewFilteredManagedClusterAddOnInformer(client versioned.Interface, namespace string, 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().ManagedClusterAddOns(namespace).List(context.TODO(), options)
			},
			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.AddonV1alpha1().ManagedClusterAddOns(namespace).Watch(context.TODO(), options)
			},
		},
		&addonv1alpha1.ManagedClusterAddOn{},
		resyncPeriod,
		indexers,
	)
}

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

func (f *managedClusterAddOnInformer) Informer() cache.SharedIndexInformer {
	return f.factory.InformerFor(&addonv1alpha1.ManagedClusterAddOn{}, f.defaultInformer)
}

func (f *managedClusterAddOnInformer) Lister() v1alpha1.ManagedClusterAddOnLister {
	return v1alpha1.NewManagedClusterAddOnLister(f.Informer().GetIndexer())
}
