add group priority to apiservice

This commit is contained in:
deads2k 2017-06-01 16:32:27 -04:00
parent 85832892b1
commit d13ad28420
13 changed files with 223 additions and 147 deletions

View File

@ -46746,7 +46746,8 @@
"required": [
"service",
"caBundle",
"priority"
"groupPriorityMinimum",
"versionPriority"
],
"properties": {
"caBundle": {
@ -46758,15 +46759,15 @@
"description": "Group is the API group name this server hosts",
"type": "string"
},
"groupPriorityMinimum": {
"description": "GroupPriorityMininum is the priority this group should have at least. Higher priority means that the group is prefered by clients over lower priority ones. Note that other versions of this group might specify even higher GroupPriorityMininum values such that the whole group gets a higher priority. The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10). The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo) We'd recommend something like: *.k8s.io (except extensions) at 18000 and PaaSes (OpenShift, Deis) are recommended to be in the 2000s",
"type": "integer",
"format": "int32"
},
"insecureSkipTLSVerify": {
"description": "InsecureSkipTLSVerify disables TLS certificate verification when communicating with this server. This is strongly discouraged. You should use the CABundle instead.",
"type": "boolean"
},
"priority": {
"description": "Priority controls the ordering of this API group in the overall discovery document that gets served. Client tools like `kubectl` use this ordering to derive preference, so this ordering mechanism is important. Values must be between 1 and 1000 The primary sort is based on priority, ordered lowest number to highest (10 before 20). The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo) We'd recommend something like: *.k8s.io (except extensions) at 100, extensions at 150 PaaSes (OpenShift, Deis) are recommended to be in the 200s",
"type": "integer",
"format": "int64"
},
"service": {
"description": "Service is a reference to the service for this API server. It must communicate on port 443 If the Service is nil, that means the handling for the API groupversion is handled locally on this server. The call will simply delegate to the normal handler chain to be fulfilled.",
"$ref": "#/definitions/io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.ServiceReference"
@ -46774,6 +46775,11 @@
"version": {
"description": "Version is the API version this server hosts. For example, \"v1\"",
"type": "string"
},
"versionPriority": {
"description": "VersionPriority controls the ordering of this API version inside of its group. Must be greater than zero. The primary sort is based on VersionPriority, ordered highest to lowest (20 before 10). The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo) Since it's inside of a group, the number can be small, probably in the 10s.",
"type": "integer",
"format": "int32"
}
}
},

View File

@ -149,7 +149,8 @@ func makeAPIService(gv schema.GroupVersion) *apiregistration.APIService {
Spec: apiregistration.APIServiceSpec{
Group: gv.Group,
Version: gv.Version,
Priority: 100,
GroupPriority: 1000,
VersionPriority: 10,
},
}
}
@ -180,7 +181,7 @@ func apiServicesToRegister(delegateAPIServer genericapiserver.DelegationTarget,
// but for now its a special case
// apps has to come last for compatibility with 1.5 kubectl clients
if apiService.Spec.Group == "apps" {
apiService.Spec.Priority = 110
apiService.Spec.GroupPriority = 1100
}
registration.AddAPIServiceToSync(apiService)

View File

@ -257,7 +257,8 @@ func (c *tprRegistrationController) handleVersionUpdate(groupVersion schema.Grou
Spec: apiregistration.APIServiceSpec{
Group: groupVersion.Group,
Version: groupVersion.Version,
Priority: 500, // TPRs should have relatively low priority
GroupPriority: 5000, // TPRs should have relatively low priority
VersionPriority: 20, // TPRs should have relatively low priority
},
})

View File

@ -86,7 +86,8 @@ func TestHandleVersionUpdate(t *testing.T) {
Spec: apiregistration.APIServiceSpec{
Group: "group.com",
Version: "v1",
Priority: 500,
GroupPriority: 5000,
VersionPriority: 20,
},
},
},
@ -123,7 +124,8 @@ func TestHandleVersionUpdate(t *testing.T) {
Spec: apiregistration.APIServiceSpec{
Group: "group.com",
Version: "v1",
Priority: 500,
GroupPriority: 5000,
VersionPriority: 20,
},
},
},

View File

