Commit b40fed9e authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #40906 from du2016/checkAPIVersions

Automatic merge from submit-queue (batch tested with PRs 40906, 40924, 40938, 40902, 40911) Check whether apiversions is empty What this PR does / why we need it: #39719 check whether apisversions get from /api is empty Special notes for your reviewer: @caesarxuchao
parents d6a4394b 4acb99df
......@@ -123,7 +123,7 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
v := &metav1.APIVersions{}
err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do().Into(v)
apiGroup := metav1.APIGroup{}
if err == nil {
if err == nil && len(v.Versions) != 0 {
apiGroup = apiVersionsToAPIGroup(v)
}
if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
......@@ -141,8 +141,10 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
apiGroupList = &metav1.APIGroupList{}
}
// append the group retrieved from /api to the list
apiGroupList.Groups = append(apiGroupList.Groups, apiGroup)
// append the group retrieved from /api to the list if not empty
if len(v.Versions) != 0 {
apiGroupList.Groups = append(apiGroupList.Groups, apiGroup)
}
return apiGroupList, nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment