Skip to content

Commit

Permalink
Config: Add callback function to have message about setup in case of …
Browse files Browse the repository at this point in the history
…preset change

fixes: #2859
  • Loading branch information
praveenkumar committed Jan 20, 2022
1 parent 275b2ad commit 92d4cbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/crc/config/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ func RequiresDeleteMsg(key string, _ interface{}) string {
"delete the CRC instance with 'crc delete' and start it with 'crc start'.", key)
}

func RequiresDeleteAndSetupMsg(key string, _ interface{}) string {
return fmt.Sprintf("Changes to configuration property '%s' are only applied when the CRC instance is created.\n"+
"If you already have a running CRC instance with different %s, then for this configuration change to take effect, "+
"delete the CRC instance with 'crc delete', setup it with `crc setup` and start it with 'crc start'.", key, key)
}

func SuccessfullyApplied(key string, value interface{}) string {
return fmt.Sprintf("Successfully configured %s to %s", key, cast.ToString(value))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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, RequiresDeleteMsg,
cfg.AddSetting(Preset, string(preset.OpenShift), validatePreset, RequiresDeleteAndSetupMsg,
fmt.Sprintf("Virtual machine preset (alpha feature - valid values are: %s or %s)", preset.Podman, preset.OpenShift))
// Start command settings in config
cfg.AddSetting(Bundle, defaultBundlePath(cfg), validateBundlePath, SuccessfullyApplied,
Expand Down

0 comments on commit 92d4cbb

Please sign in to comment.