@ -23,12 +23,12 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)
func SortedByGroup(servers []*APIService) [][]*APIService {
serversByPriority := ByPriority(servers)
sort.Sort(serversByPriority)
func SortedByGroupAndVersion(servers []*APIService) [][]*APIService {
serversByGroupPriority := ByGroupPriority(servers)
sort.Sort(serversByGroupPriority)
ret := [][]*APIService{}
for _, curr := range serversByPriority {
for _, curr := range serversByGroupPriority {
// check to see if we already have an entry for this group
existingIndex := -1
for j, groupInReturn := range ret {
@ -40,6 +40,7 @@ func SortedByGroup(servers []*APIService) [][]*APIService {
if existingIndex >= 0 {
ret[existingIndex] = append(ret[existingIndex], curr)
sort.Sort(ByVersionPriority(ret[existingIndex]))
continue
}
@ -49,15 +50,26 @@ func SortedByGroup(servers []*APIService) [][]*APIService {
return ret
}
type ByPriority []*APIService
type ByGroupPriority []*APIService
func (s ByPriority) Len() int { return len(s) }
func (s ByPriority) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s ByPriority) Less(i, j int) bool {
if s[i].Spec.Priority == s[j].Spec.Priority {
return s[i].Name < s[j].Name
func (s ByGroupPriority) Len() int { return len(s) }
func (s ByGroupPriority) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s ByGroupPriority) Less(i, j int) bool {
if s[i].Spec.GroupPriority != s[j].Spec.GroupPriority {
return s[i].Spec.GroupPriority < s[j].Spec.GroupPriority
}
return s[i].Spec.Priority < s[j].Spec.Priority
return s[i].Name < s[j].Name
}
type ByVersionPriority []*APIService
func (s ByVersionPriority) Len() int { return len(s) }
func (s ByVersionPriority) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s ByVersionPriority) Less(i, j int) bool {
if s[i].Spec.VersionPriority != s[j].Spec.VersionPriority {
return s[i].Spec.VersionPriority < s[j].Spec.VersionPriority
}
return s[i].Name < s[j].Name
}
// APIServiceNameToGroupVersion returns the GroupVersion for a given apiServiceName. The name

View File

@ -53,14 +53,19 @@ type APIServiceSpec struct {
// CABundle is a PEM encoded CA bundle which will be used to validate an API server's serving certificate.
CABundle []byte
// Priority controls the ordering of this API group in the overall discovery document that gets served.
// Client tools like `kubectl` use this ordering to derive preference, so this ordering mechanism is important.
// Values must be between 1 and 1000
// The primary sort is based on priority, ordered lowest number to highest (10 before 20).
// GroupPriorityMininum is the priority this group should have at least. Higher priority means that the group is prefered by clients over lower priority ones.
// Note that other versions of this group might specify even higher GroupPriorityMininum values such that the whole group gets a higher priority.
// The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10).
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
// We'd recommend something like: *.k8s.io (except extensions) at 100, extensions at 150
// PaaSes (OpenShift, Deis) are recommended to be in the 200s
Priority int64
// We'd recommend something like: *.k8s.io (except extensions) at 18000 and
// PaaSes (OpenShift, Deis) are recommended to be in the 2000s
GroupPriorityMinimum int32
// VersionPriority controls the ordering of this API version inside of its group. Must be greater than zero.
// The primary sort is based on VersionPriority, ordered highest to lowest (20 before 10).
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
// Since it's inside of a group, the number can be small, probably in the 10s.
VersionPriority int32
}
type ConditionStatus string

View File

@ -255,9 +255,12 @@ func (m *APIServiceSpec) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintGenerated(dAtA, i, uint64(len(m.CABundle)))
i += copy(dAtA[i:], m.CABundle)
}
dAtA[i] = 0x30
dAtA[i] = 0x38
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.Priority))
i = encodeVarintGenerated(dAtA, i, uint64(m.GroupPriorityMinimum))
dAtA[i] = 0x40
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.VersionPriority))
return i, nil
}
@ -402,7 +405,8 @@ func (m *APIServiceSpec) Size() (n int) {
l = len(m.CABundle)
n += 1 + l + sovGenerated(uint64(l))
}
n += 1 + sovGenerated(uint64(m.Priority))
n += 1 + sovGenerated(uint64(m.GroupPriorityMinimum))
n += 1 + sovGenerated(uint64(m.VersionPriority))
return n
}
@ -488,7 +492,8 @@ func (this *APIServiceSpec) String() string {
`Version:` + fmt.Sprintf("%v", this.Version) + `,`,
`InsecureSkipTLSVerify:` + fmt.Sprintf("%v", this.InsecureSkipTLSVerify) + `,`,
`CABundle:` + valueToStringGenerated(this.CABundle) + `,`,
`Priority:` + fmt.Sprintf("%v", this.Priority) + `,`,
`GroupPriorityMinimum:` + fmt.Sprintf("%v", this.GroupPriorityMinimum) + `,`,
`VersionPriority:` + fmt.Sprintf("%v", this.VersionPriority) + `,`,
`}`,
}, "")
return s
@ -1140,11 +1145,11 @@ func (m *APIServiceSpec) Unmarshal(dAtA []byte) error {
m.CABundle = []byte{}
}
iNdEx = postIndex
case 6:
case 7:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Priority", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field GroupPriorityMinimum", wireType)
}
m.Priority = 0
m.GroupPriorityMinimum = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenerated
@ -1154,7 +1159,26 @@ func (m *APIServiceSpec) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
m.Priority |= (int64(b) & 0x7F) << shift
m.GroupPriorityMinimum |= (int32(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 8:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field VersionPriority", wireType)
}
m.VersionPriority = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenerated
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.VersionPriority |= (int32(b) & 0x7F) << shift
if b < 0x80 {
break
}
@ -1479,56 +1503,58 @@ func init() {
}
var fileDescriptorGenerated = []byte{
// 801 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6f, 0x1b, 0x45,
0x14, 0xf6, 0x3a, 0xfe, 0x95, 0x49, 0x68, 0xc3, 0xa0, 0x0a, 0xcb, 0x12, 0xeb, 0x60, 0x24, 0x70,
0x11, 0xdd, 0x25, 0x05, 0xf1, 0x43, 0x9c, 0xba, 0x39, 0x54, 0x96, 0x5c, 0xa8, 0xc6, 0x51, 0x0f,
0x08, 0x89, 0x8e, 0xd7, 0x2f, 0xeb, 0xc1, 0xd9, 0x1f, 0xc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xd6, 0x26, 0x9e, 0xdb, 0xcf, 0x07, 0x00,
// 833 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x4f, 0xe3, 0x46,
0x14, 0x8e, 0x21, 0x21, 0x61, 0xa0, 0x0b, 0x9d, 0xee, 0x6a, 0x23, 0xd4, 0x1a, 0x9a, 0x4a, 0x2d,
0x5b, 0x69, 0xed, 0xb2, 0xad, 0xfa, 0x43, 0x3d, 0x61, 0x0e, 0x08, 0x09, 0x5a, 0x34, 0x41, 0x1c,
0xaa, 0x4a, 0xdd, 0x89, 0xf3, 0x30, 0xd3, 0xe0, 0xb1, 0x3b, 0x33, 0x8e, 0x94, 0xdb, 0xfe, 0x09,
0xbd, 0xf4, 0x7f, 0xe2, 0xd0, 0xc3, 0x1e, 0x39, 0x45, 0x25, 0x95, 0xfa, 0x47, 0xec, 0xa9, 0x9a,
0xf1, 0xd8, 0x0e, 0x49, 0x56, 0xbb, 0x42, 0x5c, 0xa2, 0xcc, 0x7b, 0xef, 0xfb, 0xbe, 0xf7, 0xde,
0x7c, 0x1e, 0xf4, 0x72, 0xf0, 0xbd, 0xf4, 0x58, 0xe2, 0x0f, 0xb2, 0x1e, 0x08, 0x0e, 0x0a, 0xa4,
0x3f, 0x04, 0xde, 0x4f, 0x84, 0x3f, 0x95, 0x78, 0x4e, 0xa3, 0x48, 0x40, 0x44, 0x55, 0x22, 0xfc,
0x74, 0x10, 0xf9, 0x34, 0x65, 0x52, 0xff, 0x08, 0x88, 0x98, 0x54, 0x82, 0x2a, 0x96, 0x70, 0x7f,
0xb8, 0xd7, 0x03, 0x45, 0xf7, 0xfc, 0x08, 0x38, 0x08, 0xaa, 0xa0, 0xef, 0xa5, 0x22, 0x51, 0x09,
0xfe, 0x2e, 0x27, 0xf2, 0x34, 0xd1, 0x6f, 0x15, 0x91, 0x97, 0x0e, 0x22, 0x4f, 0x13, 0x79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, 0x1d, 0xe3, 0xb6, 0xe3, 0x07, 0x70, 0x5b,
0xf9, 0x28, 0x54, 0x4f, 0x72, 0x19, 0x92, 0x64, 0x4a, 0xb3, 0x03, 0x68, 0x73, 0xd6, 0x25, 0xd8,
0x47, 0xab, 0x9c, 0xc6, 0x20, 0x53, 0x1a, 0x16, 0xef, 0xd6, 0x87, 0x96, 0x66, 0xf5, 0xa7, 0x22,
0x41, 0xaa, 0x1a, 0xbc, 0x83, 0xea, 0xfa, 0x60, 0xfd, 0x53, 0x3e, 0xc8, 0xba, 0x96, 0x98, 0x4c,
0xf0, 0xec, 0xfa, 0xd6, 0xad, 0xbd, 0xbe, 0x75, 0x6b, 0x37, 0xb7, 0x6e, 0xed, 0xd5, 0xc4, 0x75,
0xae, 0x27, 0xae, 0xf3, 0x7a, 0xe2, 0x3a, 0xff, 0x4c, 0x5c, 0xe7, 0xcf, 0x7f, 0xdd, 0xda, 0x2f,
0x4d, 0x3b, 0xc5, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x2d, 0x18, 0xd6, 0x36, 0x08, 0x00,
0x00,
}

View File

@ -91,14 +91,19 @@ message APIServiceSpec {
// CABundle is a PEM encoded CA bundle which will be used to validate an API server's serving certificate.
optional bytes caBundle = 5;
// Priority controls the ordering of this API group in the overall discovery document that gets served.
// Client tools like `kubectl` use this ordering to derive preference, so this ordering mechanism is important.
// Values must be between 1 and 1000
// The primary sort is based on priority, ordered lowest number to highest (10 before 20).
// GroupPriorityMininum is the priority this group should have at least. Higher priority means that the group is prefered by clients over lower priority ones.
// Note that other versions of this group might specify even higher GroupPriorityMininum values such that the whole group gets a higher priority.
// The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10).
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
// We'd recommend something like: *.k8s.io (except extensions) at 100, extensions at 150
// PaaSes (OpenShift, Deis) are recommended to be in the 200s
optional int64 priority = 6;
// We'd recommend something like: *.k8s.io (except extensions) at 18000 and
// PaaSes (OpenShift, Deis) are recommended to be in the 2000s
optional int32 groupPriorityMinimum = 7;
// VersionPriority controls the ordering of this API version inside of its group. Must be greater than zero.
// The primary sort is based on VersionPriority, ordered highest to lowest (20 before 10).
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
// Since it's inside of a group, the number can be small, probably in the 10s.
optional int32 versionPriority = 8;
}
// APIServiceStatus contains derived information about an API server

View File

@ -53,14 +53,22 @@ type APIServiceSpec struct {
// CABundle is a PEM encoded CA bundle which will be used to validate an API server's serving certificate.
CABundle []byte `json:"caBundle" protobuf:"bytes,5,opt,name=caBundle"`
// Priority controls the ordering of this API group in the overall discovery document that gets served.
// Client tools like `kubectl` use this ordering to derive preference, so this ordering mechanism is important.
// Values must be between 1 and 1000
// The primary sort is based on priority, ordered lowest number to highest (10 before 20).
// GroupPriorityMininum is the priority this group should have at least. Higher priority means that the group is prefered by clients over lower priority ones.
// Note that other versions of this group might specify even higher GroupPriorityMininum values such that the whole group gets a higher priority.
// The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10).
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
// We'd recommend something like: *.k8s.io (except extensions) at 100, extensions at 150
// PaaSes (OpenShift, Deis) are recommended to be in the 200s
Priority int64 `json:"priority" protobuf:"varint,6,opt,name=priority"`
// We'd recommend something like: *.k8s.io (except extensions) at 18000 and
// PaaSes (OpenShift, Deis) are recommended to be in the 2000s
GroupPriorityMinimum int32 `json:"groupPriorityMinimum" protobuf:"varint,7,opt,name=groupPriorityMinimum"`
// VersionPriority controls the ordering of this API version inside of its group. Must be greater than zero.
// The primary sort is based on VersionPriority, ordered highest to lowest (20 before 10).
// The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo)
// Since it's inside of a group, the number can be small, probably in the 10s.
VersionPriority int32 `json:"versionPriority" protobuf:"varint,8,opt,name=versionPriority"`
// leaving this here so everyone remembers why proto index 6 is skipped
// Priority int64 `json:"priority" protobuf:"varint,6,opt,name=priority"`
}
type ConditionStatus string

View File

@ -142,7 +142,8 @@ func autoConvert_v1beta1_APIServiceSpec_To_apiregistration_APIServiceSpec(in *AP
out.Version = in.Version
out.InsecureSkipTLSVerify = in.InsecureSkipTLSVerify
out.CABundle = *(*[]byte)(unsafe.Pointer(&in.CABundle))
out.Priority = in.Priority
out.GroupPriorityMinimum = in.GroupPriorityMinimum
out.VersionPriority = in.VersionPriority
return nil
}
@ -161,7 +162,8 @@ func autoConvert_apiregistration_APIServiceSpec_To_v1beta1_APIServiceSpec(in *ap
} else {
out.CABundle = *(*[]byte)(unsafe.Pointer(&in.CABundle))
}
out.Priority = in.Priority
out.GroupPriorityMinimum = in.GroupPriorityMinimum
out.VersionPriority = in.VersionPriority
return nil
}

