Skip to content

Commit

Permalink
version: Add GetDefaultPreset()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cfergeau authored and anjannath committed May 29, 2023
1 parent 07b7902 commit ab91360
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/crc/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func RegisterSettings(cfg *Config) {
}

// Preset setting should be on top because CPUs/Memory config depend on it.
cfg.AddSetting(Preset, string(preset.OpenShift), validatePreset, RequiresDeleteAndSetupMsg,
cfg.AddSetting(Preset, version.GetDefaultPreset().String(), validatePreset, RequiresDeleteAndSetupMsg,
fmt.Sprintf("Virtual machine preset (valid values are: %s)", preset.AllPresets()))
// Start command settings in config
cfg.AddSetting(Bundle, defaultBundlePath(cfg), validateBundlePath, SuccessfullyApplied, BundleHelpMsg(cfg))
Expand Down
11 changes: 11 additions & 0 deletions pkg/crc/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var (
// will be true for releases on macos and windows
// will be false for git builds on macos and windows
installerBuild = "false"

defaultPreset = "openshift"
)

const (
Expand Down Expand Up @@ -140,3 +142,12 @@ func GetCRCLatestVersionFromMirror(transport http.RoundTripper) (*CrcReleaseInfo

return &releaseInfo, nil
}

func GetDefaultPreset() crcPreset.Preset {
preset, err := crcPreset.ParsePresetE(defaultPreset)
if err != nil {
// defaultPreset is set at compile-time, it should *never* be invalid
panic(fmt.Sprintf("Invalid compilet-time default preset '%s'", defaultPreset))
}
return preset
}

0 comments on commit ab91360

Please sign in to comment.