ps: do not loop over port protocol

This can never included a comma in the protocol so it just complicated
things for no reason, we never needed this and commit edc3dc5e11 already
ensures this cannot happen.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2024-10-22 11:45:34 +02:00
parent 71c9744f72
commit 73fb6623cd
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 8 additions and 11 deletions

View File

@ -497,17 +497,14 @@ func portsToString(ports []types.PortMapping, exposedPorts map[uint16][]string)
if hostIP == "" { if hostIP == "" {
hostIP = "0.0.0.0" hostIP = "0.0.0.0"
} }
protocols := strings.Split(port.Protocol, ",") if port.Range > 1 {
for _, protocol := range protocols { fmt.Fprintf(sb, "%s:%d-%d->%d-%d/%s, ",
if port.Range > 1 { hostIP, port.HostPort, port.HostPort+port.Range-1,
fmt.Fprintf(sb, "%s:%d-%d->%d-%d/%s, ", port.ContainerPort, port.ContainerPort+port.Range-1, port.Protocol)
hostIP, port.HostPort, port.HostPort+port.Range-1, } else {
port.ContainerPort, port.ContainerPort+port.Range-1, protocol) fmt.Fprintf(sb, "%s:%d->%d/%s, ",
} else { hostIP, port.HostPort,
fmt.Fprintf(sb, "%s:%d->%d/%s, ", port.ContainerPort, port.Protocol)
hostIP, port.HostPort,
port.ContainerPort, protocol)
}
} }
} }