Skip to content

Commit

Permalink
Move logic to platforms.go
Browse files Browse the repository at this point in the history
  • Loading branch information
codeman9 committed Feb 22, 2022
1 parent 5e607df commit c2dcfb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 6 additions & 1 deletion platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ var platforms = map[string]string{"darwin": "macos", "linux": "ubuntu1404", "win
// GetPlatform returns a Bazel CI-compatible platform identifier for the current operating system.
// TODO(fweikert): raise an error for unsupported platforms
func GetPlatform() string {
return platforms[runtime.GOOS]
platform := platforms[runtime.GOOS]
arch := runtime.GOARCH
if platform == "macos" && arch == "arm64" {
platform = "macos_arm64"
}
return platform
}

// DetermineExecutableFilenameSuffix returns the extension for binaries on the current operating system.
Expand Down
8 changes: 1 addition & 7 deletions repositories/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"log"
"runtime"
"strings"

"github.com/bazelbuild/bazelisk/httputil"
Expand Down Expand Up @@ -237,11 +236,6 @@ func (gcs *GCSRepo) GetLastGreenCommit(bazeliskHome string, downstreamGreen bool
// DownloadAtCommit downloads a Bazel binary built at the given commit into the specified location and returns the absolute path.
func (gcs *GCSRepo) DownloadAtCommit(commit, destDir, destFile string) (string, error) {
log.Printf("Using unreleased version at commit %s", commit)
platform := platforms.GetPlatform()
arch := runtime.GOARCH
if platform == "macos" && arch == "arm64" {
platform = "macos_arm64"
}
url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platform, commit)
url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platforms.GetPlatform(), commit)
return httputil.DownloadBinary(url, destDir, destFile)
}

0 comments on commit c2dcfb3

Please sign in to comment.