1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

refactor: use GetFailurePolicy method (#3545)

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
Charles-Edouard Brétéché 2022-04-04 22:49:30 +02:00 committed by GitHub
parent 4b3de26433
commit 2f81c77850
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -132,6 +132,14 @@ func (s *Spec) BackgroundProcessingEnabled() bool {
return *s.Background
}
// GetFailurePolicy returns the failure policy to be applied
func (s *Spec) GetFailurePolicy() FailurePolicyType {
if s.FailurePolicy == nil {
return Fail
}
return *s.FailurePolicy
}
// GetValidationFailureAction returns the validation failure action to be applied
func (s *Spec) GetValidationFailureAction() ValidationFailureAction {
if s.ValidationFailureAction == "" {

View file

@ -435,7 +435,7 @@ func (m *webhookConfigManager) buildWebhooks(namespace string) (res []*webhook,
for _, p := range policies {
spec := p.GetSpec()
if spec.HasValidate() || spec.HasGenerate() {
if spec.FailurePolicy != nil && *spec.FailurePolicy == kyverno.Ignore {
if spec.GetFailurePolicy() == kyverno.Ignore {
m.mergeWebhook(validateIgnore, p, true)
} else {
m.mergeWebhook(validateFail, p, true)
@ -443,7 +443,7 @@ func (m *webhookConfigManager) buildWebhooks(namespace string) (res []*webhook,
}
if spec.HasMutate() || spec.HasVerifyImages() {
if spec.FailurePolicy != nil && *spec.FailurePolicy == kyverno.Ignore {
if spec.GetFailurePolicy() == kyverno.Ignore {
m.mergeWebhook(mutateIgnore, p, false)
} else {
m.mergeWebhook(mutateFail, p, false)