-
Notifications
You must be signed in to change notification settings - Fork 91
/
observe_config_controller.go
93 lines (82 loc) · 3.68 KB
/
observe_config_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package configobservercontroller
import (
"k8s.io/client-go/tools/cache"
configinformers "github.com/openshift/client-go/config/informers/externalversions"
"github.com/openshift/library-go/pkg/controller/factory"
"github.com/openshift/library-go/pkg/operator/configobserver"
"github.com/openshift/library-go/pkg/operator/configobserver/apiserver"
"github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"
"github.com/openshift/library-go/pkg/operator/v1helpers"
"github.com/openshift/cluster-authentication-operator/pkg/controllers/configobservation"
"github.com/openshift/cluster-authentication-operator/pkg/controllers/configobservation/console"
"github.com/openshift/cluster-authentication-operator/pkg/controllers/configobservation/infrastructure"
"github.com/openshift/cluster-authentication-operator/pkg/controllers/configobservation/oauth"
"github.com/openshift/cluster-authentication-operator/pkg/controllers/configobservation/routersecret"
)
func NewConfigObserver(
operatorClient v1helpers.OperatorClient,
kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces,
configInformer configinformers.SharedInformerFactory,
resourceSyncer resourcesynccontroller.ResourceSyncer,
eventRecorder events.Recorder,
) factory.Controller {
interestingNamespaces := []string{
"openshift-authentication",
"openshift-config",
}
preRunCacheSynced := []cache.InformerSynced{
operatorClient.Informer().HasSynced,
configInformer.Config().V1().APIServers().Informer().HasSynced,
configInformer.Config().V1().Consoles().Informer().HasSynced,
configInformer.Config().V1().Infrastructures().Informer().HasSynced,
configInformer.Config().V1().OAuths().Informer().HasSynced,
}
informers := []factory.Informer{
operatorClient.Informer(),
configInformer.Config().V1().APIServers().Informer(),
configInformer.Config().V1().Consoles().Informer(),
configInformer.Config().V1().Infrastructures().Informer(),
configInformer.Config().V1().OAuths().Informer(),
}
for _, ns := range interestingNamespaces {
preRunCacheSynced = append(preRunCacheSynced,
kubeInformersForNamespaces.InformersFor(ns).Core().V1().ConfigMaps().Informer().HasSynced,
kubeInformersForNamespaces.InformersFor(ns).Core().V1().Secrets().Informer().HasSynced,
)
informers = append(informers,
kubeInformersForNamespaces.InformersFor(ns).Core().V1().ConfigMaps().Informer(),
kubeInformersForNamespaces.InformersFor(ns).Core().V1().Secrets().Informer(),
)
}
oauthServerObservers := []configobserver.ObserveConfigFunc{}
for _, o := range []configobserver.ObserveConfigFunc{
apiserver.ObserveAdditionalCORSAllowedOrigins,
apiserver.ObserveTLSSecurityProfile,
console.ObserveConsoleURL,
infrastructure.ObserveAPIServerURL,
oauth.ObserveIdentityProviders,
oauth.ObserveTemplates,
oauth.ObserveTokenConfig,
routersecret.ObserveRouterSecret,
} {
oauthServerObservers = append(oauthServerObservers,
configobserver.WithPrefix(o, configobservation.OAuthServerConfigPrefix))
}
return configobserver.NewConfigObserver(
operatorClient,
eventRecorder,
configobservation.Listers{
ConfigMapLister: kubeInformersForNamespaces.ConfigMapLister(),
SecretsLister: kubeInformersForNamespaces.SecretLister(),
APIServerLister_: configInformer.Config().V1().APIServers().Lister(),
ConsoleLister: configInformer.Config().V1().Consoles().Lister(),
InfrastructureLister: configInformer.Config().V1().Infrastructures().Lister(),
OAuthLister: configInformer.Config().V1().OAuths().Lister(),
ResourceSync: resourceSyncer,
PreRunCachesSynced: preRunCacheSynced,
},
informers,
oauthServerObservers...,
)
}