Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement machine provider selection
GetSystemDefaultProvider reworked to fetch provider value from the config file. Additional environment variable CONTAINERS_MACHINE_PROVIDER is supported to override the config for testing purposes. Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
- Loading branch information
Showing
15 changed files
with
118 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
package machine | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/containers/common/pkg/config" | ||
"github.com/containers/podman/v4/pkg/machine" | ||
"github.com/containers/podman/v4/pkg/machine/hyperv" | ||
"github.com/containers/podman/v4/pkg/machine/wsl" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func GetSystemDefaultProvider() machine.VirtProvider { | ||
// This is a work-around for default provider on windows while | ||
// hyperv is one developer. | ||
// TODO this needs to be changed back | ||
if _, exists := os.LookupEnv("HYPERV"); exists { | ||
return hyperv.GetVirtualizationProvider() | ||
func GetSystemProvider() (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.WSLVirt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
logrus.Debugf("Using Podman machine with `%s` virtualization provider", resolvedVMType.String()) | ||
switch resolvedVMType { | ||
case machine.WSLVirt: | ||
return wsl.GetWSLProvider(), nil | ||
case machine.HyperVVirt: | ||
return hyperv.GetVirtualizationProvider(), nil | ||
default: | ||
return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String()) | ||
} | ||
return wsl.GetWSLProvider() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters