Vendor c/common

Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
Ashley Cui
2023-09-22 09:50:08 -04:00
parent 5a3a9ce9c7
commit 96142c2f75
5 changed files with 10 additions and 33 deletions

View File

@ -1100,34 +1100,6 @@ func Reload() (*Config, error) {
return New(&Options{SetDefault: true})
}
func (c *Config) ActiveDestination() (uri, identity string, machine bool, err error) {
if uri, found := os.LookupEnv("CONTAINER_HOST"); found {
if v, found := os.LookupEnv("CONTAINER_SSHKEY"); found {
identity = v
}
return uri, identity, false, nil
}
connEnv := os.Getenv("CONTAINER_CONNECTION")
switch {
case connEnv != "":
d, found := c.Engine.ServiceDestinations[connEnv]
if !found {
return "", "", false, fmt.Errorf("environment variable CONTAINER_CONNECTION=%q service destination not found", connEnv)
}
return d.URI, d.Identity, d.IsMachine, nil
case c.Engine.ActiveService != "":
d, found := c.Engine.ServiceDestinations[c.Engine.ActiveService]
if !found {
return "", "", false, fmt.Errorf("%q service destination not found", c.Engine.ActiveService)
}
return d.URI, d.Identity, d.IsMachine, nil
case c.Engine.RemoteURI != "":
return c.Engine.RemoteURI, c.Engine.RemoteIdentity, false, nil
}
return "", "", false, errors.New("no service destination configured")
}
var (
bindirFailed = false
bindirCached = ""

View File

@ -6,6 +6,7 @@ import (
"net"
"os"
"path/filepath"
"runtime"
"strings"
nettypes "github.com/containers/common/libnetwork/types"
@ -250,8 +251,12 @@ func defaultSecretConfig() SecretConfig {
// defaultMachineConfig returns the default machine configuration.
func defaultMachineConfig() MachineConfig {
cpus := runtime.NumCPU() / 2
if cpus == 0 {
cpus = 1
}
return MachineConfig{
CPUs: 1,
CPUs: uint64(cpus),
DiskSize: 100,
Image: getDefaultMachineImage(),
Memory: 2048,