From d793bbba55132c32fae52ee0214c42825d1b57a9 Mon Sep 17 00:00:00 2001 From: Florian Weikert Date: Wed, 17 Aug 2022 14:05:39 +0200 Subject: [PATCH] Show error for unsupported arm64 platforms Fixes https://github.com/bazelbuild/bazel/issues/16061 --- platforms/platforms.go | 12 ++++++++---- repositories/gcs.go | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/platforms/platforms.go b/platforms/platforms.go index 7a7f3415..e1ec38cc 100644 --- a/platforms/platforms.go +++ b/platforms/platforms.go @@ -31,13 +31,17 @@ var supportedPlatforms = map[string]*platform{ // GetPlatform returns a Bazel CI-compatible platform identifier for the current operating system. // TODO(fweikert): raise an error for unsupported platforms -func GetPlatform() string { +func GetPlatform() (string, error) { platform := supportedPlatforms[runtime.GOOS] arch := runtime.GOARCH - if arch == "arm64" && platform.HasArm64Binary { - return platform.Name + "_arm64" + if arch == "arm64" { + if platform.HasArm64Binary { + return platform.Name + "_arm64", nil + } + return "", fmt.Errorf("arm64 %s is unsupported", runtime.GOOS) } - return platform.Name + + return platform.Name, nil } // DetermineExecutableFilenameSuffix returns the extension for binaries on the current operating system. diff --git a/repositories/gcs.go b/repositories/gcs.go index 170f172a..b5243b62 100644 --- a/repositories/gcs.go +++ b/repositories/gcs.go @@ -236,7 +236,11 @@ 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) - url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platforms.GetPlatform(), commit) + platform, err := platforms.GetPlatform() + if err != nil { + return "", err + } + url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platform, commit) return httputil.DownloadBinary(url, destDir, destFile) }