Skip to content

Commit

Permalink
cli: fix regression in config validation (abiosoft#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
abiosoft committed Mar 6, 2023
1 parent 0f3f2de commit feef417
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,24 @@ func setDefaults(cmd *cobra.Command) {
}
}
}
}

func setConfigDefaults(conf *config.Config) {
// handle macOS virtualization.framework transition
if conf.VMType == "" {
conf.VMType = defaultVMType
}

if conf.MountType == "" {
conf.MountType = defaultMountTypeQEMU
if util.MacOS13OrNewer() && conf.VMType == "vz" {
conf.MountType = defaultMountTypeVZ
}
}

if conf.Network.Driver == "" {
conf.Network.Driver = defaultNetworkDriver
}
}

func prepareConfig(cmd *cobra.Command) {
Expand All @@ -288,12 +305,6 @@ func prepareConfig(cmd *cobra.Command) {
// set relevant missing default values
setDefaults(cmd)

// handle macOS virtualization.framework transition
{
if current.VMType == "" {
current.VMType = "qemu"
}
}
// if there is no existing settings
if current.Empty() {
// attempt template
Expand All @@ -305,6 +316,9 @@ func prepareConfig(cmd *cobra.Command) {
current = template
}

// set missing defaults in the current config
setConfigDefaults(&current)

// docker can only be set in config file
startCmdArgs.Docker = current.Docker
// provision scripts can only be set in config file
Expand Down

0 comments on commit feef417

Please sign in to comment.