@@ -12,6 +12,7 @@ import (
12
12
"github.com/golang/glog"
13
13
14
14
kapierrors "k8s.io/apimachinery/pkg/api/errors"
15
+ "k8s.io/apimachinery/pkg/api/meta"
15
16
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16
17
"k8s.io/apimachinery/pkg/labels"
17
18
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -35,6 +36,8 @@ import (
35
36
"k8s.io/apiserver/pkg/authorization/authorizerfactory"
36
37
authorizerunion "k8s.io/apiserver/pkg/authorization/union"
37
38
apirequest "k8s.io/apiserver/pkg/endpoints/request"
39
+ "k8s.io/client-go/discovery"
40
+ cacheddiscovery "k8s.io/client-go/discovery/cached"
38
41
kubeclientgoinformers "k8s.io/client-go/informers"
39
42
kubeclientgoclient "k8s.io/client-go/kubernetes"
40
43
restclient "k8s.io/client-go/rest"
@@ -95,6 +98,8 @@ import (
95
98
type MasterConfig struct {
96
99
Options configapi.MasterConfig
97
100
101
+ RESTMapper * discovery.DeferredDiscoveryRESTMapper
102
+
98
103
// RESTOptionsGetter provides access to storage and RESTOptions for a particular resource
99
104
RESTOptionsGetter restoptions.Getter
100
105
@@ -225,6 +230,10 @@ func BuildMasterConfig(options configapi.MasterConfig, informers InformerAccess)
225
230
options .ProjectConfig .ProjectRequestMessage ,
226
231
)
227
232
233
+ // Use a discovery client capable of being refreshed.
234
+ discoveryClient := cacheddiscovery .NewMemCacheClient (privilegedLoopbackKubeClientsetInternal .Discovery ())
235
+ restMapper := discovery .NewDeferredDiscoveryRESTMapper (discoveryClient , meta .InterfacesForUnstructured )
236
+
228
237
// punch through layers to build this in order to get a string for a cloud provider file
229
238
// TODO refactor us into a forward building flow with a side channel like this
230
239
kubeOptions , err := kubernetes .BuildKubeAPIserverOptions (options )
@@ -251,8 +260,7 @@ func BuildMasterConfig(options configapi.MasterConfig, informers InformerAccess)
251
260
informers .GetInternalKubeInformers (),
252
261
authorizer ,
253
262
cloudConfig ,
254
- // TODO: use a dynamic restmapper. See https://github.com/kubernetes/kubernetes/pull/42615.
255
- kapi .Registry .RESTMapper (),
263
+ restMapper ,
256
264
quotaRegistry )
257
265
openshiftPluginInitializer := & oadmission.PluginInitializer {
258
266
OpenshiftClient : privilegedLoopbackOpenShiftClient ,
@@ -298,6 +306,8 @@ func BuildMasterConfig(options configapi.MasterConfig, informers InformerAccess)
298
306
config := & MasterConfig {
299
307
Options : options ,
300
308
309
+ RESTMapper : restMapper ,
310
+
301
311
RESTOptionsGetter : restOptsGetter ,
302
312
303
313
RuleResolver : ruleResolver ,
0 commit comments