From eeeaa6867ad5cb6d1d45ce72ce1bcf36ea798113 Mon Sep 17 00:00:00 2001 From: nikhiljindal Date: Mon, 28 Mar 2016 14:03:42 -0700 Subject: [PATCH] Moving InstallSwaggerAPI to Run --- pkg/genericapiserver/genericapiserver.go | 15 ++++++++------- test/integration/kubectl_test.go | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/genericapiserver/genericapiserver.go b/pkg/genericapiserver/genericapiserver.go index 033b60386a775..1cc7dd39f639c 100644 --- a/pkg/genericapiserver/genericapiserver.go +++ b/pkg/genericapiserver/genericapiserver.go @@ -616,16 +616,13 @@ func (s *GenericAPIServer) init(c *Config) { s.installGroupsDiscoveryHandler() } -// Exposes the given group versions in API. +// Exposes the given group versions in API. Helper method to install multiple group versions at once. func (s *GenericAPIServer) InstallAPIGroups(groupsInfo []APIGroupInfo) error { for _, apiGroupInfo := range groupsInfo { - if err := s.installAPIGroup(&apiGroupInfo); err != nil { + if err := s.InstallAPIGroup(&apiGroupInfo); err != nil { return err } } - if s.enableSwaggerSupport { - s.InstallSwaggerAPI() - } return nil } @@ -652,7 +649,10 @@ func (s *GenericAPIServer) installGroupsDiscoveryHandler() { } func (s *GenericAPIServer) Run(options *ServerRunOptions) { - // We serve on 2 ports. See docs/accessing_the_api.md + if s.enableSwaggerSupport { + s.InstallSwaggerAPI() + } + // We serve on 2 ports. See docs/accessing_the_api.md secureLocation := "" if options.SecurePort != 0 { secureLocation = net.JoinHostPort(options.BindAddress.String(), strconv.Itoa(options.SecurePort)) @@ -768,7 +768,8 @@ func shouldGenSelfSignedCerts(certPath, keyPath string) bool { return true } -func (s *GenericAPIServer) installAPIGroup(apiGroupInfo *APIGroupInfo) error { +// Exposes the given group version in API. +func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error { apiPrefix := s.APIGroupPrefix if apiGroupInfo.IsLegacyGroup { apiPrefix = s.APIPrefix diff --git a/test/integration/kubectl_test.go b/test/integration/kubectl_test.go index cb62adb88f479..10b3e0f404f86 100644 --- a/test/integration/kubectl_test.go +++ b/test/integration/kubectl_test.go @@ -46,6 +46,8 @@ func TestKubectlValidation(t *testing.T) { defer components.Stop(true, true) ctx := clientcmdapi.NewContext() cfg := clientcmdapi.NewConfig() + // Enable swagger api on master. + components.KubeMaster.InstallSwaggerAPI() cluster := clientcmdapi.NewCluster() cluster.Server = components.ApiServer.URL cluster.InsecureSkipTLSVerify = true