@@ -7,15 +7,11 @@ import (
7
7
8
8
"k8s.io/klog/v2"
9
9
10
- "k8s.io/apimachinery/pkg/api/meta"
11
10
"k8s.io/apimachinery/pkg/runtime/schema"
12
11
"k8s.io/apimachinery/pkg/util/sets"
13
- "k8s.io/apimachinery/pkg/util/wait"
14
- cacheddiscovery "k8s.io/client-go/discovery/cached"
15
12
"k8s.io/client-go/informers"
16
13
"k8s.io/client-go/kubernetes"
17
14
"k8s.io/client-go/rest"
18
- "k8s.io/client-go/restmapper"
19
15
"k8s.io/controller-manager/app"
20
16
"k8s.io/controller-manager/pkg/clientbuilder"
21
17
@@ -34,7 +30,9 @@ import (
34
30
quotainformer "github.com/openshift/client-go/quota/informers/externalversions"
35
31
routeclient "github.com/openshift/client-go/route/clientset/versioned"
36
32
routeinformer "github.com/openshift/client-go/route/informers/externalversions"
37
- securityclient "github.com/openshift/client-go/securityinternal/clientset/versioned"
33
+ securityclient "github.com/openshift/client-go/security/clientset/versioned"
34
+ securityinformer "github.com/openshift/client-go/security/informers/externalversions"
35
+ securityinternalclient "github.com/openshift/client-go/securityinternal/clientset/versioned"
38
36
templateclient "github.com/openshift/client-go/template/clientset/versioned"
39
37
templateinformer "github.com/openshift/client-go/template/informers/externalversions"
40
38
"github.com/openshift/library-go/pkg/controller/controllercmd"
@@ -66,11 +64,6 @@ func NewControllerContext(
66
64
clientConfig .Burst = clientConfig .Burst / 10 + 1
67
65
}
68
66
69
- discoveryClient := cacheddiscovery .NewMemCacheClient (kubeClient .Discovery ())
70
- dynamicRestMapper := restmapper .NewDeferredDiscoveryRESTMapper (discoveryClient )
71
- dynamicRestMapper .Reset ()
72
- go wait .Until (dynamicRestMapper .Reset , 30 * time .Second , ctx .Done ())
73
-
74
67
appsClient , err := appsclient .NewForConfig (clientConfig )
75
68
if err != nil {
76
69
return nil , err
@@ -103,6 +96,10 @@ func NewControllerContext(
103
96
if err != nil {
104
97
return nil , err
105
98
}
99
+ securityClient , err := securityclient .NewForConfig (clientConfig )
100
+ if err != nil {
101
+ return nil , err
102
+ }
106
103
107
104
openshiftControllerContext := & EnhancedControllerContext {
108
105
ControllerContext : controllerContext ,
@@ -111,19 +108,17 @@ func NewControllerContext(
111
108
ClientBuilder : OpenshiftControllerClientBuilder {
112
109
ControllerClientBuilder : clientbuilder .NewDynamicClientBuilder (rest .AnonymousClientConfig (clientConfig ), kubeClient .CoreV1 (), defaultOpenShiftInfraNamespace ),
113
110
},
114
- KubernetesInformers : informers .NewSharedInformerFactory (kubeClient , defaultInformerResyncPeriod ),
115
- OpenshiftConfigKubernetesInformers : informers .NewSharedInformerFactoryWithOptions (kubeClient , defaultInformerResyncPeriod , informers .WithNamespace ("openshift-config" )),
116
- ControllerManagerKubeInformers : informers .NewSharedInformerFactoryWithOptions (kubeClient , defaultInformerResyncPeriod , informers .WithNamespace ("openshift-controller-manager" )),
117
- AppsInformers : appsinformer .NewSharedInformerFactory (appsClient , defaultInformerResyncPeriod ),
118
- BuildInformers : buildinformer .NewSharedInformerFactory (buildClient , defaultInformerResyncPeriod ),
119
- ConfigInformers : configinformer .NewSharedInformerFactory (configClient , defaultInformerResyncPeriod ),
120
- ImageInformers : imageinformer .NewSharedInformerFactory (imageClient , defaultInformerResyncPeriod ),
121
- OperatorInformers : operatorinformer .NewSharedInformerFactory (operatorClient , defaultInformerResyncPeriod ),
122
- QuotaInformers : quotainformer .NewSharedInformerFactory (quotaClient , defaultInformerResyncPeriod ),
123
- RouteInformers : routeinformer .NewSharedInformerFactory (routerClient , defaultInformerResyncPeriod ),
124
- TemplateInformers : templateinformer .NewSharedInformerFactory (templateClient , defaultInformerResyncPeriod ),
125
- InformersStarted : make (chan struct {}),
126
- RestMapper : dynamicRestMapper ,
111
+ KubernetesInformers : informers .NewSharedInformerFactory (kubeClient , defaultInformerResyncPeriod ),
112
+ AppsInformers : appsinformer .NewSharedInformerFactory (appsClient , defaultInformerResyncPeriod ),
113
+ BuildInformers : buildinformer .NewSharedInformerFactory (buildClient , defaultInformerResyncPeriod ),
114
+ ConfigInformers : configinformer .NewSharedInformerFactory (configClient , defaultInformerResyncPeriod ),
115
+ ImageInformers : imageinformer .NewSharedInformerFactory (imageClient , defaultInformerResyncPeriod ),
116
+ OperatorInformers : operatorinformer .NewSharedInformerFactory (operatorClient , defaultInformerResyncPeriod ),
117
+ QuotaInformers : quotainformer .NewSharedInformerFactory (quotaClient , defaultInformerResyncPeriod ),
118
+ RouteInformers : routeinformer .NewSharedInformerFactory (routerClient , defaultInformerResyncPeriod ),
119
+ SecurityInformers : securityinformer .NewSharedInformerFactory (securityClient , defaultInformerResyncPeriod ),
120
+ TemplateInformers : templateinformer .NewSharedInformerFactory (templateClient , defaultInformerResyncPeriod ),
121
+ InformersStarted : make (chan struct {}),
127
122
}
128
123
openshiftControllerContext .GenericResourceInformer = openshiftControllerContext .ToGenericInformer ()
129
124
@@ -165,9 +160,7 @@ type EnhancedControllerContext struct {
165
160
// ClientBuilder will provide a client for this controller to use
166
161
ClientBuilder ControllerClientBuilder
167
162
168
- KubernetesInformers informers.SharedInformerFactory
169
- OpenshiftConfigKubernetesInformers informers.SharedInformerFactory
170
- ControllerManagerKubeInformers informers.SharedInformerFactory
163
+ KubernetesInformers informers.SharedInformerFactory
171
164
172
165
TemplateInformers templateinformer.SharedInformerFactory
173
166
QuotaInformers quotainformer.SharedInformerFactory
@@ -178,9 +171,9 @@ type EnhancedControllerContext struct {
178
171
ConfigInformers configinformer.SharedInformerFactory
179
172
ImageInformers imageinformer.SharedInformerFactory
180
173
OperatorInformers operatorinformer.SharedInformerFactory
174
+ SecurityInformers securityinformer.SharedInformerFactory
181
175
182
176
GenericResourceInformer genericinformers.GenericResourceInformer
183
- RestMapper meta.RESTMapper
184
177
185
178
informersStartedLock sync.Mutex
186
179
informersStartedClosed bool
@@ -191,13 +184,12 @@ type EnhancedControllerContext struct {
191
184
192
185
func (c * EnhancedControllerContext ) StartInformers (stopCh <- chan struct {}) {
193
186
c .KubernetesInformers .Start (stopCh )
194
- c .OpenshiftConfigKubernetesInformers .Start (stopCh )
195
- c .ControllerManagerKubeInformers .Start (stopCh )
196
187
197
188
c .AppsInformers .Start (stopCh )
198
189
c .BuildInformers .Start (stopCh )
199
190
c .ConfigInformers .Start (stopCh )
200
191
c .ImageInformers .Start (stopCh )
192
+ c .SecurityInformers .Start (stopCh )
201
193
202
194
c .TemplateInformers .Start (stopCh )
203
195
c .QuotaInformers .Start (stopCh )
@@ -228,8 +220,8 @@ type ControllerClientBuilder interface {
228
220
OpenshiftConfigClient (name string ) (configclient.Interface , error )
229
221
OpenshiftConfigClientOrDie (name string ) configclient.Interface
230
222
231
- OpenshiftSecurityClient (name string ) (securityclient .Interface , error )
232
- OpenshiftSecurityClientOrDie (name string ) securityclient .Interface
223
+ OpenshiftSecurityClient (name string ) (securityinternalclient .Interface , error )
224
+ OpenshiftSecurityClientOrDie (name string ) securityinternalclient .Interface
233
225
234
226
// OpenShift clients based on generated internal clientsets
235
227
OpenshiftTemplateClient (name string ) (templateclient.Interface , error )
@@ -399,15 +391,15 @@ func (b OpenshiftControllerClientBuilder) OpenshiftQuotaClientOrDie(name string)
399
391
return client
400
392
}
401
393
402
- func (b OpenshiftControllerClientBuilder ) OpenshiftSecurityClient (name string ) (securityclient .Interface , error ) {
394
+ func (b OpenshiftControllerClientBuilder ) OpenshiftSecurityClient (name string ) (securityinternalclient .Interface , error ) {
403
395
clientConfig , err := b .Config (name )
404
396
if err != nil {
405
397
return nil , err
406
398
}
407
- return securityclient .NewForConfig (nonProtobufConfig (clientConfig ))
399
+ return securityinternalclient .NewForConfig (nonProtobufConfig (clientConfig ))
408
400
}
409
401
410
- func (b OpenshiftControllerClientBuilder ) OpenshiftSecurityClientOrDie (name string ) securityclient .Interface {
402
+ func (b OpenshiftControllerClientBuilder ) OpenshiftSecurityClientOrDie (name string ) securityinternalclient .Interface {
411
403
client , err := b .OpenshiftSecurityClient (name )
412
404
if err != nil {
413
405
klog .Fatal (err )
0 commit comments