Skip to content

Commit

Permalink
Use a constant for the version of admin-helper
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
anjannath authored and praveenkumar committed Jun 23, 2022
1 parent 8c279e9 commit 8ac31f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/crc/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions pkg/crc/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -73,6 +74,10 @@ func GetPodmanVersion() string {
return podmanVersion
}

func GetAdminHelperVersion() string {
return crcAdminHelperVersion
}

func IsOkdBuild() bool {
return okdBuild == "true"
}
Expand Down

0 comments on commit 8ac31f8

Please sign in to comment.