From c62d5ec226c40614d25ebcd6698a9f596ba3a8b8 Mon Sep 17 00:00:00 2001 From: Chen Hanxiao Date: Fri, 6 Feb 2015 14:07:17 +0800 Subject: [PATCH 1/2] nat: enable upper case proto We only accepted lower case proto: tcp, udp. This patch will enable us to use upper case of proto such as: EXPOSE 1234/TCP Signed-off-by: Chen Hanxiao Upstream-commit: 270642643452b440b159216d843ea4fc2239ff4f Component: engine --- components/engine/nat/nat.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/nat/nat.go b/components/engine/nat/nat.go index 8f2e90e668..fdecf3f9d1 100644 --- a/components/engine/nat/nat.go +++ b/components/engine/nat/nat.go @@ -140,7 +140,7 @@ func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding, return nil, nil, fmt.Errorf("Invalid ranges specified for container and host Ports: %s and %s", containerPort, hostPort) } - if !validateProto(proto) { + if !validateProto(strings.ToLower(proto)) { return nil, nil, fmt.Errorf("Invalid proto: %s", proto) } @@ -149,7 +149,7 @@ func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding, if len(hostPort) > 0 { hostPort = strconv.FormatUint(startHostPort+i, 10) } - port := NewPort(proto, containerPort) + port := NewPort(strings.ToLower(proto), containerPort) if _, exists := exposedPorts[port]; !exists { exposedPorts[port] = struct{}{} } From 417c803e589bd03662c53858f2e85db82f75f599 Mon Sep 17 00:00:00 2001 From: Chen Hanxiao Date: Sun, 8 Feb 2015 07:04:22 +0800 Subject: [PATCH 2/2] docker_cli_build_test: add testcase of EXPOSE 5678/UDP test whether we could use upper case proto in EXPOSE Signed-off-by: Chen Hanxiao Upstream-commit: 0552f1a0caf8f8e57736d05c2ed42f82e97df5f6 Component: engine --- .../integration-cli/docker_cli_build_test.go | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/components/engine/integration-cli/docker_cli_build_test.go b/components/engine/integration-cli/docker_cli_build_test.go index fad38317ef..14fa5f01a4 100644 --- a/components/engine/integration-cli/docker_cli_build_test.go +++ b/components/engine/integration-cli/docker_cli_build_test.go @@ -2293,6 +2293,27 @@ func TestBuildExposeOrder(t *testing.T) { logDone("build - expose order") } +func TestBuildExposeUpperCaseProto(t *testing.T) { + name := "testbuildexposeuppercaseproto" + expected := "map[5678/udp:map[]]" + defer deleteImages(name) + _, err := buildImage(name, + `FROM scratch + EXPOSE 5678/UDP`, + true) + if err != nil { + t.Fatal(err) + } + res, err := inspectField(name, "Config.ExposedPorts") + if err != nil { + t.Fatal(err) + } + if res != expected { + t.Fatalf("Exposed ports %s, expected %s", res, expected) + } + logDone("build - expose port with upper case proto") +} + func TestBuildEmptyEntrypointInheritance(t *testing.T) { name := "testbuildentrypointinheritance" name2 := "testbuildentrypointinheritance2"