Browse code

Remove redundant checks in runconfig.Merge

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)

LK4D4 authored on 2014/07/09 02:10:28
Showing 1 changed files
... ...
@@ -20,7 +20,7 @@ func Merge(userConf, imageConf *Config) error {
20 20
 	if userConf.CpuShares == 0 {
21 21
 		userConf.CpuShares = imageConf.CpuShares
22 22
 	}
23
-	if userConf.ExposedPorts == nil || len(userConf.ExposedPorts) == 0 {
23
+	if len(userConf.ExposedPorts) == 0 {
24 24
 		userConf.ExposedPorts = imageConf.ExposedPorts
25 25
 	} else if imageConf.ExposedPorts != nil {
26 26
 		if userConf.ExposedPorts == nil {
... ...
@@ -33,7 +33,7 @@ func Merge(userConf, imageConf *Config) error {
33 33
 		}
34 34
 	}
35 35
 
36
-	if userConf.PortSpecs != nil && len(userConf.PortSpecs) > 0 {
36
+	if len(userConf.PortSpecs) > 0 {
37 37
 		if userConf.ExposedPorts == nil {
38 38
 			userConf.ExposedPorts = make(nat.PortSet)
39 39
 		}
... ...
@@ -48,7 +48,7 @@ func Merge(userConf, imageConf *Config) error {
48 48
 		}
49 49
 		userConf.PortSpecs = nil
50 50
 	}
51
-	if imageConf.PortSpecs != nil && len(imageConf.PortSpecs) > 0 {
51
+	if len(imageConf.PortSpecs) > 0 {
52 52
 		// FIXME: I think we can safely remove this. Leaving it for now for the sake of reverse-compat paranoia.
53 53
 		utils.Debugf("Migrating image port specs to containter: %s", strings.Join(imageConf.PortSpecs, ", "))
54 54
 		if userConf.ExposedPorts == nil {
... ...
@@ -66,7 +66,7 @@ func Merge(userConf, imageConf *Config) error {
66 66
 		}
67 67
 	}
68 68
 
69
-	if userConf.Env == nil || len(userConf.Env) == 0 {
69
+	if len(userConf.Env) == 0 {
70 70
 		userConf.Env = imageConf.Env
71 71
 	} else {
72 72
 		for _, imageEnv := range imageConf.Env {
... ...
@@ -84,16 +84,16 @@ func Merge(userConf, imageConf *Config) error {
84 84
 		}
85 85
 	}
86 86
 
87
-	if userConf.Cmd == nil || len(userConf.Cmd) == 0 {
87
+	if len(userConf.Cmd) == 0 {
88 88
 		userConf.Cmd = imageConf.Cmd
89 89
 	}
90
-	if userConf.Entrypoint == nil || len(userConf.Entrypoint) == 0 {
90
+	if len(userConf.Entrypoint) == 0 {
91 91
 		userConf.Entrypoint = imageConf.Entrypoint
92 92
 	}
93 93
 	if userConf.WorkingDir == "" {
94 94
 		userConf.WorkingDir = imageConf.WorkingDir
95 95
 	}
96
-	if userConf.Volumes == nil || len(userConf.Volumes) == 0 {
96
+	if len(userConf.Volumes) == 0 {
97 97
 		userConf.Volumes = imageConf.Volumes
98 98
 	} else {
99 99
 		for k, v := range imageConf.Volumes {