1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 15:37:19 +00:00

log non fatal parsing errors (#11932) (#11949)

* log non fatal parsing errors



* log at the error level



* add check for nil



* add check for nil



---------

Signed-off-by: Your Name <you@example.com>
Co-authored-by: Ammar Yasser <aerosound161@gmail.com>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
gcp-cherry-pick-bot[bot] 2025-01-20 08:05:08 +00:00 committed by GitHub
parent d581e9ad79
commit 896c7d15c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -403,6 +403,11 @@ func (c *ApplyCommandConfig) loadPolicies(skipInvalidPolicies SkippedInvalidPoli
}
for _, policyYaml := range policyYamls {
loaderResults, err := policy.Load(fs, "", policyYaml)
if loaderResults != nil && loaderResults.NonFatalErrors != nil {
for _, err := range loaderResults.NonFatalErrors {
log.Log.Error(err.Error, "Non-fatal parsing error for single document")
}
}
if err != nil {
continue
}
@ -412,6 +417,11 @@ func (c *ApplyCommandConfig) loadPolicies(skipInvalidPolicies SkippedInvalidPoli
}
} else {
loaderResults, err := policy.Load(nil, "", path)
if loaderResults != nil && loaderResults.NonFatalErrors != nil {
for _, err := range loaderResults.NonFatalErrors {
log.Log.Error(err.Error, "Non-fatal parsing error for single document")
}
}
if err != nil {
log.Log.V(3).Info("skipping invalid YAML file", "path", path, "error", err)
} else {