mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
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
This commit is contained in:
commit
b40fed9eef
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user