From 80566b91abf82a427686b44b6221753088f88e7c Mon Sep 17 00:00:00 2001 From: Kota Kanbe Date: Thu, 25 Apr 2019 15:09:29 +0900 Subject: [PATCH] fix(report): exit 1 when scan result has errors (#804) --- commands/report.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/commands/report.go b/commands/report.go index 9e1e61e7..9f9847cb 100644 --- a/commands/report.go +++ b/commands/report.go @@ -330,15 +330,21 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{} util.Log.Infof("Loaded: %s", dir) var res models.ScanResults + hasError := false for _, r := range loaded { if len(r.Errors) == 0 { res = append(res, r) } else { - util.Log.Warnf("Ignored since errors occurred during scanning: %s", - r.ServerName) + util.Log.Errorf("Ignored since errors occurred during scanning: %s, err: %v", + r.ServerName, r.Errors) + hasError = true } } + if len(res) == 0 { + return subcommands.ExitFailure + } + for _, r := range res { util.Log.Debugf("%s: %s", r.ServerInfo(), @@ -424,5 +430,9 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{} } } + if hasError { + return subcommands.ExitFailure + } + return subcommands.ExitSuccess }