Skip to content

Commit

Permalink
OKD preset added to GetBundleType
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurycy-Krzeminski authored and praveenkumar committed Apr 25, 2023
1 parent 7a31c7f commit 2351a01
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pkg/crc/machine/bundle/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,11 @@ func (bundle *CrcBundleInfo) GetBundleNameWithoutExtension() string {
}

func (bundle *CrcBundleInfo) GetBundleType() crcPreset.Preset {
switch bundle.Type {
case "snc", "snc_custom":
return crcPreset.OpenShift
case "podman", "podman_custom":
return crcPreset.Podman
case "microshift", "microshift_custom":
return crcPreset.Microshift
default:
return crcPreset.OpenShift
bundleType := strings.TrimSuffix(bundle.Type, "_custom")
if bundleType == "snc" {
bundleType = "openshift"
}
return crcPreset.ParsePreset(bundleType)
}

func (bundle *CrcBundleInfo) IsOpenShift() bool {
Expand Down
22 changes: 22 additions & 0 deletions pkg/crc/machine/bundle/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,25 @@ func TestCustomBundleName(t *testing.T) {
customBundleName = GetCustomBundleName(customBundleName)
checkBundleName(t, customBundleName)
}

func TestGetBundleType(t *testing.T) {
var bundle CrcBundleInfo
bundle.Type = "okd"
require.Equal(t, preset.OKD, bundle.GetBundleType())
bundle.Type = "okd_custom"
require.Equal(t, preset.OKD, bundle.GetBundleType())
bundle.Type = "microshift"
require.Equal(t, preset.Microshift, bundle.GetBundleType())
bundle.Type = "microshift_custom"
require.Equal(t, preset.Microshift, bundle.GetBundleType())
bundle.Type = "openshift"
require.Equal(t, preset.OpenShift, bundle.GetBundleType())
bundle.Type = "openshift_custom"
require.Equal(t, preset.OpenShift, bundle.GetBundleType())
bundle.Type = "snc"
require.Equal(t, preset.OpenShift, bundle.GetBundleType())
bundle.Type = "snc_custom"
require.Equal(t, preset.OpenShift, bundle.GetBundleType())
bundle.Type = ""
require.Equal(t, preset.OpenShift, bundle.GetBundleType())
}

0 comments on commit 2351a01

Please sign in to comment.