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