Skip to content

Commit

Permalink
fix: Match terraform.exe in windows releases
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
Aspen Barnes committed Apr 27, 2022
1 parent b40374d commit 57f640c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions internal/releaseapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ func (c *Client) downloadBuild(build Build, checkSha256Sum string) (string, erro
return "", errors.Wrap(err, "could not unzip release archive")
}

binaryName := build.archiveBinaryName()
for _, f := range zipReader.File {
if filepath.Base(f.Name) != "terraform" {
if filepath.Base(f.Name) != binaryName {
continue
}

Expand Down Expand Up @@ -261,8 +262,20 @@ func cachedExecutablePath(cacheDir string, b Build) string {
return filepath.Join(cacheDir, b.executableName())
}

func (b *Build) archiveBinaryName() string {
extension := ""
if b.OS == "windows" {
extension = ".exe"
}
return "terraform" + extension
}

func (b *Build) executableName() string {
return fmt.Sprintf("terraform_%s_%s_%s", b.Version.String(), b.OS, b.Arch)
extension := ""
if b.OS == "windows" {
extension = ".exe"
}
return fmt.Sprintf("terraform_%s_%s_%s%s", b.Version.String(), b.OS, b.Arch, extension)
}

func (b *Build) zipFileName() string {
Expand Down

0 comments on commit 57f640c

Please sign in to comment.