core/v1 should be first in discovery order

Currently, core/v1 is in the end of the discovery order.

Since core/v1 is special, it should be in the beginning.

Kubernetes-commit: 45950fdb750d7ac12cec3b9ef3487baa99a40401
This commit is contained in:
Nikhita Raghunath 2018-02-05 15:04:29 +05:30 committed by Kubernetes Publisher
parent e2d750fcad
commit c4f02185e3
2 changed files with 15 additions and 4 deletions

View File

@ -145,9 +145,9 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
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 {
apiGroupList.Groups = append(apiGroupList.Groups, apiGroup)
apiGroupList.Groups = append([]metav1.APIGroup{apiGroup}, apiGroupList.Groups...)
}
return apiGroupList, nil
}

View File

@ -74,6 +74,17 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
"v1",
},
}
case "/apis":
obj = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Name: "extensions",
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "extensions/v1beta1"},
},
},
},
}
default:
w.WriteHeader(http.StatusNotFound)
return
@ -95,8 +106,8 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
groupVersions := metav1.ExtractGroupVersions(apiGroupList)
if !reflect.DeepEqual(groupVersions, []string{"v1"}) {
t.Errorf("expected: %q, got: %q", []string{"v1"}, groupVersions)
if !reflect.DeepEqual(groupVersions, []string{"v1", "extensions/v1beta1"}) {
t.Errorf("expected: %q, got: %q", []string{"v1", "extensions/v1beta1"}, groupVersions)
}
}