mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
move error message to log (#9238)
* move error message to log Signed-off-by: anushkamittal2001 <anushka@nirmata.com> * Add rephrased error logs Signed-off-by: anushkamittal2001 <anushka@nirmata.com> * silence errors Signed-off-by: anushkamittal2001 <anushka@nirmata.com> * modify tests for silence errors Signed-off-by: anushkamittal2001 <anushka@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: anushkamittal2001 <anushka@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: Jim Bugwadia <jim@nirmata.com> Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
d102abeb99
commit
cf80b66a69
1 changed files with 6 additions and 3 deletions
|
@ -86,6 +86,7 @@ func Command() *cobra.Command {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.SilenceErrors = true
|
||||
printSkippedAndInvalidPolicies(out, skipInvalidPolicies)
|
||||
if applyCommandConfig.PolicyReport {
|
||||
printReport(out, responses, applyCommandConfig.AuditWarn)
|
||||
|
@ -461,12 +462,14 @@ func printViolations(out io.Writer, rc *processor.ResultCounts) {
|
|||
}
|
||||
|
||||
func exit(rc *processor.ResultCounts, warnExitCode int, warnNoPassed bool) error {
|
||||
if rc.Fail() > 0 || rc.Error() > 0 {
|
||||
return fmt.Errorf("exit as fail or error count > 0")
|
||||
if rc.Fail() > 0 {
|
||||
return fmt.Errorf("exit as there are policy violations")
|
||||
} else if rc.Error() > 0 {
|
||||
return fmt.Errorf("exit as there are policy errors")
|
||||
} else if rc.Warn() > 0 && warnExitCode != 0 {
|
||||
return fmt.Errorf("exit as warnExitCode is %d", warnExitCode)
|
||||
} else if rc.Pass() == 0 && warnNoPassed {
|
||||
return fmt.Errorf("exit as warnExitCode is %d", warnExitCode)
|
||||
return fmt.Errorf("exit as no objects satisfied policy")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue