Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,12 @@ def parse_host(addr, platform=None, tls=False):

if addr == 'tcp://':
raise errors.DockerException(
"Invalid bind address format: {0}".format(addr))
"Invalid bind address format: {0}".format(addr)
)
elif addr.startswith('unix://'):
addr = addr[7:]
elif addr.startswith('tcp://'):
proto = "http"
proto = 'http{0}'.format('s' if tls else '')
addr = addr[6:]
elif addr.startswith('https://'):
proto = "https"
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,12 @@ def test_parse_host_empty_value(self):
def test_parse_host_tls(self):
host_value = 'myhost.docker.net:3348'
expected_result = 'https://myhost.docker.net:3348'
self.assertEqual(parse_host(host_value, None, True), expected_result)
assert parse_host(host_value, tls=True) == expected_result

def test_parse_host_tls_tcp_proto(self):
host_value = 'tcp://myhost.docker.net:3348'
expected_result = 'https://myhost.docker.net:3348'
assert parse_host(host_value, tls=True) == expected_result


class ParseRepositoryTagTest(base.BaseTestCase):
Expand Down