View File

@ -58,9 +58,11 @@ func ValidateAPIService(apiService *apiregistration.APIService) field.ErrorList
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "version"), apiService.Spec.Version, errString))
}
if apiService.Spec.Priority <= 0 || apiService.Spec.Priority > 1000 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "priority"), apiService.Spec.Priority, "priority must be positive and less than 1000"))
if apiService.Spec.GroupPriorityMinimum <= 0 || apiService.Spec.GroupPriorityMinimum > 10000 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "groupPriorityMinimum"), apiService.Spec.GroupPriorityMinimum, "must be positive and less than 10000"))
}
if apiService.Spec.VersionPriority <= 0 || apiService.Spec.VersionPriority > 1000 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "versionPriority"), apiService.Spec.VersionPriority, "must be positive and less than 1000"))
}
if apiService.Spec.Service == nil {

View File

@ -18,6 +18,7 @@ package apiserver
import (
"errors"
"fmt"
"net/http"
apierrors "k8s.io/apimachinery/pkg/api/errors"
@ -73,7 +74,7 @@ func (r *apisHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
apiServicesByGroup := apiregistrationapi.SortedByGroup(apiServices)
apiServicesByGroup := apiregistrationapi.SortedByGroupAndVersion(apiServices)
for _, apiGroupServers := range apiServicesByGroup {
// skip the legacy group
if len(apiGroupServers[0].Spec.Group) == 0 {
@ -91,11 +92,12 @@ func (r *apisHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// convertToDiscoveryAPIGroup takes apiservices in a single group and returns a discovery compatible object.
// if none of the services are available, it will return nil.
func convertToDiscoveryAPIGroup(apiServices []*apiregistrationapi.APIService) *metav1.APIGroup {
apiServicesByGroup := apiregistrationapi.SortedByGroup(apiServices)[0]
apiServicesByGroup := apiregistrationapi.SortedByGroupAndVersion(apiServices)[0]
var discoveryGroup *metav1.APIGroup
for _, apiService := range apiServicesByGroup {
fmt.Printf("#### %#v\n", apiService)
if !apiregistrationapi.IsAPIServiceConditionTrue(apiService, apiregistrationapi.Available) {
continue
}

View File

@ -62,7 +62,7 @@ func TestAPIs(t *testing.T) {
},
Group: "foo",
Version: "v1",
Priority: 10,
GroupPriorityMinimum: 10,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -79,7 +79,7 @@ func TestAPIs(t *testing.T) {
},
Group: "bar",
Version: "v1",
Priority: 11,
GroupPriorityMinimum: 11,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -133,7 +133,8 @@ func TestAPIs(t *testing.T) {
},
Group: "foo",
Version: "v1",
Priority: 20,
GroupPriorityMinimum: 1,
VersionPriority: 15,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -150,7 +151,7 @@ func TestAPIs(t *testing.T) {
},
Group: "bar",
Version: "v2",
Priority: 11,
GroupPriorityMinimum: 11,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -167,7 +168,8 @@ func TestAPIs(t *testing.T) {
},
Group: "foo",
Version: "v2",
Priority: 1,
GroupPriorityMinimum: 20,
VersionPriority: 10,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -184,7 +186,7 @@ func TestAPIs(t *testing.T) {
},
Group: "bar",
Version: "v1",
Priority: 11,
GroupPriorityMinimum: 11,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -338,7 +340,8 @@ func TestAPIGroup(t *testing.T) {
},
Group: "foo",
Version: "v1",
Priority: 20,
GroupPriorityMinimum: 1,
VersionPriority: 15,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -355,7 +358,7 @@ func TestAPIGroup(t *testing.T) {
},
Group: "bar",
Version: "v2",
Priority: 11,
GroupPriorityMinimum: 11,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -372,7 +375,8 @@ func TestAPIGroup(t *testing.T) {
},
Group: "foo",
Version: "v2",
Priority: 1,
GroupPriorityMinimum: 20,
VersionPriority: 10,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
@ -389,7 +393,7 @@ func TestAPIGroup(t *testing.T) {
},
Group: "bar",
Version: "v1",
Priority: 11,
GroupPriorityMinimum: 11,
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{