Files
podman/pkg/machine/provider/platform.go
Brent Baude 919dce1315 Plumbing to run machine tests with hyperv
this pr has the basic plumbing that allows the e2e machine tests to run
with the hyperv provider.

it requires a special fcos image right now because gvforwarder was not
in the upstream fcos images for hyperv.

changed the way "provider" is set; moved GetProvider functions to
pkg/machine/provider.  provider is now set at the machine level.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-09-14 15:57:35 -05:00

37 lines
1006 B
Go

//go:build (amd64 && !windows && amd64 && !darwin) || (arm64 && !windows && arm64 && !darwin) || (amd64 && darwin)
package provider
import (
"fmt"
"os"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v4/pkg/machine"
"github.com/containers/podman/v4/pkg/machine/qemu"
"github.com/sirupsen/logrus"
)
func Get() (machine.VirtProvider, error) {
cfg, err := config.Default()
if err != nil {
return nil, err
}
provider := cfg.Machine.Provider
if providerOverride, found := os.LookupEnv("CONTAINERS_MACHINE_PROVIDER"); found {
provider = providerOverride
}
resolvedVMType, err := machine.ParseVMType(provider, machine.QemuVirt)
if err != nil {
return nil, err
}
logrus.Debugf("Using Podman machine with `%s` virtualization provider", resolvedVMType.String())
switch resolvedVMType {
case machine.QemuVirt:
return qemu.VirtualizationProvider(), nil
default:
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String())
}
}