Skip to content

Commit

Permalink
feat: add support for env defined binary (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: Lewin Chan <8480608+quotidian-ennui@users.noreply.github.com>
  • Loading branch information
quotidian-ennui and quotidian-ennui committed Feb 17, 2024
1 parent 29d45b2 commit 2c17fcc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion parser/binary-parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package parser
import (
"encoding/json"
"fmt"
"os"
"os/exec"

tfjson "github.com/hashicorp/terraform-json"
Expand All @@ -13,7 +14,11 @@ type BinaryParser struct {
}

func (j BinaryParser) Parse() (tfjson.Plan, error) {
cmd := exec.Command("terraform", "show", "-json", j.fileName)
tfbinary := "terraform"
if tfoverride, ok := os.LookupEnv("TF_BINARY"); ok {
tfbinary = tfoverride
}
cmd := exec.Command(tfbinary, "show", "-json", j.fileName)
output, err := cmd.CombinedOutput()
if err != nil {
return tfjson.Plan{}, fmt.Errorf(
Expand Down

0 comments on commit 2c17fcc

Please sign in to comment.