1
0
Fork 0
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:
Yuvraj 2020-07-09 11:50:05 -07:00 committed by GitHub
parent 87fa77fbcc
commit ffe18aab86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -125,15 +125,18 @@ func validateArray(log logr.Logger, resourceArray, patternArray []interface{}, o
}
default:
// In all other cases - detect type and handle each array element with validateResourceElement
for i, patternElement := range patternArray {
currentPath := path + strconv.Itoa(i) + "/"
path, err := validateResourceElement(log, resourceArray[i], patternElement, originPattern, currentPath)
if err != nil {
return path, err
if len(resourceArray) >= len(patternArray) {
for i, patternElement := range patternArray {
currentPath := path + strconv.Itoa(i) + "/"
path, err := validateResourceElement(log, resourceArray[i], patternElement, originPattern, currentPath)
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
}