mirror of https://github.com/docker/docs.git
				
				
				
			Fix panic while merging log configs to nil map
Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit 7dff31064824ed1f9b046fe5c29bd707e663ee0b) Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
		
							parent
							
								
									98b155379b
								
							
						
					
					
						commit
						31d24fa6a9
					
				|  | @ -150,6 +150,10 @@ func (daemon *Daemon) mergeAndVerifyLogConfig(cfg *containertypes.LogConfig) err | ||||||
| 		cfg.Type = daemon.defaultLogConfig.Type | 		cfg.Type = daemon.defaultLogConfig.Type | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	if cfg.Config == nil { | ||||||
|  | 		cfg.Config = make(map[string]string) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if cfg.Type == daemon.defaultLogConfig.Type { | 	if cfg.Type == daemon.defaultLogConfig.Type { | ||||||
| 		for k, v := range daemon.defaultLogConfig.Config { | 		for k, v := range daemon.defaultLogConfig.Config { | ||||||
| 			if _, ok := cfg.Config[k]; !ok { | 			if _, ok := cfg.Config[k]; !ok { | ||||||
|  |  | ||||||
|  | @ -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) | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue