From cfac4198903d1ddbd1f985c311fbae5ed3727763 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Wed, 6 May 2020 14:55:29 +0100 Subject: [PATCH] terraform/discovery: Find exe on Windows explicitly --- internal/terraform/discovery/discovery.go | 4 ++-- internal/terraform/discovery/discovery_unix.go | 5 +++++ internal/terraform/discovery/discovery_windows.go | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 internal/terraform/discovery/discovery_unix.go create mode 100644 internal/terraform/discovery/discovery_windows.go diff --git a/internal/terraform/discovery/discovery.go b/internal/terraform/discovery/discovery.go index 06f58a1de..7b62c3ee8 100644 --- a/internal/terraform/discovery/discovery.go +++ b/internal/terraform/discovery/discovery.go @@ -10,9 +10,9 @@ type DiscoveryFunc func() (string, error) type Discovery struct{} func (d *Discovery) LookPath() (string, error) { - path, err := exec.LookPath("terraform") + path, err := exec.LookPath(executableName) if err != nil { - return "", fmt.Errorf("unable to find terraform: %s", err) + return "", fmt.Errorf("unable to find %s: %s", executableName, err) } return path, nil } diff --git a/internal/terraform/discovery/discovery_unix.go b/internal/terraform/discovery/discovery_unix.go new file mode 100644 index 000000000..52e3003f8 --- /dev/null +++ b/internal/terraform/discovery/discovery_unix.go @@ -0,0 +1,5 @@ +// +build !windows + +package discovery + +const executableName = "terraform" diff --git a/internal/terraform/discovery/discovery_windows.go b/internal/terraform/discovery/discovery_windows.go new file mode 100644 index 000000000..c86b8361a --- /dev/null +++ b/internal/terraform/discovery/discovery_windows.go @@ -0,0 +1,3 @@ +package discovery + +const executableName = "terraform.exe"