mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Merge pull request #23554 from nikhiljindal/swaggerInRun
Automatic merge from submit-queue genericapiserver: Moving InstallSwaggerAPI to Run Ref https://github.com/kubernetes/kubernetes/pull/21190#discussion_r57494673 Moving InstallSwaggerAPI() from InstallAPIGroups() to Run(). This allows the use of InstallAPIGroups() multiple times or using InstallAPIGroup() directly. cc @jianhuiz @kubernetes/sig-api-machinery
This commit is contained in:
commit
3197f31cc6
@ -605,16 +605,13 @@ func (s *GenericAPIServer) init(c *Config) {
|
|||||||
s.installGroupsDiscoveryHandler()
|
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 {
|
func (s *GenericAPIServer) InstallAPIGroups(groupsInfo []APIGroupInfo) error {
|
||||||
for _, apiGroupInfo := range groupsInfo {
|
for _, apiGroupInfo := range groupsInfo {
|
||||||
if err := s.installAPIGroup(&apiGroupInfo); err != nil {
|
if err := s.InstallAPIGroup(&apiGroupInfo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.enableSwaggerSupport {
|
|
||||||
s.InstallSwaggerAPI()
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,6 +638,9 @@ func (s *GenericAPIServer) installGroupsDiscoveryHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *GenericAPIServer) Run(options *ServerRunOptions) {
|
func (s *GenericAPIServer) Run(options *ServerRunOptions) {
|
||||||
|
if s.enableSwaggerSupport {
|
||||||
|
s.InstallSwaggerAPI()
|
||||||
|
}
|
||||||
// We serve on 2 ports. See docs/accessing_the_api.md
|
// We serve on 2 ports. See docs/accessing_the_api.md
|
||||||
secureLocation := ""
|
secureLocation := ""
|
||||||
if options.SecurePort != 0 {
|
if options.SecurePort != 0 {
|
||||||
@ -757,7 +757,8 @@ func shouldGenSelfSignedCerts(certPath, keyPath string) bool {
|
|||||||
return true
|
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
|
apiPrefix := s.APIGroupPrefix
|
||||||
if apiGroupInfo.IsLegacyGroup {
|
if apiGroupInfo.IsLegacyGroup {
|
||||||
apiPrefix = s.APIPrefix
|
apiPrefix = s.APIPrefix
|
||||||
|
@ -46,6 +46,8 @@ func TestKubectlValidation(t *testing.T) {
|
|||||||
defer components.Stop(true, true)
|
defer components.Stop(true, true)
|
||||||
ctx := clientcmdapi.NewContext()
|
ctx := clientcmdapi.NewContext()
|
||||||
cfg := clientcmdapi.NewConfig()
|
cfg := clientcmdapi.NewConfig()
|
||||||
|
// Enable swagger api on master.
|
||||||
|
components.KubeMaster.InstallSwaggerAPI()
|
||||||
cluster := clientcmdapi.NewCluster()
|
cluster := clientcmdapi.NewCluster()
|
||||||
cluster.Server = components.ApiServer.URL
|
cluster.Server = components.ApiServer.URL
|
||||||
cluster.InsecureSkipTLSVerify = true
|
cluster.InsecureSkipTLSVerify = true
|
||||||
|
Loading…
Reference in New Issue
Block a user