mirror of https://github.com/docker/cli.git
Make --publish-rm precedes --publish-add, so that add wins
`--publish-add 8081:81 --publish-add 8082:82 --publish-rm 80 --publish-rm 81/tcp --publish-rm 82/tcp` would thus result in 81 and 82 to be published. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
016a56b064
commit
16bbd3441a
|
@ -82,6 +82,14 @@ func (p *PortOpt) Set(value string) error {
|
|||
return fmt.Errorf("missing mandatory field %q", portOptTargetPort)
|
||||
}
|
||||
|
||||
if pConfig.PublishMode == "" {
|
||||
pConfig.PublishMode = swarm.PortConfigPublishModeIngress
|
||||
}
|
||||
|
||||
if pConfig.Protocol == "" {
|
||||
pConfig.Protocol = swarm.PortConfigProtocolTCP
|
||||
}
|
||||
|
||||
p.ports = append(p.ports, pConfig)
|
||||
} else {
|
||||
// short syntax
|
||||
|
@ -131,6 +139,7 @@ func ConvertPortToPortConfig(
|
|||
Protocol: swarm.PortConfigProtocol(strings.ToLower(port.Proto())),
|
||||
TargetPort: uint32(port.Int()),
|
||||
PublishedPort: uint32(hostPort),
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
})
|
||||
}
|
||||
return ports
|
||||
|
|
|
@ -18,6 +18,7 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
|
|||
{
|
||||
Protocol: "tcp",
|
||||
TargetPort: 80,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -28,6 +29,7 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
|
|||
Protocol: "tcp",
|
||||
TargetPort: 8080,
|
||||
PublishedPort: 80,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -38,6 +40,7 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
|
|||
Protocol: "tcp",
|
||||
TargetPort: 80,
|
||||
PublishedPort: 8080,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -48,6 +51,7 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
|
|||
Protocol: "udp",
|
||||
TargetPort: 8080,
|
||||
PublishedPort: 80,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -58,11 +62,13 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
|
|||
Protocol: "tcp",
|
||||
TargetPort: 8080,
|
||||
PublishedPort: 80,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
{
|
||||
Protocol: "tcp",
|
||||
TargetPort: 8081,
|
||||
PublishedPort: 81,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -73,16 +79,19 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
|
|||
Protocol: "udp",
|
||||
TargetPort: 8080,
|
||||
PublishedPort: 80,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
{
|
||||
Protocol: "udp",
|
||||
TargetPort: 8081,
|
||||
PublishedPort: 81,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
{
|
||||
Protocol: "udp",
|
||||
TargetPort: 8082,
|
||||
PublishedPort: 82,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -107,6 +116,8 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
|
|||
expected: []swarm.PortConfig{
|
||||
{
|
||||
TargetPort: 80,
|
||||
Protocol: "tcp",
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -116,6 +127,7 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
|
|||
{
|
||||
Protocol: "tcp",
|
||||
TargetPort: 80,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -126,6 +138,7 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
|
|||
Protocol: "tcp",
|
||||
TargetPort: 80,
|
||||
PublishedPort: 8080,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -136,6 +149,7 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
|
|||
Protocol: "tcp",
|
||||
TargetPort: 8080,
|
||||
PublishedPort: 80,
|
||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -157,6 +171,7 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
|
|||
TargetPort: 80,
|
||||
PublishedPort: 8080,
|
||||
PublishMode: "host",
|
||||
Protocol: "tcp",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -167,6 +182,7 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
|
|||
TargetPort: 80,
|
||||
PublishedPort: 8080,
|
||||
PublishMode: "ingress",
|
||||
Protocol: "tcp",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue