apiserver: chain delegated PrepareRun

This commit is contained in:
Dr. Stefan Schimanski 2019-03-04 12:04:43 +01:00
parent 915be28b61
commit 7c4329ed45
2 changed files with 9 additions and 8 deletions

View File

@ -184,13 +184,6 @@ func CreateServerChain(completedOptions completedServerRunOptions, stopCh <-chan
return nil, err return nil, err
} }
// otherwise go down the normal path of standing the aggregator up in front of the API server
// this wires up openapi
kubeAPIServer.GenericAPIServer.PrepareRun()
// This will wire up openapi for extension api server
apiExtensionsServer.GenericAPIServer.PrepareRun()
// aggregator comes last in the chain // aggregator comes last in the chain
aggregatorConfig, err := createAggregatorConfig(*kubeAPIServerConfig.GenericConfig, completedOptions.ServerRunOptions, kubeAPIServerConfig.ExtraConfig.VersionedInformers, serviceResolver, proxyTransport, pluginInitializer) aggregatorConfig, err := createAggregatorConfig(*kubeAPIServerConfig.GenericConfig, completedOptions.ServerRunOptions, kubeAPIServerConfig.ExtraConfig.VersionedInformers, serviceResolver, proxyTransport, pluginInitializer)
if err != nil { if err != nil {

View File

@ -205,6 +205,9 @@ type DelegationTarget interface {
// NextDelegate returns the next delegationTarget in the chain of delegations // NextDelegate returns the next delegationTarget in the chain of delegations
NextDelegate() DelegationTarget NextDelegate() DelegationTarget
// PrepareRun does post API installation setup steps. It calls recursively the same function of the delegates.
PrepareRun() preparedGenericAPIServer
} }
func (s *GenericAPIServer) UnprotectedHandler() http.Handler { func (s *GenericAPIServer) UnprotectedHandler() http.Handler {
@ -253,14 +256,19 @@ func (s emptyDelegate) ListedPaths() []string {
func (s emptyDelegate) NextDelegate() DelegationTarget { func (s emptyDelegate) NextDelegate() DelegationTarget {
return nil return nil
} }
func (s emptyDelegate) PrepareRun() preparedGenericAPIServer {
return preparedGenericAPIServer{nil}
}
// preparedGenericAPIServer is a private wrapper that enforces a call of PrepareRun() before Run can be invoked. // preparedGenericAPIServer is a private wrapper that enforces a call of PrepareRun() before Run can be invoked.
type preparedGenericAPIServer struct { type preparedGenericAPIServer struct {
*GenericAPIServer *GenericAPIServer
} }
// PrepareRun does post API installation setup steps. // PrepareRun does post API installation setup steps. It calls recursively the same function of the delegates.
func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer { func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer {
s.delegationTarget.PrepareRun()
if s.openAPIConfig != nil { if s.openAPIConfig != nil {
s.OpenAPIVersionedService, s.StaticOpenAPISpec = routes.OpenAPI{ s.OpenAPIVersionedService, s.StaticOpenAPISpec = routes.OpenAPI{
Config: s.openAPIConfig, Config: s.openAPIConfig,