From 995006c164d0e60af7931484e689356e0e515576 Mon Sep 17 00:00:00 2001 From: Wataru Ishida Date: Wed, 14 Jun 2017 03:42:58 +0000 Subject: [PATCH] Support SCTP port mapping Signed-off-by: Wataru Ishida Signed-off-by: Akihiro Suda --- cli/command/formatter/container_test.go | 5 ++++- cli/command/formatter/service_test.go | 14 +++++++++++++- opts/port.go | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cli/command/formatter/container_test.go b/cli/command/formatter/container_test.go index 33d2d0bb1495..cccd6cb62dfb 100644 --- a/cli/command/formatter/container_test.go +++ b/cli/command/formatter/container_test.go @@ -642,9 +642,12 @@ func TestDisplayablePorts(t *testing.T) { PublicPort: 1024, PrivatePort: 80, Type: "udp", + }, { + PrivatePort: 12345, + Type: "sctp", }, }, - "80/tcp, 80/udp, 1024/tcp, 1024/udp, 1.1.1.1:1024->80/tcp, 1.1.1.1:1024->80/udp, 2.1.1.1:1024->80/tcp, 2.1.1.1:1024->80/udp, 1.1.1.1:80->1024/tcp, 1.1.1.1:80->1024/udp, 2.1.1.1:80->1024/tcp, 2.1.1.1:80->1024/udp", + "80/tcp, 80/udp, 1024/tcp, 1024/udp, 12345/sctp, 1.1.1.1:1024->80/tcp, 1.1.1.1:1024->80/udp, 2.1.1.1:1024->80/tcp, 2.1.1.1:1024->80/udp, 1.1.1.1:80->1024/tcp, 1.1.1.1:80->1024/udp, 2.1.1.1:80->1024/tcp, 2.1.1.1:80->1024/udp", }, } diff --git a/cli/command/formatter/service_test.go b/cli/command/formatter/service_test.go index ddedbd425a60..b05d806dfdf2 100644 --- a/cli/command/formatter/service_test.go +++ b/cli/command/formatter/service_test.go @@ -338,10 +338,22 @@ func TestServiceContext_Ports(t *testing.T) { PublishedPort: 62, PublishMode: "ingress", }, + { + Protocol: "sctp", + TargetPort: 97, + PublishedPort: 97, + PublishMode: "ingress", + }, + { + Protocol: "sctp", + TargetPort: 98, + PublishedPort: 98, + PublishMode: "ingress", + }, }, }, }, } - assert.Equal(t, "*:60-61->60-61/tcp, *:62->61/tcp, *:80-81->80/tcp, *:90-95->90-95/tcp, *:90-96->90-96/udp", c.Ports()) + assert.Equal(t, "*:97-98->97-98/sctp, *:60-61->60-61/tcp, *:62->61/tcp, *:80-81->80/tcp, *:90-95->90-95/tcp, *:90-96->90-96/udp", c.Ports()) } diff --git a/opts/port.go b/opts/port.go index 49ca7d0fe182..5a5a18738f1c 100644 --- a/opts/port.go +++ b/opts/port.go @@ -49,7 +49,7 @@ func (p *PortOpt) Set(value string) error { switch key { case portOptProtocol: - if value != string(swarm.PortConfigProtocolTCP) && value != string(swarm.PortConfigProtocolUDP) { + if value != string(swarm.PortConfigProtocolTCP) && value != string(swarm.PortConfigProtocolUDP) && value != string(swarm.PortConfigProtocolSCTP) { return fmt.Errorf("invalid protocol value %s", value) }