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:
parent
4b3de26433
commit
2f81c77850
2 changed files with 10 additions and 2 deletions
|
@ -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 == "" {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue