Skip to content

Commit

Permalink
Make TF_IN_AUTOMATION env var optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mss committed Oct 9, 2024
1 parent 373219a commit 20d3f4f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/exec/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
osexec "os/exec"
"path"
"slices"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -253,7 +254,9 @@ func ExecuteTerraform(info schema.ConfigAndStacksInfo) error {

// Set `TF_IN_AUTOMATION` ENV var to `true` to suppress verbose instructions after terraform commands
// https://developer.hashicorp.com/terraform/cli/config/environment-variables#tf_in_automation
info.ComponentEnvList = append(info.ComponentEnvList, "TF_IN_AUTOMATION=true")
if slices.IndexFunc(info.ComponentEnvList, func(s string) bool { return strings.HasPrefix(s, "TF_IN_AUTOMATION=") }) == -1 {
info.ComponentEnvList = append(info.ComponentEnvList, "TF_IN_AUTOMATION=true")
}

// Print ENV vars if they are found in the component's stack config
if len(info.ComponentEnvList) > 0 {
Expand Down

0 comments on commit 20d3f4f

Please sign in to comment.