Skip to content

Commit ab91360

Browse files
cfergeauanjannath
authored andcommitted
version: Add GetDefaultPreset()
This will allow to override it at compile-time when needed. I changed the default preset in the configuration code, but I did not check if it was used in other places. This will help with #3637
1 parent 07b7902 commit ab91360

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/crc/config/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func RegisterSettings(cfg *Config) {
7070
}
7171

7272
// Preset setting should be on top because CPUs/Memory config depend on it.
73-
cfg.AddSetting(Preset, string(preset.OpenShift), validatePreset, RequiresDeleteAndSetupMsg,
73+
cfg.AddSetting(Preset, version.GetDefaultPreset().String(), validatePreset, RequiresDeleteAndSetupMsg,
7474
fmt.Sprintf("Virtual machine preset (valid values are: %s)", preset.AllPresets()))
7575
// Start command settings in config
7676
cfg.AddSetting(Bundle, defaultBundlePath(cfg), validateBundlePath, SuccessfullyApplied, BundleHelpMsg(cfg))

pkg/crc/version/version.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var (
3535
// will be true for releases on macos and windows
3636
// will be false for git builds on macos and windows
3737
installerBuild = "false"
38+
39+
defaultPreset = "openshift"
3840
)
3941

4042
const (
@@ -140,3 +142,12 @@ func GetCRCLatestVersionFromMirror(transport http.RoundTripper) (*CrcReleaseInfo
140142

141143
return &releaseInfo, nil
142144
}
145+
146+
func GetDefaultPreset() crcPreset.Preset {
147+
preset, err := crcPreset.ParsePresetE(defaultPreset)
148+
if err != nil {
149+
// defaultPreset is set at compile-time, it should *never* be invalid
150+
panic(fmt.Sprintf("Invalid compilet-time default preset '%s'", defaultPreset))
151+
}
152+
return preset
153+
}

0 commit comments

Comments
 (0)