1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

fix: skip creating event for an empty resource name (#7810)

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
Mariam Fahmy 2023-07-13 11:54:08 +03:00 committed by GitHub
parent 5577eb8708
commit 8c2335fe55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -60,9 +60,12 @@ func NewPolicyAppliedEvent(source Source, engineResponse engineapi.EngineRespons
} }
hasValidate := engineResponse.Policy().GetSpec().HasValidate() hasValidate := engineResponse.Policy().GetSpec().HasValidate()
if hasValidate { hasVerifyImages := engineResponse.Policy().GetSpec().HasVerifyImages()
hasMutate := engineResponse.Policy().GetSpec().HasMutate()
if hasValidate || hasVerifyImages {
fmt.Fprintf(&bldr, "%s: pass", res) fmt.Fprintf(&bldr, "%s: pass", res)
} else { } else if hasMutate {
fmt.Fprintf(&bldr, "%s is successfully mutated", res) fmt.Fprintf(&bldr, "%s is successfully mutated", res)
} }

View file

@ -16,7 +16,7 @@ func GenerateEvents(engineResponses []engineapi.EngineResponse, blocked bool) []
// - Some/All policies skipped // - Some/All policies skipped
// - report skipped event on resource // - report skipped event on resource
for _, er := range engineResponses { for _, er := range engineResponses {
if er.IsEmpty() { if er.IsEmpty() || er.Resource.GetName() == "" {
continue continue
} }
if !er.IsSuccessful() { if !er.IsSuccessful() {