mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +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:
		@@ -123,7 +123,7 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
 | 
				
			|||||||
	v := &metav1.APIVersions{}
 | 
						v := &metav1.APIVersions{}
 | 
				
			||||||
	err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do().Into(v)
 | 
						err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do().Into(v)
 | 
				
			||||||
	apiGroup := metav1.APIGroup{}
 | 
						apiGroup := metav1.APIGroup{}
 | 
				
			||||||
	if err == nil {
 | 
						if err == nil && len(v.Versions) != 0 {
 | 
				
			||||||
		apiGroup = apiVersionsToAPIGroup(v)
 | 
							apiGroup = apiVersionsToAPIGroup(v)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
 | 
						if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
 | 
				
			||||||
@@ -141,8 +141,10 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
 | 
				
			|||||||
		apiGroupList = &metav1.APIGroupList{}
 | 
							apiGroupList = &metav1.APIGroupList{}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// append the group retrieved from /api to the list
 | 
						// append the group retrieved from /api to the list if not empty
 | 
				
			||||||
 | 
						if len(v.Versions) != 0 {
 | 
				
			||||||
		apiGroupList.Groups = append(apiGroupList.Groups, apiGroup)
 | 
							apiGroupList.Groups = append(apiGroupList.Groups, apiGroup)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return apiGroupList, nil
 | 
						return apiGroupList, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user