mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-08 10:04:25 +00:00
refactor: reduce policy mutations (#3550)
Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
parent
e716daa22e
commit
f77220ad66
1 changed files with 15 additions and 15 deletions
|
@ -21,22 +21,22 @@ func GenerateJSONPatchesForDefaults(policy kyverno.PolicyInterface, log logr.Log
|
|||
var patches [][]byte
|
||||
var updateMsgs []string
|
||||
spec := policy.GetSpec()
|
||||
// default 'ValidationFailureAction'
|
||||
if patch, updateMsg := defaultvalidationFailureAction(spec, log); patch != nil {
|
||||
patches = append(patches, patch)
|
||||
updateMsgs = append(updateMsgs, updateMsg)
|
||||
}
|
||||
// default 'Background'
|
||||
if patch, updateMsg := defaultBackgroundFlag(spec, log); patch != nil {
|
||||
patches = append(patches, patch)
|
||||
updateMsgs = append(updateMsgs, updateMsg)
|
||||
}
|
||||
if patch, updateMsg := defaultFailurePolicy(spec, log); patch != nil {
|
||||
patches = append(patches, patch)
|
||||
updateMsgs = append(updateMsgs, updateMsg)
|
||||
}
|
||||
// if autogenInternals is enabled, we don't mutate rules in the webhook
|
||||
// if autogenInternals is enabled, we don't mutate most of the policy fields
|
||||
if !toggle.AutogenInternals() {
|
||||
// default 'ValidationFailureAction'
|
||||
if patch, updateMsg := defaultvalidationFailureAction(spec, log); patch != nil {
|
||||
patches = append(patches, patch)
|
||||
updateMsgs = append(updateMsgs, updateMsg)
|
||||
}
|
||||
// default 'Background'
|
||||
if patch, updateMsg := defaultBackgroundFlag(spec, log); patch != nil {
|
||||
patches = append(patches, patch)
|
||||
updateMsgs = append(updateMsgs, updateMsg)
|
||||
}
|
||||
if patch, updateMsg := defaultFailurePolicy(spec, log); patch != nil {
|
||||
patches = append(patches, patch)
|
||||
updateMsgs = append(updateMsgs, updateMsg)
|
||||
}
|
||||
patch, errs := GeneratePodControllerRule(policy, log)
|
||||
if len(errs) > 0 {
|
||||
var errMsgs []string
|
||||
|
|
Loading…
Add table
Reference in a new issue