mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
Resolve Kyverno panic when sync the generate request (#975)
* handle validate error panic * return error in validate array * fix error log message Co-authored-by: Yuvraj <yuvraj@neualto.com>
This commit is contained in:
parent
87fa77fbcc
commit
ffe18aab86
1 changed files with 9 additions and 6 deletions
|
@ -125,15 +125,18 @@ func validateArray(log logr.Logger, resourceArray, patternArray []interface{}, o
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// In all other cases - detect type and handle each array element with validateResourceElement
|
// In all other cases - detect type and handle each array element with validateResourceElement
|
||||||
for i, patternElement := range patternArray {
|
if len(resourceArray) >= len(patternArray) {
|
||||||
currentPath := path + strconv.Itoa(i) + "/"
|
for i, patternElement := range patternArray {
|
||||||
path, err := validateResourceElement(log, resourceArray[i], patternElement, originPattern, currentPath)
|
currentPath := path + strconv.Itoa(i) + "/"
|
||||||
if err != nil {
|
path, err := validateResourceElement(log, resourceArray[i], patternElement, originPattern, currentPath)
|
||||||
return path, err
|
if err != nil {
|
||||||
|
return path, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
return "", fmt.Errorf("Validate Array failed, array length mismatch, resource Array len is %d and pattern Array len is %d", len(resourceArray), len(patternArray))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue