diff options
author | baude <bbaude@redhat.com> | 2018-01-30 13:19:01 -0600 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-01-31 20:23:31 +0000 |
commit | 3c044f9267f62b8f7f88c7395ad325df3bf420f5 (patch) | |
tree | d868f625ff78b5403fa82b9e7f51ffdaa953356a /cmd/podman | |
parent | ecb74aa40641cd322112401a593eaf26458e9d24 (diff) | |
download | podman-3c044f9267f62b8f7f88c7395ad325df3bf420f5.tar.gz podman-3c044f9267f62b8f7f88c7395ad325df3bf420f5.tar.bz2 podman-3c044f9267f62b8f7f88c7395ad325df3bf420f5.zip |
Ginkgo Tests: ps, pull, push and rm
Migrate ps, pull, push, and rm from bats to ginkgo.
Also, fixed a conditional issue with adding ports
when an image defines the port and the user wants
to override it.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #277
Approved by: baude
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/create.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go index e0825566a..045703074 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -298,6 +298,18 @@ func isPortInPortBindings(pb map[nat.Port][]nat.PortBinding, port nat.Port) bool return libpod.StringInSlice(port.Port(), hostPorts) } +// isPortInImagePorts determines if an exposed host port was given to us by metadata +// in the image itself +func isPortInImagePorts(exposedPorts map[string]struct{}, port string) bool { + for i := range exposedPorts { + fields := strings.Split(i, "/") + if port == fields[0] { + return true + } + } + return false +} + func exposedPorts(c *cli.Context, imageExposedPorts map[string]struct{}) (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { var exposedPorts []string var ports map[nat.Port]struct{} @@ -337,7 +349,7 @@ func exposedPorts(c *cli.Context, imageExposedPorts map[string]struct{}) (map[na return nil, nil, err } // check if the port in question is already being used - if isPortInPortBindings(portBindings, p) { + if isPortInPortBindings(portBindings, p) && !isPortInImagePorts(imageExposedPorts, p.Port()) { return nil, nil, errors.Errorf("host port %s already used in --publish option", p.Port()) } |