mirror of
https://github.com/docker/cli.git
synced 2026-01-13 18:22:35 +03:00
Merge pull request #24548 from cpuguy83/24167_fix_log_config_merge
Fix panic while merging log configs to nil map Upstream-commit: 7a1442baf6e31b3c94a2e9fd92155a75c1987868 Component: engine
This commit is contained in:
@@ -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 {
|
||||
|
||||
15
components/engine/daemon/logs_test.go
Normal file
15
components/engine/daemon/logs_test.go
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user