@@ -47,6 +47,7 @@ import (
47
47
auditlog "k8s.io/apiserver/plugin/pkg/audit/log"
48
48
auditwebhook "k8s.io/apiserver/plugin/pkg/audit/webhook"
49
49
pluginwebhook "k8s.io/apiserver/plugin/pkg/audit/webhook"
50
+ "k8s.io/client-go/rest"
50
51
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
51
52
apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
52
53
openapicommon "k8s.io/kube-openapi/pkg/common"
@@ -370,12 +371,13 @@ func buildPublicAddress(masterConfig configapi.MasterConfig) (net.IP, error) {
370
371
return publicAddress , nil
371
372
}
372
373
373
- func buildKubeApiserverConfig (
374
- masterConfig configapi.MasterConfig ,
375
- admissionControl admission.Interface ,
376
- originAuthenticator authenticator.Request ,
377
- kubeAuthorizer authorizer.Authorizer ,
378
- ) (* master.Config , error ) {
374
+ type incompleteKubeMasterConfig struct {
375
+ options * kapiserveroptions.ServerRunOptions
376
+ incompleteConfig * apiserver.Config
377
+ masterConfig configapi.MasterConfig
378
+ }
379
+
380
+ func BuildKubernetesMasterConfig (masterConfig configapi.MasterConfig ) (* incompleteKubeMasterConfig , error ) {
379
381
apiserverOptions , err := BuildKubeAPIserverOptions (masterConfig )
380
382
if err != nil {
381
383
return nil , err
@@ -386,6 +388,20 @@ func buildKubeApiserverConfig(
386
388
return nil , err
387
389
}
388
390
391
+ return & incompleteKubeMasterConfig {apiserverOptions , genericConfig , masterConfig }, nil
392
+ }
393
+
394
+ func (rc * incompleteKubeMasterConfig ) LoopbackConfig () * rest.Config {
395
+ return rc .incompleteConfig .LoopbackClientConfig
396
+ }
397
+
398
+ func (rc * incompleteKubeMasterConfig ) Complete (
399
+ admissionControl admission.Interface ,
400
+ originAuthenticator authenticator.Request ,
401
+ kubeAuthorizer authorizer.Authorizer ,
402
+ ) (* master.Config , error ) {
403
+ genericConfig , apiserverOptions , masterConfig := rc .incompleteConfig , rc .options , rc .masterConfig
404
+
389
405
proxyClientCerts , err := buildProxyClientCerts (masterConfig )
390
406
if err != nil {
391
407
return nil , err
@@ -561,33 +577,13 @@ func buildKubeApiserverConfig(
561
577
)
562
578
}
563
579
564
- return kubeApiserverConfig , nil
565
- }
566
-
567
- // TODO this function's parameters need to be refactored
568
- func BuildKubernetesMasterConfig (
569
- masterConfig configapi.MasterConfig ,
570
- admissionControl admission.Interface ,
571
- originAuthenticator authenticator.Request ,
572
- kubeAuthorizer authorizer.Authorizer ,
573
- ) (* master.Config , error ) {
574
- apiserverConfig , err := buildKubeApiserverConfig (
575
- masterConfig ,
576
- admissionControl ,
577
- originAuthenticator ,
578
- kubeAuthorizer ,
579
- )
580
- if err != nil {
581
- return nil , err
582
- }
583
-
584
580
// we do this for integration tests to be able to turn it off for better startup speed
585
581
// TODO remove the entire option once openapi is faster
586
582
if masterConfig .DisableOpenAPI {
587
- apiserverConfig .GenericConfig .OpenAPIConfig = nil
583
+ kubeApiserverConfig .GenericConfig .OpenAPIConfig = nil
588
584
}
589
585
590
- return apiserverConfig , nil
586
+ return kubeApiserverConfig , nil
591
587
}
592
588
593
589
func defaultOpenAPIConfig (config configapi.MasterConfig ) * openapicommon.Config {
0 commit comments