From 649ee4f2d0b987f2e84aca2c9227f5ab4804a225 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Tue, 16 Jul 2019 14:34:02 -0400 Subject: [PATCH] Clarify accepted versions skew requirements, update field documentation --- pkg/apis/admission/types.go | 4 ++-- pkg/apis/admissionregistration/validation/validation.go | 6 +++++- staging/src/k8s.io/api/admission/v1/types.go | 8 ++++---- staging/src/k8s.io/api/admission/v1beta1/types.go | 6 +++--- .../pkg/apis/apiextensions/validation/validation.go | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pkg/apis/admission/types.go b/pkg/apis/admission/types.go index 52534dceb01..411ac03598a 100644 --- a/pkg/apis/admission/types.go +++ b/pkg/apis/admission/types.go @@ -95,10 +95,10 @@ type AdmissionRequest struct { Operation Operation // UserInfo is information about the requesting user UserInfo authentication.UserInfo - // Object is the object from the incoming request prior to default values being applied + // Object is the object from the incoming request. // +optional Object runtime.Object - // OldObject is the existing object. Only populated for UPDATE requests. + // OldObject is the existing object. Only populated for DELETE and UPDATE requests. // +optional OldObject runtime.Object // DryRun indicates that modifications will definitely not be persisted for this request. diff --git a/pkg/apis/admissionregistration/validation/validation.go b/pkg/apis/admissionregistration/validation/validation.go index 78209889d49..8bfb006b7aa 100644 --- a/pkg/apis/admissionregistration/validation/validation.go +++ b/pkg/apis/admissionregistration/validation/validation.go @@ -152,6 +152,10 @@ func validateRule(rule *admissionregistration.Rule, fldPath *field.Path, allowSu return allErrors } +// AcceptedAdmissionReviewVersions contains the list of AdmissionReview versions the *prior* version of the API server understands. +// 1.15: server understands v1beta1; accepted versions are ["v1beta1"] +// 1.16: server understands v1, v1beta1; accepted versions are ["v1beta1"] +// 1.17: server understands v1, v1beta1; accepted versions are ["v1","v1beta1"] var AcceptedAdmissionReviewVersions = []string{v1beta1.SchemeGroupVersion.Version} func isAcceptedAdmissionReviewVersion(v string) bool { @@ -188,7 +192,7 @@ func validateAdmissionReviewVersions(versions []string, requireRecognizedVersion if requireRecognizedVersion && !hasAcceptedVersion { allErrors = append(allErrors, field.Invalid( fldPath, versions, - fmt.Sprintf("none of the versions accepted by this server. accepted version(s) are %v", + fmt.Sprintf("must include at least one of %v", strings.Join(AcceptedAdmissionReviewVersions, ", ")))) } } diff --git a/staging/src/k8s.io/api/admission/v1/types.go b/staging/src/k8s.io/api/admission/v1/types.go index 464253daea9..e03907a1f19 100644 --- a/staging/src/k8s.io/api/admission/v1/types.go +++ b/staging/src/k8s.io/api/admission/v1/types.go @@ -82,7 +82,7 @@ type AdmissionRequest struct { RequestSubResource string `json:"requestSubResource,omitempty" protobuf:"bytes,15,opt,name=requestSubResource"` // Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and - // rely on the server to generate the name. If that is the case, this method will return the empty string. + // rely on the server to generate the name. If that is the case, this field will contain an empty string. // +optional Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"` // Namespace is the namespace associated with the request (if any). @@ -93,10 +93,10 @@ type AdmissionRequest struct { Operation Operation `json:"operation" protobuf:"bytes,7,opt,name=operation"` // UserInfo is information about the requesting user UserInfo authenticationv1.UserInfo `json:"userInfo" protobuf:"bytes,8,opt,name=userInfo"` - // Object is the object from the incoming request prior to default values being applied + // Object is the object from the incoming request. // +optional Object runtime.RawExtension `json:"object,omitempty" protobuf:"bytes,9,opt,name=object"` - // OldObject is the existing object. Only populated for UPDATE requests. + // OldObject is the existing object. Only populated for DELETE and UPDATE requests. // +optional OldObject runtime.RawExtension `json:"oldObject,omitempty" protobuf:"bytes,10,opt,name=oldObject"` // DryRun indicates that modifications will definitely not be persisted for this request. @@ -115,7 +115,7 @@ type AdmissionRequest struct { // AdmissionResponse describes an admission response. type AdmissionResponse struct { // UID is an identifier for the individual request/response. - // This should be copied over from the corresponding AdmissionRequest. + // This must be copied over from the corresponding AdmissionRequest. UID types.UID `json:"uid" protobuf:"bytes,1,opt,name=uid"` // Allowed indicates whether or not the admission request was permitted. diff --git a/staging/src/k8s.io/api/admission/v1beta1/types.go b/staging/src/k8s.io/api/admission/v1beta1/types.go index e968720e71a..2cb9ea55a38 100644 --- a/staging/src/k8s.io/api/admission/v1beta1/types.go +++ b/staging/src/k8s.io/api/admission/v1beta1/types.go @@ -82,7 +82,7 @@ type AdmissionRequest struct { RequestSubResource string `json:"requestSubResource,omitempty" protobuf:"bytes,15,opt,name=requestSubResource"` // Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and - // rely on the server to generate the name. If that is the case, this method will return the empty string. + // rely on the server to generate the name. If that is the case, this field will contain an empty string. // +optional Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"` // Namespace is the namespace associated with the request (if any). @@ -93,10 +93,10 @@ type AdmissionRequest struct { Operation Operation `json:"operation" protobuf:"bytes,7,opt,name=operation"` // UserInfo is information about the requesting user UserInfo authenticationv1.UserInfo `json:"userInfo" protobuf:"bytes,8,opt,name=userInfo"` - // Object is the object from the incoming request prior to default values being applied + // Object is the object from the incoming request. // +optional Object runtime.RawExtension `json:"object,omitempty" protobuf:"bytes,9,opt,name=object"` - // OldObject is the existing object. Only populated for UPDATE requests. + // OldObject is the existing object. Only populated for DELETE and UPDATE requests. // +optional OldObject runtime.RawExtension `json:"oldObject,omitempty" protobuf:"bytes,10,opt,name=oldObject"` // DryRun indicates that modifications will definitely not be persisted for this request. diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go index 983d14fc7d9..43bb7350f81 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go @@ -298,7 +298,7 @@ func validateConversionReviewVersions(versions []string, requireRecognizedVersio if requireRecognizedVersion && !hasAcceptedVersion { allErrs = append(allErrs, field.Invalid( fldPath, versions, - fmt.Sprintf("none of the versions accepted by this server. accepted version(s) are %v", + fmt.Sprintf("must include at least one of %v", strings.Join(acceptedConversionReviewVersion, ", ")))) } }