support arch in downloadURL

pull/10774/head
Ilya Zuyev 2021-03-19 13:55:11 -07:00
parent 7e45721c82
commit 275f743e9f
5 changed files with 17 additions and 11 deletions

View File

@ -23,6 +23,7 @@ import (
"encoding/hex"
"fmt"
"io/ioutil"
"runtime"
"testing"
retryablehttp "github.com/hashicorp/go-retryablehttp"
@ -56,7 +57,7 @@ func TestReleasesJSON(t *testing.T) {
fmt.Printf("Checking release: %s\n", r.Name)
for platform, sha := range r.Checksums {
fmt.Printf("Checking SHA for %s.\n", platform)
actualSha, err := getSHAFromURL(util.GetBinaryDownloadURL(r.Name, platform))
actualSha, err := getSHAFromURL(util.GetBinaryDownloadURL(r.Name, platform, runtime.GOARCH))
if err != nil {
t.Errorf("Error calculating SHA for %s-%s. Error: %v", r.Name, platform, err)
continue

View File

@ -29,7 +29,7 @@ import (
)
const (
downloadURL = "https://storage.googleapis.com/minikube/releases/%s/minikube-%s-amd64%s"
downloadURL = "https://storage.googleapis.com/minikube/releases/%s/minikube-%s-%s%s"
)
// CalculateSizeInMB returns the number of MB in the human readable string
@ -62,13 +62,13 @@ func ConvertUnsignedBytesToMB(byteSize uint64) int64 {
return int64(byteSize / units.MiB)
}
// GetBinaryDownloadURL returns a suitable URL for the platform
func GetBinaryDownloadURL(version, platform string) string {
// GetBinaryDownloadURL returns a suitable URL for the platform and arch
func GetBinaryDownloadURL(version, platform, arch string) string {
switch platform {
case "windows":
return fmt.Sprintf(downloadURL, version, platform, ".exe")
return fmt.Sprintf(downloadURL, version, platform, arch, ".exe")
default:
return fmt.Sprintf(downloadURL, version, platform, "")
return fmt.Sprintf(downloadURL, version, platform, arch, "")
}
}

View File

@ -20,6 +20,7 @@ import (
"io/ioutil"
"os"
"os/user"
"runtime"
"syscall"
"testing"
@ -38,7 +39,7 @@ func TestGetBinaryDownloadURL(t *testing.T) {
}
for _, tt := range testData {
url := GetBinaryDownloadURL(tt.version, tt.platform)
url := GetBinaryDownloadURL(tt.version, tt.platform, runtime.GOARCH)
if url != tt.expectedURL {
t.Fatalf("Expected '%s' but got '%s'", tt.expectedURL, url)
}

View File

@ -43,7 +43,7 @@ func installRelease(version string) (f *os.File, err error) {
}
tf.Close()
url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS)
url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS, runtime.GOARCH)
if err := retry.Expo(func() error { return getter.GetFile(tf.Name(), url) }, 3*time.Second, Minutes(3)); err != nil {
return tf, err
@ -79,8 +79,12 @@ func TestRunningBinaryUpgrade(t *testing.T) {
// Should be a version from the last 6 months
legacyVersion := "v1.6.2"
if KicDriver() {
// v1.8.0 would be selected, but: https://github.com/kubernetes/minikube/issues/8740
legacyVersion = "v1.9.0"
if arm64Platform() {
legacyVersion = "v1.17.0"
} else {
// v1.8.0 would be selected, but: https://github.com/kubernetes/minikube/issues/8740
legacyVersion = "v1.9.0"
}
}
tf, err := installRelease(legacyVersion)

View File

@ -48,7 +48,7 @@ func TestStress(t *testing.T) {
}
oldPath := fmt.Sprintf("../../out/minikube-%s", *upgradeFrom)
url := util.GetBinaryDownloadURL(*upgradeFrom, runtime.GOOS)
url := util.GetBinaryDownloadURL(*upgradeFrom, runtime.GOOS, runtime.GOARCH)
t.Logf("Downloading minikube %s from %s", *upgradeFrom, url)
err = getter.GetFile(oldPath, url)
if err != nil {