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:
parent
4d9b2595b8
commit
1d617f1b92
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user