mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Require match condition version only if matchConditions are specified
This commit is contained in:
parent
3240e2b28e
commit
a000af25ff
@ -512,7 +512,9 @@ func ValidateWebhookConfiguration(fldPath *field.Path, c *api.WebhookConfigurati
|
|||||||
|
|
||||||
switch c.MatchConditionSubjectAccessReviewVersion {
|
switch c.MatchConditionSubjectAccessReviewVersion {
|
||||||
case "":
|
case "":
|
||||||
allErrs = append(allErrs, field.Required(fldPath.Child("matchConditionSubjectAccessReviewVersion"), ""))
|
if len(c.MatchConditions) > 0 {
|
||||||
|
allErrs = append(allErrs, field.Required(fldPath.Child("matchConditionSubjectAccessReviewVersion"), "required if match conditions are specified"))
|
||||||
|
}
|
||||||
case "v1":
|
case "v1":
|
||||||
_ = &v1.SubjectAccessReview{}
|
_ = &v1.SubjectAccessReview{}
|
||||||
default:
|
default:
|
||||||
|
@ -1438,6 +1438,7 @@ func TestValidateAuthorizationConfiguration(t *testing.T) {
|
|||||||
ConnectionInfo: api.WebhookConnectionInfo{
|
ConnectionInfo: api.WebhookConnectionInfo{
|
||||||
Type: "InClusterConfig",
|
Type: "InClusterConfig",
|
||||||
},
|
},
|
||||||
|
MatchConditions: []api.WebhookMatchCondition{{Expression: "true"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user