forked from openshift/library-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.go
36 lines (29 loc) · 1.2 KB
/
controller.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
package controllers
import (
"k8s.io/client-go/tools/cache"
"github.com/openshift/library-go/pkg/operator/encryption/statemachine"
"github.com/openshift/library-go/pkg/operator/management"
operatorv1helpers "github.com/openshift/library-go/pkg/operator/v1helpers"
)
func shouldRunEncryptionController(operatorClient operatorv1helpers.OperatorClient) (bool, error) {
operatorSpec, _, _, err := operatorClient.GetOperatorState()
if err != nil {
return false, err
}
return management.IsOperatorManaged(operatorSpec.ManagementState), nil
}
func setUpInformers(
deployer statemachine.Deployer,
operatorClient operatorv1helpers.OperatorClient,
kubeInformersForNamespaces operatorv1helpers.KubeInformersForNamespaces,
eventHandler cache.ResourceEventHandler,
) []cache.InformerSynced {
operatorInformer := operatorClient.Informer()
operatorInformer.AddEventHandler(eventHandler)
managedSecretsInformer := kubeInformersForNamespaces.InformersFor("openshift-config-managed").Core().V1().Secrets().Informer()
managedSecretsInformer.AddEventHandler(eventHandler)
return append([]cache.InformerSynced{
operatorInformer.HasSynced,
managedSecretsInformer.HasSynced,
}, deployer.AddEventHandler(eventHandler)...)
}