Machine init --provider

Add the ability for users to override the default provider when creating mahcines.  The new flag is `--provider` and allows you to specifiy a valid vmtype for the platform.  This PR also removes the previous list test where we tested listing all providers.  I added a PR for testing --provider which includes a standard `machine ls` which defaults now to showing all providers.

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2025-10-03 14:01:49 -05:00
parent 386c8f3fe9
commit 5e1c2f8d7d
17 changed files with 162 additions and 119 deletions

View File

@@ -33,6 +33,12 @@ func Get() (vmconfigs.VMProvider, error) {
}
logrus.Debugf("Using Podman machine with `%s` virtualization provider", resolvedVMType.String())
return GetByVMType(resolvedVMType)
}
// GetByVMType takes a VMType (presumably from ParseVMType) and returns the correlating
// VMProvider
func GetByVMType(resolvedVMType define.VMType) (vmconfigs.VMProvider, error) {
switch resolvedVMType {
case define.AppleHvVirt:
return new(applehv.AppleHVStubber), nil
@@ -42,8 +48,8 @@ func Get() (vmconfigs.VMProvider, error) {
}
return new(libkrun.LibKrunStubber), nil
default:
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String())
}
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String())
}
func GetAll() []vmconfigs.VMProvider {