mirror of
https://github.com/containers/podman.git
synced 2025-10-20 12:43:58 +08:00
Update to use new common machine API
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:
5
vendor/github.com/containers/common/libnetwork/etchosts/ip.go
generated
vendored
5
vendor/github.com/containers/common/libnetwork/etchosts/ip.go
generated
vendored
@ -6,6 +6,7 @@ import (
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/libnetwork/util"
|
||||
"github.com/containers/common/pkg/config"
|
||||
"github.com/containers/common/pkg/machine"
|
||||
"github.com/containers/storage/pkg/unshare"
|
||||
)
|
||||
|
||||
@ -15,8 +16,8 @@ func GetHostContainersInternalIP(conf *config.Config, netStatus map[string]types
|
||||
switch conf.Containers.HostContainersInternalIP {
|
||||
case "":
|
||||
// if empty (default) we will automatically choose one below
|
||||
// if machine we let the gvproxy dns server handle the dns name so do not add it
|
||||
if conf.Engine.MachineEnabled {
|
||||
// if machine using gvproxy we let the gvproxy dns server handle the dns name so do not add it
|
||||
if machine.IsGvProxyBased() {
|
||||
return ""
|
||||
}
|
||||
case "none":
|
||||
|
2
vendor/github.com/containers/common/libnetwork/netavark/network.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/netavark/network.go
generated
vendored
@ -27,7 +27,7 @@ type netavarkNetwork struct {
|
||||
// networkRunDir is where temporary files are stored, i.e.the ipam db, aardvark config etc
|
||||
networkRunDir string
|
||||
|
||||
// tells netavark whether this is rootless mode or rootfull, "true" or "false"
|
||||
// tells netavark whether this is rootless mode or rootful, "true" or "false"
|
||||
networkRootless bool
|
||||
|
||||
// netavarkBinary is the path to the netavark binary.
|
||||
|
3
vendor/github.com/containers/common/libnetwork/network/interface.go
generated
vendored
3
vendor/github.com/containers/common/libnetwork/network/interface.go
generated
vendored
@ -14,6 +14,7 @@ import (
|
||||
"github.com/containers/common/libnetwork/netavark"
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/pkg/config"
|
||||
"github.com/containers/common/pkg/machine"
|
||||
"github.com/containers/storage"
|
||||
"github.com/containers/storage/pkg/homedir"
|
||||
"github.com/containers/storage/pkg/ioutils"
|
||||
@ -173,7 +174,7 @@ func getCniInterface(conf *config.Config) (types.ContainerNetwork, error) {
|
||||
DefaultNetwork: conf.Network.DefaultNetwork,
|
||||
DefaultSubnet: conf.Network.DefaultSubnet,
|
||||
DefaultsubnetPools: conf.Network.DefaultSubnetPools,
|
||||
IsMachine: conf.Engine.MachineEnabled,
|
||||
IsMachine: machine.IsGvProxyBased(),
|
||||
})
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
2
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
@ -312,6 +312,8 @@ type EngineConfig struct {
|
||||
LockType string `toml:"lock_type,omitempty"`
|
||||
|
||||
// MachineEnabled indicates if Podman is running in a podman-machine VM
|
||||
//
|
||||
// This method is soft deprecated, use machine.IsPodmanMachine instead
|
||||
MachineEnabled bool `toml:"machine_enabled,omitempty"`
|
||||
|
||||
// MultiImageArchive - if true, the container engine allows for storing
|
||||
|
25
vendor/github.com/containers/common/pkg/config/config_freebsd.go
generated
vendored
Normal file
25
vendor/github.com/containers/common/pkg/config/config_freebsd.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// podman remote clients on freebsd cannot use unshare.isRootless() to determine the configuration file locations.
|
||||
func customConfigFile() (string, error) {
|
||||
if path, found := os.LookupEnv("CONTAINERS_CONF"); found {
|
||||
return path, nil
|
||||
}
|
||||
return rootlessConfigPath()
|
||||
}
|
||||
|
||||
func ifRootlessConfigPath() (string, error) {
|
||||
return rootlessConfigPath()
|
||||
}
|
||||
|
||||
var defaultHelperBinariesDir = []string{
|
||||
"/usr/local/bin",
|
||||
"/usr/local/libexec/podman",
|
||||
"/usr/local/lib/podman",
|
||||
"/usr/local/libexec/podman",
|
||||
"/usr/local/lib/podman",
|
||||
}
|
10
vendor/github.com/containers/common/pkg/config/containers.conf
generated
vendored
10
vendor/github.com/containers/common/pkg/config/containers.conf
generated
vendored
@ -455,12 +455,6 @@ default_sysctls = [
|
||||
#
|
||||
#lock_type** = "shm"
|
||||
|
||||
# Indicates if Podman is running inside a VM via Podman Machine.
|
||||
# Podman uses this value to do extra setup around networking from the
|
||||
# container inside the VM to to host.
|
||||
#
|
||||
#machine_enabled = false
|
||||
|
||||
# MultiImageArchive - if true, the container engine allows for storing archives
|
||||
# (e.g., of the docker-archive transport) with multiple images. By default,
|
||||
# Podman creates single-image archives.
|
||||
@ -572,9 +566,9 @@ default_sysctls = [
|
||||
# URI to access the Podman service
|
||||
# Examples:
|
||||
# rootless "unix://run/user/$UID/podman/podman.sock" (Default)
|
||||
# rootfull "unix://run/podman/podman.sock (Default)
|
||||
# rootful "unix://run/podman/podman.sock (Default)
|
||||
# remote rootless ssh://engineering.lab.company.com/run/user/1000/podman/podman.sock
|
||||
# remote rootfull ssh://root@10.10.1.136:22/run/podman/podman.sock
|
||||
# remote rootful ssh://root@10.10.1.136:22/run/podman/podman.sock
|
||||
#
|
||||
# uri = "ssh://user@production.example.com/run/user/1001/podman/podman.sock"
|
||||
# Path to file containing ssh identity key
|
||||
|
70
vendor/github.com/containers/common/pkg/machine/machine.go
generated
vendored
Normal file
70
vendor/github.com/containers/common/pkg/machine/machine.go
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
package machine
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/containers/common/pkg/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type MachineMarker struct {
|
||||
Enabled bool
|
||||
Type string
|
||||
}
|
||||
|
||||
const (
|
||||
markerFile = "/etc/containers/podman-machine"
|
||||
Wsl = "wsl"
|
||||
Qemu = "qemu"
|
||||
)
|
||||
|
||||
var (
|
||||
markerSync sync.Once
|
||||
machineMarker *MachineMarker
|
||||
)
|
||||
|
||||
func loadMachineMarker(file string) {
|
||||
var kind string
|
||||
|
||||
// Support deprecated config value for compatibility
|
||||
enabled := isLegacyConfigSet()
|
||||
|
||||
if content, err := os.ReadFile(file); err == nil {
|
||||
enabled = true
|
||||
kind = strings.TrimSpace(string(content))
|
||||
}
|
||||
|
||||
machineMarker = &MachineMarker{enabled, kind}
|
||||
}
|
||||
|
||||
func isLegacyConfigSet() bool {
|
||||
config, err := config.Default()
|
||||
if err != nil {
|
||||
logrus.Warnf("could not obtain container configuration")
|
||||
return false
|
||||
}
|
||||
|
||||
//nolint:staticcheck //lint:ignore SA1019 deprecated call
|
||||
return config.Engine.MachineEnabled
|
||||
}
|
||||
|
||||
func IsPodmanMachine() bool {
|
||||
return GetMachineMarker().Enabled
|
||||
}
|
||||
|
||||
func MachineHostType() string {
|
||||
return GetMachineMarker().Type
|
||||
}
|
||||
|
||||
func IsGvProxyBased() bool {
|
||||
return IsPodmanMachine() && MachineHostType() != Wsl
|
||||
}
|
||||
|
||||
func GetMachineMarker() *MachineMarker {
|
||||
markerSync.Do(func() {
|
||||
loadMachineMarker(markerFile)
|
||||
})
|
||||
return machineMarker
|
||||
}
|
Reference in New Issue
Block a user