1
0
mirror of https://github.com/rancher/os.git synced 2025-07-12 14:18:01 +00:00

Merge pull request #1414 from joshwget/remove-empty-docker-engine-arguments

Remove empty Docker engine arguments
This commit is contained in:
Sven Dowideit 2016-11-23 08:54:30 +10:00 committed by GitHub
commit 13c6c15587
2 changed files with 20 additions and 2 deletions

View File

@ -43,11 +43,15 @@ func generateEngineOptsSlice(opts EngineOpts) []string {
}
case []string:
for _, elem := range value {
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag), elem)
if elem != "" {
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag), elem)
}
}
case map[string]string:
for k, v := range value {
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag), fmt.Sprintf("%s=%s", k, v))
if v != "" {
optsSlice = append(optsSlice, fmt.Sprintf("--%s", optTag), fmt.Sprintf("%s=%s", k, v))
}
}
}
}

View File

@ -18,6 +18,20 @@ func TestGenerateEngineOptsString(t *testing.T) {
if len(generateEngineOptsSlice(EngineOpts{})) != 0 {
t.Fail()
}
if len(generateEngineOptsSlice(EngineOpts{
Host: []string{
"",
},
})) != 0 {
t.Fail()
}
if len(generateEngineOptsSlice(EngineOpts{
LogOpts: map[string]string{
"max-file": "",
},
})) != 0 {
t.Fail()
}
testContains(t, fmt.Sprint(generateEngineOptsSlice(EngineOpts{
Bridge: "bridge",