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

package externalversions

import (
	"fmt"

	v1alpha1 "github.com/gocrane/api/analysis/v1alpha1"
	autoscalingv1alpha1 "github.com/gocrane/api/autoscaling/v1alpha1"
	co2ev1alpha1 "github.com/gocrane/api/co2e/v1alpha1"
	ensurancev1alpha1 "github.com/gocrane/api/ensurance/v1alpha1"
	predictionv1alpha1 "github.com/gocrane/api/prediction/v1alpha1"
	topologyv1alpha1 "github.com/gocrane/api/topology/v1alpha1"
	schema "k8s.io/apimachinery/pkg/runtime/schema"
	cache "k8s.io/client-go/tools/cache"
)

// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() cache.GenericLister
}

type genericInformer struct {
	informer cache.SharedIndexInformer
	resource schema.GroupResource
}

// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
	return f.informer
}

// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
	return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}

// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
	switch resource {
	// Group=analysis.crane.io, Version=v1alpha1
	case v1alpha1.SchemeGroupVersion.WithResource("analytics"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Analysis().V1alpha1().Analytics().Informer()}, nil
	case v1alpha1.SchemeGroupVersion.WithResource("configsets"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Analysis().V1alpha1().ConfigSets().Informer()}, nil
	case v1alpha1.SchemeGroupVersion.WithResource("recommendations"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Analysis().V1alpha1().Recommendations().Informer()}, nil
	case v1alpha1.SchemeGroupVersion.WithResource("recommendationrules"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Analysis().V1alpha1().RecommendationRules().Informer()}, nil

		// Group=autoscaling.crane.io, Version=v1alpha1
	case autoscalingv1alpha1.SchemeGroupVersion.WithResource("effectivehorizontalpodautoscalers"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().EffectiveHorizontalPodAutoscalers().Informer()}, nil
	case autoscalingv1alpha1.SchemeGroupVersion.WithResource("effectiveverticalpodautoscalers"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().EffectiveVerticalPodAutoscalers().Informer()}, nil
	case autoscalingv1alpha1.SchemeGroupVersion.WithResource("substitutes"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().Substitutes().Informer()}, nil

		// Group=co2e.crane.io, Version=v1alpha1
	case co2ev1alpha1.SchemeGroupVersion.WithResource("cloudcarbonfootprints"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Co2e().V1alpha1().CloudCarbonFootprints().Informer()}, nil

		// Group=ensurance.crane.io, Version=v1alpha1
	case ensurancev1alpha1.SchemeGroupVersion.WithResource("avoidanceactions"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Ensurance().V1alpha1().AvoidanceActions().Informer()}, nil
	case ensurancev1alpha1.SchemeGroupVersion.WithResource("nodeqoss"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Ensurance().V1alpha1().NodeQOSs().Informer()}, nil
	case ensurancev1alpha1.SchemeGroupVersion.WithResource("podqoss"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Ensurance().V1alpha1().PodQOSs().Informer()}, nil

		// Group=prediction.crane.io, Version=v1alpha1
	case predictionv1alpha1.SchemeGroupVersion.WithResource("clusternodepredictions"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Prediction().V1alpha1().ClusterNodePredictions().Informer()}, nil
	case predictionv1alpha1.SchemeGroupVersion.WithResource("timeseriespredictions"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Prediction().V1alpha1().TimeSeriesPredictions().Informer()}, nil

		// Group=topology.crane.io, Version=v1alpha1
	case topologyv1alpha1.SchemeGroupVersion.WithResource("noderesourcetopologies"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Topology().V1alpha1().NodeResourceTopologies().Informer()}, nil

	}

	return nil, fmt.Errorf("no informer found for %v", resource)
}
