Merge "Fix hostname of docker image"

This commit is contained in:
Zuul 2019-01-07 01:58:38 +00:00 committed by Gerrit Code Review
commit d4b48e7b05
2 changed files with 12 additions and 2 deletions

View File

@ -72,6 +72,12 @@ class Reference(dict):
matches = matched.groups()
if len(matches) != 2:
return '', name
hostname = matches[0]
if hostname is None:
return '', name
if ('.' not in hostname and ':' not in hostname and
hostname != 'localhost'):
return '', name
return matches[0], matches[1]

View File

@ -74,7 +74,7 @@ class TestReference(base.BaseTestCase):
create_test_case(input_='{}a:tag-puts-this-over-max'.
format('a/' * 127),
repository='{}a'.format('a/' * 127),
hostname='a',
hostname='',
tag='tag-puts-this-over-max'),
create_test_case(input_='aa/asdf$$^/aa',
err=reference.ReferenceInvalidFormat),
@ -106,12 +106,16 @@ class TestReference(base.BaseTestCase):
tag='8080'),
create_test_case(input_='foo/foo_bar.com:8080',
repository='foo/foo_bar.com',
hostname='foo',
hostname='',
tag='8080'),
create_test_case(input_='test.com/foo',
repository='test.com/foo',
hostname='test.com',
path='foo'),
create_test_case(input_='test_com/foo',
repository='test_com/foo',
hostname='',
path='test_com/foo'),
create_test_case(input_='test:8080/foo',
repository='test:8080/foo',
hostname='test:8080',