@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ limitations under the License.
|
||||
package informers
|
||||
|
||||
import (
|
||||
prominformers "github.com/prometheus-operator/prometheus-operator/pkg/client/informers/externalversions"
|
||||
promfake "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned/fake"
|
||||
snapshotinformer "github.com/kubernetes-csi/external-snapshotter/client/v3/informers/externalversions"
|
||||
istioinformers "istio.io/client-go/pkg/informers/externalversions"
|
||||
apiextensionsinformers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions"
|
||||
@@ -30,6 +32,7 @@ import (
|
||||
type nullInformerFactory struct {
|
||||
fakeK8sInformerFactory informers.SharedInformerFactory
|
||||
fakeKsInformerFactory ksinformers.SharedInformerFactory
|
||||
fakePrometheusFactory prominformers.SharedInformerFactory
|
||||
}
|
||||
|
||||
func NewNullInformerFactory() InformerFactory {
|
||||
@@ -39,9 +42,13 @@ func NewNullInformerFactory() InformerFactory {
|
||||
fakeKsClient := ksfake.NewSimpleClientset()
|
||||
fakeKsInformerFactory := ksinformers.NewSharedInformerFactory(fakeKsClient, time.Minute*10)
|
||||
|
||||
fakePrometheusClient := promfake.NewSimpleClientset()
|
||||
fakePrometheusFactory := prominformers.NewSharedInformerFactory(fakePrometheusClient, time.Minute*10)
|
||||
|
||||
return &nullInformerFactory{
|
||||
fakeK8sInformerFactory: fakeInformerFactory,
|
||||
fakeKsInformerFactory: fakeKsInformerFactory,
|
||||
fakePrometheusFactory: fakePrometheusFactory,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,5 +72,9 @@ func (n nullInformerFactory) ApiExtensionSharedInformerFactory() apiextensionsin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *nullInformerFactory) PrometheusSharedInformerFactory() prominformers.SharedInformerFactory {
|
||||
return n.fakePrometheusFactory
|
||||
}
|
||||
|
||||
func (n nullInformerFactory) Start(stopCh <-chan struct{}) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user