Skip to content

Commit

Permalink
Update WSL backend to be compat with FCOS defaults
Browse files Browse the repository at this point in the history
container/common Config was recently updated to use FCOS
default names, since Windows HyperV backend needs them,
and these are common with other providers.

Map this to values the WSL backend expects.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <[email protected]>
  • Loading branch information
n1hility authored and baude committed Aug 15, 2023
1 parent 9e14e3e commit 98e7d7a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions pkg/machine/fcos.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,18 @@ func FCOSStreamFromString(s string) FCOSStream {
}
return Stable
}

func IsValidFCOSStreamString(s string) bool {
switch s {
case Testing.String():
fallthrough
case Next.String():
fallthrough
case PodmanTesting.String():
fallthrough
case Stable.String():
return true
}

return false
}
9 changes: 7 additions & 2 deletions pkg/machine/wsl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ func (p *WSLVirtualization) NewMachine(opts machine.InitOptions) (machine.VM, er
vm.ConfigPath = configPath
vm.ImagePath = opts.ImagePath

// WSL uses a different username; here we hardcode it.
vm.RemoteUsername = "user"
// WSL historically uses a different username; translate "core" fcos default to
// legacy "user" default
if opts.Username == "" || opts.Username == "core" {
vm.RemoteUsername = "user"
} else {
vm.RemoteUsername = opts.Username
}

vm.Created = time.Now()
vm.LastUp = vm.Created
Expand Down
3 changes: 2 additions & 1 deletion pkg/machine/wsl/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ func downloadDistro(v *MachineVM, opts machine.InitOptions) error {
err error
)

if _, e := strconv.Atoi(opts.ImagePath); e == nil {
// The default FCOS stream names are reserved indicators for the standard Fedora fetch
if machine.IsValidFCOSStreamString(opts.ImagePath) {
v.ImageStream = opts.ImagePath
dd, err = NewFedoraDownloader(vmtype, v.Name, opts.ImagePath)
} else {
Expand Down

0 comments on commit 98e7d7a

Please sign in to comment.