From 87e31e0b4687df81665bc36a7d59a88fdbe06f26 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Wed, 14 Apr 2021 14:25:59 +0200 Subject: [PATCH] feat: create BinaryFileName constant --- tfinstall/download.go | 2 +- tfinstall/look_path.go | 2 +- tfinstall/tfinstall.go | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tfinstall/download.go b/tfinstall/download.go index 30e15e87..2fad9dbc 100644 --- a/tfinstall/download.go +++ b/tfinstall/download.go @@ -92,7 +92,7 @@ func downloadWithVerification(ctx context.Context, tfVersion string, installDir return "", err } - return filepath.Join(tfDir, "terraform"), nil + return filepath.Join(tfDir, BinaryFileName), nil } // verifySumsSignature downloads SHA256SUMS and SHA256SUMS.sig and verifies diff --git a/tfinstall/look_path.go b/tfinstall/look_path.go index 2ebec09b..3650b0f6 100644 --- a/tfinstall/look_path.go +++ b/tfinstall/look_path.go @@ -18,7 +18,7 @@ func LookPath() *LookPathOption { } func (opt *LookPathOption) ExecPath(context.Context) (string, error) { - p, err := exec.LookPath("terraform") + p, err := exec.LookPath(BinaryFileName) if err != nil { if notFoundErr, ok := err.(*exec.Error); ok && notFoundErr.Err == exec.ErrNotFound { log.Printf("[WARN] could not locate a terraform executable on system path; continuing") diff --git a/tfinstall/tfinstall.go b/tfinstall/tfinstall.go index 3dd69635..e0c60e8b 100644 --- a/tfinstall/tfinstall.go +++ b/tfinstall/tfinstall.go @@ -7,6 +7,10 @@ import ( "strings" ) +const ( + BinaryFileName = "terraform" +) + const baseURL = "https://releases.hashicorp.com/terraform" type ExecPathFinder interface {