diff options
author | Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> | 2020-07-13 20:51:18 +0900 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-07-22 14:15:30 -0400 |
commit | 9c8ffc4615d178bd21e18347128e10ca5ca5d7d8 (patch) | |
tree | ee13f7f0a84ea78200218256387cb2c97aa9d495 | |
parent | c6852ee516abe3e1c4e5e31168d85d7cd446ce36 (diff) | |
download | podman-9c8ffc4615d178bd21e18347128e10ca5ca5d7d8.tar.gz podman-9c8ffc4615d178bd21e18347128e10ca5ca5d7d8.tar.bz2 podman-9c8ffc4615d178bd21e18347128e10ca5ca5d7d8.zip |
Fix "Error: unrecognized protocol \"TCP\" in port mapping"
"TCP" in upper characters was not recognized as a valid protocol name.
Fix #6948
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
-rw-r--r-- | pkg/specgen/generate/ports.go | 1 | ||||
-rw-r--r-- | test/e2e/run_networking_test.go | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go index 9412ecfbf..c8d1c27c5 100644 --- a/pkg/specgen/generate/ports.go +++ b/pkg/specgen/generate/ports.go @@ -356,6 +356,7 @@ func checkProtocol(protocol string, allowSCTP bool) ([]string, error) { splitProto := strings.Split(protocol, ",") // Don't error on duplicates - just deduplicate for _, p := range splitProto { + p = strings.ToLower(p) switch p { case protoTCP, "": protocols[protoTCP] = struct{}{} diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 6c049c5c1..9357145ab 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -88,6 +88,20 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) }) + It("podman run -p 8080:80/TCP", func() { + name := "testctr" + // "TCP" in upper characters + session := podmanTest.Podman([]string{"create", "-t", "-p", "8080:80/TCP", "--name", name, ALPINE, "/bin/sh"}) + session.WaitWithDefaultTimeout() + inspectOut := podmanTest.InspectContainer(name) + Expect(len(inspectOut)).To(Equal(1)) + Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) + // "tcp" in lower characters + Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8080")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + }) + It("podman run -p 80/udp", func() { name := "testctr" session := podmanTest.Podman([]string{"create", "-t", "-p", "80/udp", "--name", name, ALPINE, "/bin/sh"}) |