mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-08 18:15:48 +00:00
allowing users to skip policy validation when mutating resources (#2365)
* allowing users to skip policy validation when mutating resources * fix unit test issue * fix comment
This commit is contained in:
parent
511db4372b
commit
12530619ce
6 changed files with 37 additions and 3 deletions
|
@ -1518,6 +1518,11 @@ spec:
|
|||
type: array
|
||||
type: object
|
||||
type: array
|
||||
schemaValidation:
|
||||
description: SchemaValidation skips policy validation checks. Optional.
|
||||
The default value is set to "true", it must be set to "false" to
|
||||
disable the validation checks.
|
||||
type: boolean
|
||||
validationFailureAction:
|
||||
description: ValidationFailureAction controls if a validation policy
|
||||
rule failure should disallow the admission review request (enforce),
|
||||
|
|
|
@ -1519,6 +1519,11 @@ spec:
|
|||
type: array
|
||||
type: object
|
||||
type: array
|
||||
schemaValidation:
|
||||
description: SchemaValidation skips policy validation checks. Optional.
|
||||
The default value is set to "true", it must be set to "false" to
|
||||
disable the validation checks.
|
||||
type: boolean
|
||||
validationFailureAction:
|
||||
description: ValidationFailureAction controls if a validation policy
|
||||
rule failure should disallow the admission review request (enforce),
|
||||
|
|
|
@ -956,6 +956,11 @@ spec:
|
|||
type: array
|
||||
type: object
|
||||
type: array
|
||||
schemaValidation:
|
||||
description: SchemaValidation skips policy validation checks. Optional.
|
||||
The default value is set to "true", it must be set to "false" to
|
||||
disable the validation checks.
|
||||
type: boolean
|
||||
validationFailureAction:
|
||||
description: ValidationFailureAction controls if a validation policy rule failure should disallow the admission review request (enforce), or allow (audit) the admission review request and report an error in a policy report. Optional. The default value is "audit".
|
||||
type: string
|
||||
|
@ -2705,6 +2710,11 @@ spec:
|
|||
type: array
|
||||
type: object
|
||||
type: array
|
||||
schemaValidation:
|
||||
description: SchemaValidation skips policy validation checks. Optional.
|
||||
The default value is set to "true", it must be set to "false" to
|
||||
disable the validation checks.
|
||||
type: boolean
|
||||
validationFailureAction:
|
||||
description: ValidationFailureAction controls if a validation policy rule failure should disallow the admission review request (enforce), or allow (audit) the admission review request and report an error in a policy report. Optional. The default value is "audit".
|
||||
type: string
|
||||
|
|
|
@ -943,6 +943,9 @@ spec:
|
|||
type: array
|
||||
type: object
|
||||
type: array
|
||||
schemaValidation:
|
||||
description: SchemaValidation skips policy validation checks. Optional.The default value is set to "true", it must be set to "false" to disable the validation checks.
|
||||
type: boolean
|
||||
validationFailureAction:
|
||||
description: ValidationFailureAction controls if a validation policy rule failure should disallow the admission review request (enforce), or allow (audit) the admission review request and report an error in a policy report. Optional. The default value is "audit".
|
||||
type: string
|
||||
|
@ -2664,6 +2667,9 @@ spec:
|
|||
type: array
|
||||
type: object
|
||||
type: array
|
||||
schemaValidation:
|
||||
description: SchemaValidation skips policy validation checks. Optional.The default value is set to "true", it must be set to "false" to disable the validation checks.
|
||||
type: boolean
|
||||
validationFailureAction:
|
||||
description: ValidationFailureAction controls if a validation policy rule failure should disallow the admission review request (enforce), or allow (audit) the admission review request and report an error in a policy report. Optional. The default value is "audit".
|
||||
type: string
|
||||
|
|
|
@ -54,6 +54,11 @@ type Spec struct {
|
|||
// uses variables that are only available in the admission review request (e.g. user name).
|
||||
// +optional
|
||||
Background *bool `json:"background,omitempty" yaml:"background,omitempty"`
|
||||
|
||||
// SchemaValidation skips policy validation checks.
|
||||
// Optional. The default value is set to "true", it must be set to "false" to disable the validation checks.
|
||||
// +optional
|
||||
SchemaValidation *bool `json:"schemaValidation,omitempty" yaml:"schemaValidation,omitempty"`
|
||||
}
|
||||
|
||||
// Rule defines a validation, mutation, or generation control for matching resources.
|
||||
|
|
|
@ -167,10 +167,13 @@ func (o *Controller) ValidatePolicyMutation(policy v1.ClusterPolicy) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = o.ValidateResource(*patchedResource.DeepCopy(), "", kind)
|
||||
if err != nil {
|
||||
return err
|
||||
if policy.Spec.SchemaValidation == nil || *policy.Spec.SchemaValidation {
|
||||
err = o.ValidateResource(*patchedResource.DeepCopy(), "", kind)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue