Skip to content

Commit

Permalink
feat(terraform): explicit error for unknown exit code in terraform plan
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianGottinger authored and DenisBiondic committed Apr 23, 2024
1 parent 1b2838c commit eba0de4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/recipes/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,17 @@ func (tf *terraformWrapper) plan(isDestroy bool) (string, error) {
// 1 = Error
// 2 = Succeeded with non-empty diff (changes present)
var planIsDirty bool
switch getExitCode(err) {
switch exitCode := getExitCode(err); exitCode {
case 0:
planIsDirty = false
break
case 1:
return "", internal.ReturnErrorOrPanic(err)
case 2:
planIsDirty = true
break
default:
return "", internal.ReturnErrorOrPanic(err)
return "", internal.ReturnErrorOrPanic(fmt.Errorf("unexpected exit code %d in terraform plan command %w", exitCode, err))
}

err = tf.persistPlanInAdditionalFormatsOnDisk(plaintextPlanOutput, localTerraformRelativePlanFilePath)
Expand Down

0 comments on commit eba0de4

Please sign in to comment.