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 {
|
type portRange struct {
|
||||||
|
pName string
|
||||||
pStart uint32
|
pStart uint32
|
||||||
pEnd uint32
|
pEnd uint32
|
||||||
tStart uint32
|
tStart uint32
|
||||||
|
@ -736,8 +737,14 @@ func (pr portRange) String() string {
|
||||||
var (
|
var (
|
||||||
pub string
|
pub string
|
||||||
tgt string
|
tgt string
|
||||||
|
name string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if pr.pName == "" {
|
||||||
|
name = "*"
|
||||||
|
} else {
|
||||||
|
name = pr.pName
|
||||||
|
}
|
||||||
if pr.pEnd > pr.pStart {
|
if pr.pEnd > pr.pStart {
|
||||||
pub = fmt.Sprintf("%d-%d", pr.pStart, pr.pEnd)
|
pub = fmt.Sprintf("%d-%d", pr.pStart, pr.pEnd)
|
||||||
} else {
|
} else {
|
||||||
|
@ -748,7 +755,7 @@ func (pr portRange) String() string {
|
||||||
} else {
|
} else {
|
||||||
tgt = fmt.Sprintf("%d", pr.tStart)
|
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.
|
// Ports formats published ports on the ingress network for output.
|
||||||
|
@ -794,6 +801,7 @@ func (c *serviceContext) Ports() string {
|
||||||
ports = append(ports, pr.String())
|
ports = append(ports, pr.String())
|
||||||
}
|
}
|
||||||
pr = portRange{
|
pr = portRange{
|
||||||
|
pName: p.Name,
|
||||||
pStart: p.PublishedPort,
|
pStart: p.PublishedPort,
|
||||||
pEnd: p.PublishedPort,
|
pEnd: p.PublishedPort,
|
||||||
tStart: p.TargetPort,
|
tStart: p.TargetPort,
|
||||||
|
|
|
@ -139,7 +139,10 @@ func (c *taskContext) Ports() string {
|
||||||
}
|
}
|
||||||
ports := []string{}
|
ports := []string{}
|
||||||
for _, pConfig := range c.task.Status.PortStatus.Ports {
|
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.PublishedPort,
|
||||||
pConfig.TargetPort,
|
pConfig.TargetPort,
|
||||||
pConfig.Protocol,
|
pConfig.Protocol,
|
||||||
|
|
Loading…
Reference in New Issue