Remove redundant checks in runconfig.Merge

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
LK4D4 2014-07-08 21:10:28 +04:00
Родитель d48492a12e
Коммит 7dba5024e8
1 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -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 {