mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-05 15:37:19 +00:00
* 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:
parent
d581e9ad79
commit
896c7d15c5
1 changed files with 10 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue