@@ -19,6 +19,8 @@ package informers
|
||||
import (
|
||||
snapshotclient "github.com/kubernetes-csi/external-snapshotter/client/v3/clientset/versioned"
|
||||
snapshotinformer "github.com/kubernetes-csi/external-snapshotter/client/v3/informers/externalversions"
|
||||
prominformers "github.com/prometheus-operator/prometheus-operator/pkg/client/informers/externalversions"
|
||||
promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
|
||||
istioclient "istio.io/client-go/pkg/clientset/versioned"
|
||||
istioinformers "istio.io/client-go/pkg/informers/externalversions"
|
||||
apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
|
||||
@@ -41,6 +43,7 @@ type InformerFactory interface {
|
||||
IstioSharedInformerFactory() istioinformers.SharedInformerFactory
|
||||
SnapshotSharedInformerFactory() snapshotinformer.SharedInformerFactory
|
||||
ApiExtensionSharedInformerFactory() apiextensionsinformers.SharedInformerFactory
|
||||
PrometheusSharedInformerFactory() prominformers.SharedInformerFactory
|
||||
|
||||
// Start shared informer factory one by one if they are not nil
|
||||
Start(stopCh <-chan struct{})
|
||||
@@ -52,10 +55,12 @@ type informerFactories struct {
|
||||
istioInformerFactory istioinformers.SharedInformerFactory
|
||||
snapshotInformerFactory snapshotinformer.SharedInformerFactory
|
||||
apiextensionsInformerFactory apiextensionsinformers.SharedInformerFactory
|
||||
prometheusInformerFactory prominformers.SharedInformerFactory
|
||||
}
|
||||
|
||||
func NewInformerFactories(client kubernetes.Interface, ksClient versioned.Interface, istioClient istioclient.Interface,
|
||||
snapshotClient snapshotclient.Interface, apiextensionsClient apiextensionsclient.Interface) InformerFactory {
|
||||
snapshotClient snapshotclient.Interface, apiextensionsClient apiextensionsclient.Interface,
|
||||
prometheusClient promresourcesclient.Interface) InformerFactory {
|
||||
factory := &informerFactories{}
|
||||
|
||||
if client != nil {
|
||||
@@ -78,6 +83,10 @@ func NewInformerFactories(client kubernetes.Interface, ksClient versioned.Interf
|
||||
factory.apiextensionsInformerFactory = apiextensionsinformers.NewSharedInformerFactory(apiextensionsClient, defaultResync)
|
||||
}
|
||||
|
||||
if prometheusClient != nil {
|
||||
factory.prometheusInformerFactory = prominformers.NewSharedInformerFactory(prometheusClient, defaultResync)
|
||||
}
|
||||
|
||||
return factory
|
||||
}
|
||||
|
||||
@@ -101,6 +110,10 @@ func (f *informerFactories) ApiExtensionSharedInformerFactory() apiextensionsinf
|
||||
return f.apiextensionsInformerFactory
|
||||
}
|
||||
|
||||
func (f *informerFactories) PrometheusSharedInformerFactory() prominformers.SharedInformerFactory {
|
||||
return f.prometheusInformerFactory
|
||||
}
|
||||
|
||||
func (f *informerFactories) Start(stopCh <-chan struct{}) {
|
||||
if f.informerFactory != nil {
|
||||
f.informerFactory.Start(stopCh)
|
||||
@@ -121,4 +134,8 @@ func (f *informerFactories) Start(stopCh <-chan struct{}) {
|
||||
if f.apiextensionsInformerFactory != nil {
|
||||
f.apiextensionsInformerFactory.Start(stopCh)
|
||||
}
|
||||
|
||||
if f.prometheusInformerFactory != nil {
|
||||
f.prometheusInformerFactory.Start(stopCh)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user