From 8ac31f8c581043862f7a8b262369662301902f74 Mon Sep 17 00:00:00 2001 From: Anjan Nath Date: Thu, 23 Jun 2022 13:32:46 +0530 Subject: [PATCH] Use a constant for the version of admin-helper earlier when parsing the version from the download URL the version is changed implicitly based on the tag used which doesn't reflect the version that is set on the binary for tags we prefer to use the github style with a v infront for the version in the binary we prefer to not use the v so tag v0.0.11 corresponds to version 0.0.11, using the crcAdminHelperVersion constant makes it explicit when bumping admin-helper version this fixes the following error on linux ``` unexpected version of the crc-admin-helper executable: crc-admin-helper-linux version mismatch: v0.0.11 expected but 0.0.11 found in the cache ``` --- pkg/crc/cache/cache.go | 3 +-- pkg/crc/constants/constants.go | 4 ++-- pkg/crc/version/version.go | 5 +++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/crc/cache/cache.go b/pkg/crc/cache/cache.go index 60c7083cf1..45c92a2304 100644 --- a/pkg/crc/cache/cache.go +++ b/pkg/crc/cache/cache.go @@ -4,7 +4,6 @@ import ( "fmt" "io/ioutil" "os" - "path" "path/filepath" "strings" @@ -70,7 +69,7 @@ func getVersionGeneric(executablePath string, args ...string) (string, error) { func NewAdminHelperCache() *Cache { url := constants.GetAdminHelperURL() - version := path.Base(path.Dir(url)) + version := version.GetAdminHelperVersion() return New(constants.GetAdminHelperExecutable(), url, version, diff --git a/pkg/crc/constants/constants.go b/pkg/crc/constants/constants.go index df617be3bd..6cf8c217b0 100644 --- a/pkg/crc/constants/constants.go +++ b/pkg/crc/constants/constants.go @@ -24,7 +24,7 @@ const ( DaemonLogFile = "crcd.log" CrcLandingPageURL = "https://console.redhat.com/openshift/create/local" // #nosec G101 DefaultPodmanURLBase = "https://storage.googleapis.com/libpod-master-releases" - DefaultAdminHelperCliBase = "https://github.com/code-ready/admin-helper/releases/download/v0.0.11" + DefaultAdminHelperURLBase = "https://github.com/code-ready/admin-helper/releases/download/v%s/%s" CRCMacTrayDownloadURL = "https://github.com/code-ready/tray-electron/releases/download/%s/crc-tray-macos.tar.gz" CRCWindowsTrayDownloadURL = "https://github.com/code-ready/tray-electron/releases/download/%s/crc-tray-windows.zip" DefaultContext = "admin" @@ -57,7 +57,7 @@ func GetAdminHelperExecutable() string { } func GetAdminHelperURLForOs(os string) string { - return fmt.Sprintf("%s/%s", DefaultAdminHelperCliBase, GetAdminHelperExecutableForOs(os)) + return fmt.Sprintf(DefaultAdminHelperURLBase, version.GetAdminHelperVersion(), GetAdminHelperExecutableForOs(os)) } func GetAdminHelperURL() string { diff --git a/pkg/crc/version/version.go b/pkg/crc/version/version.go index 2f23e30bb5..8a36905628 100644 --- a/pkg/crc/version/version.go +++ b/pkg/crc/version/version.go @@ -44,6 +44,7 @@ const ( releaseInfoLink = "https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/release-info.json" // Tray version to be embedded in executable crcTrayElectronVersion = "1.2.7" + crcAdminHelperVersion = "0.0.11" ) type CrcReleaseInfo struct { @@ -73,6 +74,10 @@ func GetPodmanVersion() string { return podmanVersion } +func GetAdminHelperVersion() string { + return crcAdminHelperVersion +} + func IsOkdBuild() bool { return okdBuild == "true" }