Skip to content

Commit

Permalink
Merge pull request kubernetes#23554 from nikhiljindal/swaggerInRun
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

genericapiserver: Moving InstallSwaggerAPI to Run

Ref kubernetes#21190 (comment)

Moving InstallSwaggerAPI() from InstallAPIGroups() to Run(). This allows the use of InstallAPIGroups() multiple times or using InstallAPIGroup() directly.

cc @jianhuiz @kubernetes/sig-api-machinery
  • Loading branch information
k8s-merge-robot committed Apr 2, 2016
2 parents e9c57e6 + eeeaa68 commit 3197f31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/genericapiserver/genericapiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,16 +605,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
}

Expand All @@ -641,7 +638,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))
Expand Down Expand Up @@ -757,7 +757,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
Expand Down
2 changes: 2 additions & 0 deletions test/integration/kubectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3197f31

Please sign in to comment.