Unverified Commit d8928efc authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #59342 from nikhita/discovery-corev1-order

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. core/v1 should be first in the discovery order Currently, `core/v1` is at the end of the discovery order. See https://github.com/kubernetes/kubernetes/issues/42521#issuecomment-360517775. **Release note**: ```release-note NONE ``` /assign sttts liggitt
parents 5320cdee 45950fdb
...@@ -145,9 +145,9 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err ...@@ -145,9 +145,9 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
apiGroupList = &metav1.APIGroupList{} apiGroupList = &metav1.APIGroupList{}
} }
// append the group retrieved from /api to the list if not empty // prepend the group retrieved from /api to the list if not empty
if len(v.Versions) != 0 { if len(v.Versions) != 0 {
apiGroupList.Groups = append(apiGroupList.Groups, apiGroup) apiGroupList.Groups = append([]metav1.APIGroup{apiGroup}, apiGroupList.Groups...)
} }
return apiGroupList, nil return apiGroupList, nil
} }
......
...@@ -74,6 +74,17 @@ func TestGetServerGroupsWithV1Server(t *testing.T) { ...@@ -74,6 +74,17 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
"v1", "v1",
}, },
} }
case "/apis":
obj = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Name: "extensions",
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "extensions/v1beta1"},
},
},
},
}
default: default:
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
return return
...@@ -95,8 +106,8 @@ func TestGetServerGroupsWithV1Server(t *testing.T) { ...@@ -95,8 +106,8 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
groupVersions := metav1.ExtractGroupVersions(apiGroupList) groupVersions := metav1.ExtractGroupVersions(apiGroupList)
if !reflect.DeepEqual(groupVersions, []string{"v1"}) { if !reflect.DeepEqual(groupVersions, []string{"v1", "extensions/v1beta1"}) {
t.Errorf("expected: %q, got: %q", []string{"v1"}, groupVersions) t.Errorf("expected: %q, got: %q", []string{"v1", "extensions/v1beta1"}, groupVersions)
} }
} }
......
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