diff --git a/pkg/apis/rbac/v1alpha1/types.go b/pkg/apis/rbac/v1alpha1/types.go index 0863dfbf588..5157ec776f8 100644 --- a/pkg/apis/rbac/v1alpha1/types.go +++ b/pkg/apis/rbac/v1alpha1/types.go @@ -54,9 +54,8 @@ type Subject struct { // Kind of object being referenced. Values defined by this API group are "User", "Group", and "ServiceAccount". // If the Authorizer does not recognized the kind value, the Authorizer should report an error. Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"` - // APIVersion holds the API group and version of the referenced object. For non-object references such as "Group" and "User" this is - // expected to be API version of this API group. For example "rbac/v1alpha1". - APIVersion string `json:"apiVersion" protobuf:"bytes,2,opt.name=apiVersion"` + // APIVersion holds the API group and version of the referenced object. + APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,2,opt.name=apiVersion"` // Name of the object being referenced. Name string `json:"name" protobuf:"bytes,3,opt,name=name"` // Namespace of the referenced object. If the object kind is non-namespace, such as "User" or "Group", and this value is not empty diff --git a/pkg/apis/rbac/validation/validation.go b/pkg/apis/rbac/validation/validation.go index 4a384e65ee4..c43f733037b 100644 --- a/pkg/apis/rbac/validation/validation.go +++ b/pkg/apis/rbac/validation/validation.go @@ -105,9 +105,6 @@ func validateRoleBindingSubject(subject rbac.Subject, isNamespaced bool, fldPath if len(subject.Name) == 0 { allErrs = append(allErrs, field.Required(fldPath.Child("name"), "")) } - if len(subject.APIVersion) != 0 { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("apiVersion"), subject.APIVersion)) - } switch subject.Kind { case rbac.ServiceAccountKind: diff --git a/pkg/apis/rbac/validation/validation_test.go b/pkg/apis/rbac/validation/validation_test.go index c513729a7b5..9a62f3bfb55 100644 --- a/pkg/apis/rbac/validation/validation_test.go +++ b/pkg/apis/rbac/validation/validation_test.go @@ -96,15 +96,6 @@ func TestValidateRoleBinding(t *testing.T) { T: field.ErrorTypeInvalid, F: "subjects[0].name", }, - "forbidden fields": { - A: rbac.RoleBinding{ - ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master"}, - RoleRef: api.ObjectReference{Namespace: "master", Name: "valid"}, - Subjects: []rbac.Subject{{Name: "subject", Kind: rbac.ServiceAccountKind, APIVersion: "foo"}}, - }, - T: field.ErrorTypeForbidden, - F: "subjects[0].apiVersion", - }, "missing subject name": { A: rbac.RoleBinding{ ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault, Name: "master"},