1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-29 10:55:05 +00:00

Fix issue where CLI test command ignores failures (#5189)

Closes #5187

The test command was resetting the return value to "pass", even if it
was already marked failed, in some cases. This solves by moving the
"pass" into an else-if clause.

Signed-off-by: Eric Miller <eric.miller@instructure.com>

Signed-off-by: Eric Miller <eric.miller@instructure.com>
Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
This commit is contained in:
Eric Miller 2022-11-11 01:19:49 -06:00 committed by GitHub
parent 6091af6fba
commit 001db94d87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,7 +67,7 @@ applying 1 policy to 2 resources...
kyverno test .
Executing limit-containers-per-pod...
applying 1 policy to 4 resources...
applying 1 policy to 4 resources...
# POLICY RULE RESOURCE RESULT
@ -84,7 +84,7 @@ Test Summary: 4 tests passed and 0 tests failed
kyverno test . --test-case-selector "policy=disallow-latest-tag, rule=require-image-tag, resource=test-require-image-tag-pass"
Executing test-simple...
applying 1 policy to 1 resource...
applying 1 policy to 1 resource...
# POLICY RULE RESOURCE RESULT
@ -787,9 +787,7 @@ func getAndCompareResource(path string, engineResource unstructured.Unstructured
if err != nil {
log.Log.V(3).Info(resourceType+" mismatch", "error", err.Error())
status = "fail"
}
if matched == "" {
} else if matched == "" {
status = "pass"
}
return status