Skip to content

Commit

Permalink
Remove redundant checks in runconfig.Merge
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
  • Loading branch information
LK4D4 committed Aug 4, 2014
1 parent d48492a commit 7dba502
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions runconfig/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 7dba502

Please sign in to comment.