From 7dba5024e8cf152f8a597dd177485dbf9001ae58 Mon Sep 17 00:00:00 2001 From: LK4D4 Date: Tue, 8 Jul 2014 21:10:28 +0400 Subject: [PATCH] Remove redundant checks in runconfig.Merge Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) --- runconfig/merge.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runconfig/merge.go b/runconfig/merge.go index 290d5f3189..1c81d25ba6 100644 --- a/runconfig/merge.go +++ b/runconfig/merge.go @@ -20,7 +20,7 @@ func Merge(userConf, imageConf *Config) error { if userConf.CpuShares == 0 { userConf.CpuShares = imageConf.CpuShares } - if userConf.ExposedPorts == nil || len(userConf.ExposedPorts) == 0 { + if len(userConf.ExposedPorts) == 0 { userConf.ExposedPorts = imageConf.ExposedPorts } else if imageConf.ExposedPorts != nil { if userConf.ExposedPorts == nil { @@ -33,7 +33,7 @@ func Merge(userConf, imageConf *Config) error { } } - if userConf.PortSpecs != nil && len(userConf.PortSpecs) > 0 { + if len(userConf.PortSpecs) > 0 { if userConf.ExposedPorts == nil { userConf.ExposedPorts = make(nat.PortSet) } @@ -48,7 +48,7 @@ func Merge(userConf, imageConf *Config) error { } userConf.PortSpecs = nil } - if imageConf.PortSpecs != nil && len(imageConf.PortSpecs) > 0 { + if len(imageConf.PortSpecs) > 0 { // FIXME: I think we can safely remove this. Leaving it for now for the sake of reverse-compat paranoia. utils.Debugf("Migrating image port specs to containter: %s", strings.Join(imageConf.PortSpecs, ", ")) if userConf.ExposedPorts == nil { @@ -66,7 +66,7 @@ func Merge(userConf, imageConf *Config) error { } } - if userConf.Env == nil || len(userConf.Env) == 0 { + if len(userConf.Env) == 0 { userConf.Env = imageConf.Env } else { for _, imageEnv := range imageConf.Env { @@ -84,16 +84,16 @@ func Merge(userConf, imageConf *Config) error { } } - if userConf.Cmd == nil || len(userConf.Cmd) == 0 { + if len(userConf.Cmd) == 0 { userConf.Cmd = imageConf.Cmd } - if userConf.Entrypoint == nil || len(userConf.Entrypoint) == 0 { + if len(userConf.Entrypoint) == 0 { userConf.Entrypoint = imageConf.Entrypoint } if userConf.WorkingDir == "" { userConf.WorkingDir = imageConf.WorkingDir } - if userConf.Volumes == nil || len(userConf.Volumes) == 0 { + if len(userConf.Volumes) == 0 { userConf.Volumes = imageConf.Volumes } else { for k, v := range imageConf.Volumes {