Skip to content

Commit

Permalink
Fix a problem with exit code 2. If there is an exit code of 1, the fi…
Browse files Browse the repository at this point in the history
…nal result must be 1 because it indicates that there is an error, The priority oder is 1, 2, 0.
  • Loading branch information
jocgir committed Apr 28, 2017
1 parent 72d4a8d commit 1017989
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion configstack/running_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ func (this MultiError) ExitStatus() (int, error) {
for i := range this.Errors {
if code, err := shell.GetExitCode(this.Errors[i]); err != nil {
return -1, this
} else if code > exitCode {
} else if code == 1 || code == 2 && exitCode == 0 {
// The exit code 1 is more significant that the exit code 2 because it represents an error
// while 2 represent a warning.
exitCode = code
}
}
Expand Down
2 changes: 1 addition & 1 deletion configstack/stack_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (stack *Stack) planWithSummary(terragruntOptions *options.TerragruntOptions
return err
}

// Returns the handler and the list of results
// Returns the handler that will be executed after each completion of `terraform plan`
func getResultHandler(detailedExitCode bool, results *[]moduleResult, mutex *sync.Mutex) ModuleHandler {
return func(module TerraformModule, output string, err error) error {
inspectPlanResult(module, output)
Expand Down

0 comments on commit 1017989

Please sign in to comment.