summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-08 20:34:49 +0200
committerGitHub <noreply@github.com>2019-08-08 20:34:49 +0200
commit09cedd152d5c5827520635b10498d15225999e19 (patch)
tree989288c573df9f218683a8ddce7ee8bb839fe611 /cmd
parent3959a357f7cefc9e3494042781fe0978e621cccc (diff)
parentb7b86bda2dea8e0cd6b381ede64d1850f3a5e393 (diff)
downloadpodman-09cedd152d5c5827520635b10498d15225999e19.tar.gz
podman-09cedd152d5c5827520635b10498d15225999e19.tar.bz2
podman-09cedd152d5c5827520635b10498d15225999e19.zip
Merge pull request #3750 from baude/portreporting
fix port early return
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/port.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/cmd/podman/port.go b/cmd/podman/port.go
index 5753c8e56..4e1f9642c 100644
--- a/cmd/podman/port.go
+++ b/cmd/podman/port.go
@@ -48,8 +48,8 @@ func init() {
func portCmd(c *cliconfig.PortValues) error {
var (
- userProto, containerName string
- userPort int
+ userProto string
+ userPort int
)
args := c.InputArgs
@@ -106,6 +106,7 @@ func portCmd(c *cliconfig.PortValues) error {
if err != nil {
return err
}
+ var found bool
// Iterate mappings
for _, v := range portmappings {
hostIP := v.HostIP
@@ -125,12 +126,14 @@ func portCmd(c *cliconfig.PortValues) error {
if v.ContainerPort == int32(userPort) {
if userProto == "" || userProto == v.Protocol {
fmt.Printf("%s:%d\n", hostIP, v.HostPort)
+ found = true
break
}
- } else {
- return errors.Errorf("No public port '%d' published for %s", userPort, containerName)
}
}
+ if !found && port != "" {
+ return errors.Errorf("failed to find published port '%d'", userPort)
+ }
}
return nil