forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
starter.go
42 lines (33 loc) · 1.2 KB
/
starter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package webconsole_operator
import (
"fmt"
"time"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
webconsoleclient "github.com/openshift/origin/pkg/cmd/openshift-operators/generated/clientset/versioned"
webconsoleinformers "github.com/openshift/origin/pkg/cmd/openshift-operators/generated/informers/externalversions"
)
func RunWebConsoleOperator(clientConfig *rest.Config, stopCh <-chan struct{}) error {
kubeClient, err := kubernetes.NewForConfig(clientConfig)
if err != nil {
panic(err)
}
webconsoleClient, err := webconsoleclient.NewForConfig(clientConfig)
if err != nil {
panic(err)
}
operatorInformers := webconsoleinformers.NewSharedInformerFactory(webconsoleClient, 10*time.Minute)
kubeInformersNamespaced := informers.NewFilteredSharedInformerFactory(kubeClient, 10*time.Minute, targetNamespaceName, nil)
operator := NewWebConsoleOperator(
operatorInformers.Webconsole().V1alpha1().OpenShiftWebConsoleConfigs(),
kubeInformersNamespaced,
webconsoleClient.WebconsoleV1alpha1(),
kubeClient.AppsV1(),
kubeClient.CoreV1(),
)
operatorInformers.Start(stopCh)
kubeInformersNamespaced.Start(stopCh)
operator.Run(1, stopCh)
return fmt.Errorf("stopped")
}