Skip to content

Commit

Permalink
ps: do not loop over prot protocol
Browse files Browse the repository at this point in the history
This can never included a comma in the protocol so it just complicated
things for no reason, we never needed this and commit edc3dc5 already
ensures this cannot happen.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
  • Loading branch information
Luap99 committed Oct 22, 2024
1 parent 4319fac commit 26c9e87
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions cmd/podman/containers/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,17 +497,14 @@ func portsToString(ports []types.PortMapping, exposedPorts map[uint16][]string)
if hostIP == "" {
hostIP = "0.0.0.0"
}
protocols := strings.Split(port.Protocol, ",")
for _, protocol := range protocols {
if port.Range > 1 {
fmt.Fprintf(sb, "%s:%d-%d->%d-%d/%s, ",
hostIP, port.HostPort, port.HostPort+port.Range-1,
port.ContainerPort, port.ContainerPort+port.Range-1, protocol)
} else {
fmt.Fprintf(sb, "%s:%d->%d/%s, ",
hostIP, port.HostPort,
port.ContainerPort, protocol)
}
if port.Range > 1 {
fmt.Fprintf(sb, "%s:%d-%d->%d-%d/%s, ",
hostIP, port.HostPort, port.HostPort+port.Range-1,
port.ContainerPort, port.ContainerPort+port.Range-1, port.Protocol)
} else {
fmt.Fprintf(sb, "%s:%d->%d/%s, ",
hostIP, port.HostPort,
port.ContainerPort, port.Protocol)
}
}

Expand Down

0 comments on commit 26c9e87

Please sign in to comment.