mirror of https://github.com/docker/cli.git
display port name field in 'service ls'
Signed-off-by: Arvid E. Picciani <arvid@kraud.cloud>
This commit is contained in:
parent
e198123693
commit
b04338080c
|
@ -725,6 +725,7 @@ func (c *serviceContext) Image() string {
|
|||
}
|
||||
|
||||
type portRange struct {
|
||||
pName string
|
||||
pStart uint32
|
||||
pEnd uint32
|
||||
tStart uint32
|
||||
|
@ -736,8 +737,14 @@ func (pr portRange) String() string {
|
|||
var (
|
||||
pub string
|
||||
tgt string
|
||||
name string
|
||||
)
|
||||
|
||||
if pr.pName == "" {
|
||||
name = "*"
|
||||
} else {
|
||||
name = pr.pName
|
||||
}
|
||||
if pr.pEnd > pr.pStart {
|
||||
pub = fmt.Sprintf("%d-%d", pr.pStart, pr.pEnd)
|
||||
} else {
|
||||
|
@ -748,7 +755,7 @@ func (pr portRange) String() string {
|
|||
} else {
|
||||
tgt = fmt.Sprintf("%d", pr.tStart)
|
||||
}
|
||||
return fmt.Sprintf("*:%s->%s/%s", pub, tgt, pr.protocol)
|
||||
return fmt.Sprintf("%s:%s->%s/%s", name, pub, tgt, pr.protocol)
|
||||
}
|
||||
|
||||
// Ports formats published ports on the ingress network for output.
|
||||
|
@ -794,6 +801,7 @@ func (c *serviceContext) Ports() string {
|
|||
ports = append(ports, pr.String())
|
||||
}
|
||||
pr = portRange{
|
||||
pName: p.Name,
|
||||
pStart: p.PublishedPort,
|
||||
pEnd: p.PublishedPort,
|
||||
tStart: p.TargetPort,
|
||||
|
|
|
@ -139,7 +139,10 @@ func (c *taskContext) Ports() string {
|
|||
}
|
||||
ports := []string{}
|
||||
for _, pConfig := range c.task.Status.PortStatus.Ports {
|
||||
ports = append(ports, fmt.Sprintf("*:%d->%d/%s",
|
||||
var name = pConfig.Name
|
||||
if name == "" { name = "*" }
|
||||
ports = append(ports, fmt.Sprintf("%s:%d->%d/%s",
|
||||
name,
|
||||
pConfig.PublishedPort,
|
||||
pConfig.TargetPort,
|
||||
pConfig.Protocol,
|
||||
|
|
Loading…
Reference in New Issue