1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

fix: remove skip increment when resource not found in cli apply (#9282) (#9284)

* fix: remove skip increment when resource not found in cli apply



* fix test



---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
gcp-cherry-pick-bot[bot] 2023-12-26 22:26:44 +01:00 committed by GitHub
parent 41e7bd40a8
commit 3501cde249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 17 deletions

View file

@ -82,7 +82,7 @@ func Test_NamespaceSelector(t *testing.T) {
fail: 1,
warn: 0,
err: 0,
skip: 2,
skip: 0,
},
},
{
@ -98,7 +98,7 @@ func Test_NamespaceSelector(t *testing.T) {
fail: 1,
warn: 0,
err: 0,
skip: 4,
skip: 0,
},
},
}

View file

@ -38,10 +38,8 @@ func (rc *ResultCounts) addEngineResponse(auditWarn bool, response engineapi.Eng
scored := annotations.Scored(policy.GetAnnotations())
for _, rule := range autogen.ComputeRules(policy) {
if rule.HasValidate() || rule.HasVerifyImageChecks() || rule.HasVerifyImages() {
ruleFoundInEngineResponse := false
for _, valResponseRule := range response.PolicyResponse.Rules {
if rule.Name == valResponseRule.Name() {
ruleFoundInEngineResponse = true
switch valResponseRule.Status() {
case engineapi.RuleStatusPass:
rc.pass++
@ -64,9 +62,6 @@ func (rc *ResultCounts) addEngineResponse(auditWarn bool, response engineapi.Eng
continue
}
}
if !ruleFoundInEngineResponse {
rc.skip++
}
}
}
}
@ -79,10 +74,8 @@ func (rc *ResultCounts) addGenerateResponse(auditWarn bool, resPath string, resp
}
policy := genericPolicy.GetPolicy().(kyvernov1.PolicyInterface)
for _, policyRule := range autogen.ComputeRules(policy) {
ruleFoundInEngineResponse := false
for _, ruleResponse := range response.PolicyResponse.Rules {
if policyRule.Name == ruleResponse.Name() {
ruleFoundInEngineResponse = true
if ruleResponse.Status() == engineapi.RuleStatusPass {
rc.pass++
} else {
@ -95,9 +88,6 @@ func (rc *ResultCounts) addGenerateResponse(auditWarn bool, resPath string, resp
continue
}
}
if !ruleFoundInEngineResponse {
rc.skip++
}
}
}
@ -118,10 +108,8 @@ func (rc *ResultCounts) addMutateResponse(resourcePath string, response engineap
}
printMutatedRes := false
for _, policyRule := range autogen.ComputeRules(policy) {
ruleFoundInEngineResponse := false
for _, mutateResponseRule := range response.PolicyResponse.Rules {
if policyRule.Name == mutateResponseRule.Name() {
ruleFoundInEngineResponse = true
if mutateResponseRule.Status() == engineapi.RuleStatusPass {
rc.pass++
printMutatedRes = true
@ -135,9 +123,6 @@ func (rc *ResultCounts) addMutateResponse(resourcePath string, response engineap
continue
}
}
if !ruleFoundInEngineResponse {
rc.skip++
}
}
return printMutatedRes
}