From ce9f2681a2be99ed97915674de9dd26e441298d4 Mon Sep 17 00:00:00 2001 From: Clemens Gutweiler Date: Thu, 7 Jan 2016 17:59:51 +0100 Subject: [PATCH] Fixes #1422: ipv6 addr contains colons, so we split only by the first char. Signed-off-by: Clemens Gutweiler --- compose/config/types.py | 2 +- tests/unit/config/types_test.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compose/config/types.py b/compose/config/types.py index cec1f6cfd..437f41205 100644 --- a/compose/config/types.py +++ b/compose/config/types.py @@ -58,7 +58,7 @@ def parse_extra_hosts(extra_hosts_config): extra_hosts_dict = {} for extra_hosts_line in extra_hosts_config: # TODO: validate string contains ':' ? - host, ip = extra_hosts_line.split(':') + host, ip = extra_hosts_line.split(':', 1) extra_hosts_dict[host.strip()] = ip.strip() return extra_hosts_dict diff --git a/tests/unit/config/types_test.py b/tests/unit/config/types_test.py index 4df665485..702aa977e 100644 --- a/tests/unit/config/types_test.py +++ b/tests/unit/config/types_test.py @@ -16,11 +16,13 @@ def test_parse_extra_hosts_list(): assert parse_extra_hosts([ "www.example.com: 192.168.0.17", "static.example.com:192.168.0.19", - "api.example.com: 192.168.0.18" + "api.example.com: 192.168.0.18", + "v6.example.com: ::1" ]) == { 'www.example.com': '192.168.0.17', 'static.example.com': '192.168.0.19', - 'api.example.com': '192.168.0.18' + 'api.example.com': '192.168.0.18', + 'v6.example.com': '::1' }