Skip to content

Commit

Permalink
Fix panic while merging log configs to nil map
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Jul 12, 2016
1 parent 8f3be17 commit 7dff310
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions daemon/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ func (daemon *Daemon) mergeAndVerifyLogConfig(cfg *containertypes.LogConfig) err
cfg.Type = daemon.defaultLogConfig.Type
}

if cfg.Config == nil {
cfg.Config = make(map[string]string)
}

if cfg.Type == daemon.defaultLogConfig.Type {
for k, v := range daemon.defaultLogConfig.Config {
if _, ok := cfg.Config[k]; !ok {
Expand Down
15 changes: 15 additions & 0 deletions daemon/logs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package daemon

import (
"testing"

containertypes "github.com/docker/engine-api/types/container"
)

func TestMergeAndVerifyLogConfigNilConfig(t *testing.T) {
d := &Daemon{defaultLogConfig: containertypes.LogConfig{Type: "json-file", Config: map[string]string{"max-file": "1"}}}
cfg := containertypes.LogConfig{Type: d.defaultLogConfig.Type}
if err := d.mergeAndVerifyLogConfig(&cfg); err != nil {
t.Fatal(err)
}
}

0 comments on commit 7dff310

Please sign in to comment.