Skip to content

Commit

Permalink
Merge pull request #11 from linuxdaemon/windows-exe-match
Browse files Browse the repository at this point in the history
fix: Match terraform.exe in windows releases
  • Loading branch information
c4po authored Apr 28, 2022
2 parents b40374d + 57f640c commit fa4b768
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 fa4b768

Please sign in to comment.