Vendor c/common changes

Vendor latest c/common with changes to add a new Farms
table to containers.conf and update system connection to
add a connection to a farm when --farm is set.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
This commit is contained in:
Urvashi Mohnani
2023-08-08 10:47:48 -04:00
parent 57fac93b30
commit b672ddc792
44 changed files with 2704 additions and 13267 deletions

View File

@ -16,6 +16,7 @@ const (
HostContainersInternal = "host.containers.internal"
HostGateway = "host-gateway"
localhost = "localhost"
hostDockerInternal = "host.docker.internal"
)
type HostEntries []HostEntry
@ -119,7 +120,7 @@ func newHost(params *Params) error {
l2 := HostEntry{IP: "::1", Names: lh}
containerIPs = append(containerIPs, l1, l2)
if params.HostContainersInternalIP != "" {
e := HostEntry{IP: params.HostContainersInternalIP, Names: []string{HostContainersInternal}}
e := HostEntry{IP: params.HostContainersInternalIP, Names: []string{HostContainersInternal, hostDockerInternal}}
containerIPs = append(containerIPs, e)
}
containerIPs = append(containerIPs, params.ContainerIPs...)

View File

@ -79,6 +79,8 @@ type Config struct {
Secrets SecretConfig `toml:"secrets"`
// ConfigMap section defines configurations for the configmaps management
ConfigMaps ConfigMapConfig `toml:"configmaps"`
// Farms defines configurations for the buildfarm farms
Farms FarmConfig `toml:"farms"`
}
// ContainersConfig represents the "containers" TOML config table
@ -676,6 +678,14 @@ type MachineConfig struct {
Provider string `toml:"provider,omitempty"`
}
// FarmConfig represents the "farm" TOML config tabls
type FarmConfig struct {
// Default is the default farm to be used when farming out builds
Default string `toml:"default,omitempty"`
// List is a map of farms created where key=farm-name and value=list of connections
List map[string][]string `toml:"list,omitempty"`
}
// Destination represents destination for remote service
type Destination struct {
// URI, required. Example: ssh://root@example.com:22/run/podman/podman.sock
@ -1241,6 +1251,10 @@ func ReadCustomConfig() (*Config, error) {
return nil, err
}
}
// Let's always initialize the farm list so it is never nil
if newConfig.Farms.List == nil {
newConfig.Farms.List = make(map[string][]string)
}
return newConfig, nil
}

View File

@ -798,3 +798,11 @@ default_sysctls = [
# TOML does not provide a way to end a table other than a further table being
# defined, so every key hereafter will be part of [machine] and not the
# main config.
[farms]
#
# the default farm to use when farming out builds
# default = ""
#
# map of existing farms
#[farms.list]

View File

@ -660,3 +660,11 @@ default_sysctls = [
# TOML does not provide a way to end a table other than a further table being
# defined, so every key hereafter will be part of [machine] and not the
# main config.
[farms]
#
# the default farm to use when farming out builds
# default = ""
#
# map of existing farms
#[farms.list]

View File

@ -234,6 +234,7 @@ func DefaultConfig() (*Config, error) {
Engine: *defaultEngineConfig,
Secrets: defaultSecretConfig(),
Machine: defaultMachineConfig(),
Farms: defaultFarmConfig(),
}, nil
}
@ -257,6 +258,14 @@ func defaultMachineConfig() MachineConfig {
}
}
// defaultFarmConfig returns the default farms configuration.
func defaultFarmConfig() FarmConfig {
emptyList := make(map[string][]string)
return FarmConfig{
List: emptyList,
}
}
// defaultConfigFromMemory returns a default engine configuration. Note that the
// config is different for root and rootless. It also parses the storage.conf.
func defaultConfigFromMemory() (*EngineConfig, error) {

View File

@ -64,6 +64,19 @@ func golangConnectionCreate(options ConnectionCreateOptions) error {
} else {
cfg.Engine.ServiceDestinations[options.Name] = *dst
}
// Create or update an existing farm with the connection being added
if options.Farm != "" {
if len(cfg.Farms.List) == 0 {
cfg.Farms.Default = options.Farm
}
if val, ok := cfg.Farms.List[options.Farm]; ok {
cfg.Farms.List[options.Farm] = append(val, options.Name)
} else {
cfg.Farms.List[options.Farm] = []string{options.Name}
}
}
return cfg.Write()
}

View File

@ -24,6 +24,7 @@ type ConnectionCreateOptions struct {
Identity string
Socket string
Default bool
Farm string
}
type ConnectionDialOptions struct {