Skip to content

Commit

Permalink
fix(report): exit 1 when scan result has errors (future-architect#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
kotakanbe authored Apr 25, 2019
1 parent 533d05a commit 80566b9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions commands/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -424,5 +430,9 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}
}
}

if hasError {
return subcommands.ExitFailure
}

return subcommands.ExitSuccess
}

0 comments on commit 80566b9

Please sign in to comment.