aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Williams <nath.e.will@gmail.com>2018-04-17 16:02:37 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-18 10:58:24 +0000
commit94f20cdd00149edf35e3963cc95d8a5cc8c7dd12 (patch)
treea2746f787830e79c74f9d2697f1f7a1ff244c77e
parent96d11622c60e80e706c7bc18a096dc0a762f3e9f (diff)
downloadpodman-94f20cdd00149edf35e3963cc95d8a5cc8c7dd12.tar.gz
podman-94f20cdd00149edf35e3963cc95d8a5cc8c7dd12.tar.bz2
podman-94f20cdd00149edf35e3963cc95d8a5cc8c7dd12.zip
- reverse host field order (ip goes first)
- fix host string split to permit IPv6 Signed-off-by: Nathan Williams <nath.e.will@gmail.com> Closes: #635 Approved by: rhatdan
-rw-r--r--libpod/container_internal.go4
-rw-r--r--test/e2e/run_dns_test.go5
2 files changed, 5 insertions, 4 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index e0411e028..414def120 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -901,8 +901,8 @@ func (c *Container) generateHosts() (string, error) {
if len(c.config.HostAdd) > 0 {
for _, host := range c.config.HostAdd {
// the host format has already been verified at this point
- fields := strings.Split(host, ":")
- hosts += fmt.Sprintf("%s %s\n", fields[0], fields[1])
+ fields := strings.SplitN(host, ":", 2)
+ hosts += fmt.Sprintf("%s %s\n", fields[1], fields[0])
}
}
return c.writeStringToRundir("hosts", hosts)
diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go
index 27ca1e556..cfe6a34a2 100644
--- a/test/e2e/run_dns_test.go
+++ b/test/e2e/run_dns_test.go
@@ -62,10 +62,11 @@ var _ = Describe("Podman run dns", func() {
})
It("podman run add host", func() {
- session := podmanTest.Podman([]string{"run", "--add-host=foobar:1.1.1.1", ALPINE, "cat", "/etc/hosts"})
+ session := podmanTest.Podman([]string{"run", "--add-host=foobar:1.1.1.1", "--add-host=foobaz:dead:beef:cafe", ALPINE, "cat", "/etc/hosts"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session.LineInOuputStartsWith("foobar 1.1.1.1")
+ session.LineInOuputStartsWith("1.1.1.1 foobar")
+ session.LineInOuputStartsWith("dead:beef:cafe foobaz")
})
It("podman run add hostname", func() {