From 4acb99df52d7b89a599c057037769bd499658a4f Mon Sep 17 00:00:00 2001 From: dutianpeng Date: Fri, 3 Feb 2017 11:33:06 +0800 Subject: [PATCH] Check whether apiversions is empty --- .../src/k8s.io/client-go/discovery/discovery_client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/staging/src/k8s.io/client-go/discovery/discovery_client.go b/staging/src/k8s.io/client-go/discovery/discovery_client.go index 9d39c0270e2..f05fb42bd69 100644 --- a/staging/src/k8s.io/client-go/discovery/discovery_client.go +++ b/staging/src/k8s.io/client-go/discovery/discovery_client.go @@ -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 }