Skip to content

Commit

Permalink
Version: use GetBundleVersion for any type of preset
Browse files Browse the repository at this point in the history
This pr is a refactor to use `GetBundleVersion` for any type of
preset bundle and return the correct bundle version. After this
PR we don't need `GetPodmanVersion()` and it removes it.
  • Loading branch information
praveenkumar committed Aug 25, 2022
1 parent e6985c7 commit 40230ae
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/crc/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func defaultVersion(preset crcPreset.Preset) *version {
Version: crcversion.GetCRCVersion(),
Commit: crcversion.GetCommitSha(),
OpenshiftVersion: crcversion.GetBundleVersion(preset),
PodmanVersion: crcversion.GetPodmanVersion(),
PodmanVersion: crcversion.GetBundleVersion(crcPreset.Podman),
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/api/api_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestVersion(t *testing.T) {
CrcVersion: version.GetCRCVersion(),
OpenshiftVersion: version.GetBundleVersion(preset.OpenShift),
CommitSha: version.GetCommitSha(),
PodmanVersion: version.GetPodmanVersion(),
PodmanVersion: version.GetBundleVersion(preset.Podman),
},
vr,
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/api/api_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ var testCases = []testCase{
// version
{
request: get("version"),
response: jSon(fmt.Sprintf(`{"CrcVersion":"%s","CommitSha":"%s","OpenshiftVersion":"%s","PodmanVersion":"%s"}`, version.GetCRCVersion(), version.GetCommitSha(), version.GetBundleVersion(preset.OpenShift), version.GetPodmanVersion())),
response: jSon(fmt.Sprintf(`{"CrcVersion":"%s","CommitSha":"%s","OpenshiftVersion":"%s","PodmanVersion":"%s"}`, version.GetCRCVersion(), version.GetCommitSha(), version.GetBundleVersion(preset.OpenShift), version.GetBundleVersion(preset.Podman))),
},

// version never fails
Expand Down
3 changes: 2 additions & 1 deletion pkg/crc/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/code-ready/crc/pkg/crc/machine"
"github.com/code-ready/crc/pkg/crc/machine/types"
"github.com/code-ready/crc/pkg/crc/preflight"
"github.com/code-ready/crc/pkg/crc/preset"
"github.com/code-ready/crc/pkg/crc/version"
)

Expand Down Expand Up @@ -125,7 +126,7 @@ func (h *Handler) GetVersion(c *context) error {
CrcVersion: version.GetCRCVersion(),
CommitSha: version.GetCommitSha(),
OpenshiftVersion: version.GetBundleVersion(crcConfig.GetPreset(h.Config)),
PodmanVersion: version.GetPodmanVersion(),
PodmanVersion: version.GetBundleVersion(preset.Podman),
})
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ func defaultBundleForOs(preset crcpreset.Preset) map[string]string {
switch preset {
case crcpreset.Podman:
return map[string]string{
"darwin": fmt.Sprintf("crc_podman_vfkit_%s_%s.crcbundle", version.GetPodmanVersion(), runtime.GOARCH),
"linux": fmt.Sprintf("crc_podman_libvirt_%s_%s.crcbundle", version.GetPodmanVersion(), runtime.GOARCH),
"windows": fmt.Sprintf("crc_podman_hyperv_%s_%s.crcbundle", version.GetPodmanVersion(), runtime.GOARCH),
"darwin": fmt.Sprintf("crc_podman_vfkit_%s_%s.crcbundle", version.GetBundleVersion(preset), runtime.GOARCH),
"linux": fmt.Sprintf("crc_podman_libvirt_%s_%s.crcbundle", version.GetBundleVersion(preset), runtime.GOARCH),
"windows": fmt.Sprintf("crc_podman_hyperv_%s_%s.crcbundle", version.GetBundleVersion(preset), runtime.GOARCH),
}
case crcpreset.OKD:
return map[string]string{
Expand Down
12 changes: 6 additions & 6 deletions pkg/crc/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ func GetCommitSha() string {
}

func GetBundleVersion(preset crcPreset.Preset) string {
if preset == crcPreset.OpenShift {
switch preset {
case crcPreset.Podman:
return podmanVersion
case crcPreset.OKD:
return okdVersion
default:
return bundleVersion
}
return okdVersion
}

func GetPodmanVersion() string {
return podmanVersion
}

func GetAdminHelperVersion() string {
Expand Down

0 comments on commit 40230ae

Please sign in to comment.