Update WSL backend to be compat with FCOS defaults

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 <jason.greene@redhat.com>
This commit is contained in:
Jason T. Greene 2023-08-14 16:58:01 -05:00 committed by Brent Baude
parent 9e14e3ebe5
commit 98e7d7af01
3 changed files with 24 additions and 3 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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 {