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

package v1alpha1

import (
	"context"
	time "time"

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

// ClusterManagementAddOnInformer provides access to a shared informer and lister for
// ClusterManagementAddOns.
type ClusterManagementAddOnInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() v1alpha1.ClusterManagementAddOnLister
}

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

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

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

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

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

func (f *clusterManagementAddOnInformer) Lister() v1alpha1.ClusterManagementAddOnLister {
	return v1alpha1.NewClusterManagementAddOnLister(f.Informer().GetIndexer())
}
