1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-01-20 18:52:16 +00:00
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
This commit is contained in:
Jim Bugwadia 2021-10-02 16:57:40 -07:00
parent e0e6074afc
commit 89d1e4afab
3 changed files with 4 additions and 5 deletions

View file

@ -12,9 +12,8 @@ import (
"github.com/kyverno/kyverno/pkg/engine/wildcards" "github.com/kyverno/kyverno/pkg/engine/wildcards"
) )
type PatternError struct { type PatternError struct {
Err error Err error
Path string Path string
Skip bool Skip bool
} }

View file

@ -459,7 +459,7 @@ func (v *validator) validatePatterns(resource unstructured.Unstructured) *respon
if v.pattern != nil { if v.pattern != nil {
if err := validate.MatchPattern(v.log, resource.Object, v.pattern); err != nil { if err := validate.MatchPattern(v.log, resource.Object, v.pattern); err != nil {
if pe, ok := err.(*validate.PatternError); ok{ if pe, ok := err.(*validate.PatternError); ok {
v.log.V(3).Info("validation error", "path", pe.Path, "error", err.Error()) v.log.V(3).Info("validation error", "path", pe.Path, "error", err.Error())
if pe.Path == "" { if pe.Path == "" {
return ruleResponse(v.rule, v.buildErrorMessage(err, ""), response.RuleStatusError) return ruleResponse(v.rule, v.buildErrorMessage(err, ""), response.RuleStatusError)

View file

@ -60,7 +60,7 @@ func (v *Validate) Validate() (string, error) {
func (v *Validate) validateElements() error { func (v *Validate) validateElements() error {
count := validationElemCount(v.rule) count := validationElemCount(v.rule)
if count == 0 { if count == 0 {
return fmt.Errorf("one of pattern, anyPattern, deny, foreach must be specified") return fmt.Errorf("one of pattern, anyPattern, deny, foreach must be specified")
} }
@ -106,7 +106,7 @@ func (v *Validate) validateForEach(foreach *kyverno.ForEachValidation) error {
} }
count := foreachElemCount(foreach) count := foreachElemCount(foreach)
if count == 0 { if count == 0 {
return fmt.Errorf("one of pattern, anyPattern, deny must be specified") return fmt.Errorf("one of pattern, anyPattern, deny must be specified")
} }