Skip to content

Commit

Permalink
steampipe check exit code should be the number of alerts. Closes #498
Browse files Browse the repository at this point in the history
  • Loading branch information
tyagiparth authored Jun 15, 2021
1 parent 2cf7e40 commit e2e7322
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func runCheckCmd(cmd *cobra.Command, args []string) {

// for now we execute controls synchronously
// Execute returns the number of failures
executionTree.Execute(ctx, client)
failures += executionTree.Execute(ctx, client)
err = DisplayControlResults(ctx, executionTree)
utils.FailOnError(err)
}
Expand Down
8 changes: 5 additions & 3 deletions control/execute/result_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,21 @@ func (r *ResultGroup) Execute(ctx context.Context, client *db.Client) int {
// it may not matter, as we display results in order
// it is only an issue if there are dependencies, in which case we must run in dependency order

var errors = 0
var failures = 0
for _, controlRun := range r.ControlRuns {
select {
case <-ctx.Done():
controlRun.SetError(ctx.Err())
default:
controlRun.Start(ctx, client)
failures += controlRun.Summary.Alarm
failures += controlRun.Summary.Error
}
}
for _, child := range r.Groups {
errors += child.Execute(ctx, client)
failures += child.Execute(ctx, client)
}
return errors
return failures
}

// GetGroupByName finds a child ResultGroup with a specific name
Expand Down

0 comments on commit e2e7322

Please sign in to comment.