1
0
mirror of https://github.com/rancher/os.git synced 2025-06-28 15:56:58 +00:00

Remove empty Docker engine arguments

This commit is contained in:
Josh Curl 2016-11-21 15:18:44 -08:00
parent 4d9b2595b8
commit 1d617f1b92
No known key found for this signature in database
GPG Key ID: 82B504B9BCCFA677
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",