mirror of
https://github.com/rancher/os.git
synced 2025-08-31 14:23:11 +00:00
* Load apparmor on boot also when booting from disk * Rename system-dockerd to system-engine * Do not cache service metadatas * Do not cache Docker image to ISO file * Disable system-docker bridge by default * Remove deprecated --oom-score-adjust flag * Update VMware tools to 12.2.5 * Update QEMU guest agent to 7.2 * Remove broken VirtualBox tools
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/fatih/structs"
|
|
)
|
|
|
|
func (d *DockerConfig) FullArgs() []string {
|
|
args := []string{}
|
|
args = append(args, generateEngineOptsSlice(d.EngineOpts)...)
|
|
args = append(args, d.ExtraArgs...)
|
|
|
|
if d.TLS {
|
|
args = append(args, d.TLSArgs...)
|
|
}
|
|
|
|
if d.UserNsEnabled {
|
|
args = append(args, "--userns-remap")
|
|
args = append(args, "user-docker:user-docker")
|
|
}
|
|
return args
|
|
}
|
|
|
|
func (d *DockerConfig) AppendEnv() []string {
|
|
return append(os.Environ(), d.Environment...)
|
|
}
|
|
|
|
func generateEngineOptsSlice(opts EngineOpts) []string {
|
|
optsStruct := structs.New(opts)
|
|
|
|
var optsSlice []string
|
|
for k, v := range optsStruct.Map() {
|
|
optTag := optsStruct.Field(k).Tag("opt")
|
|
|
|
switch value := v.(type) {
|
|
case string:
|
|
if value != "" {
|
|
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag), value)
|
|
}
|
|
case *bool:
|
|
if value != nil {
|
|
if *value {
|
|
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag))
|
|
} else {
|
|
optsSlice = append(optsSlice, fmt.Sprintf("--%s=false", optTag))
|
|
}
|
|
}
|
|
case []string:
|
|
for _, elem := range value {
|
|
if elem != "" {
|
|
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag), elem)
|
|
}
|
|
}
|
|
case map[string]string:
|
|
for k, v := range value {
|
|
if v != "" {
|
|
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag), fmt.Sprintf("%s=%s", k, v))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return optsSlice
|
|
}
|