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

@@ -30,18 +30,24 @@ func Get() (vmconfigs.VMProvider, error) {
}
logrus.Debugf("Using Podman machine with `%s` virtualization provider", resolvedVMType.String())
switch resolvedVMType {
case define.QemuVirt:
return qemu.NewStubber()
default:
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String())
}
return GetByVMType(resolvedVMType)
}
func GetAll() []vmconfigs.VMProvider {
return []vmconfigs.VMProvider{new(qemu.QEMUStubber)}
}
// GetByVMType takes a VMType (presumably from ParseVMType) and returns the correlating
// VMProvider
func GetByVMType(resolvedVMType define.VMType) (vmconfigs.VMProvider, error) {
switch resolvedVMType {
case define.QemuVirt:
return qemu.NewStubber()
default:
}
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String())
}
// SupportedProviders returns the providers that are supported on the host operating system
func SupportedProviders() []define.VMType {
return []define.VMType{define.QemuVirt}