Skip to content

Commit

Permalink
Replace "+" by "-" in default_image_name to get valid docker tag
Browse files Browse the repository at this point in the history
"+" are valid in Python versions according to PEP 440 but docker
tags must be valid ASCII and may contain lowercase and uppercase
letters, digits, underscores, periods and dashes
  • Loading branch information
xavfernandez committed Nov 28, 2018
1 parent 70c0674 commit 3ad1f16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ChangeLog
6.5 (unreleased)
----------------

- Nothing changed yet.
- Replace "+" signs in python versions by "-" in default image name


6.4 (2018-11-28)
Expand Down
5 changes: 4 additions & 1 deletion src/grocker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def default_image_name(config, req):
else:
img_name = req.project_name
img_name += ":{project_version}".format(
project_version=req.version,
# Python versions might contain "+"
# but a docker tag name must be valid ASCII and may contain lowercase and uppercase
# letters, digits, underscores, periods and dashes
project_version=req.version.replace('+', '-'),
)
return '/'.join((docker_image_prefix, img_name)) if docker_image_prefix else img_name

Expand Down
6 changes: 6 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def test_default_image_name(self):
releases = (
'grocker-test-project==2.0.0',
'grocker-test-project[pep8]==2.0.0',
'grocker-test-project[pep8, other_extra]==2.0.0+git1234',
filepath,
)
image_names = (None, 'demo-app')
Expand All @@ -164,6 +165,11 @@ def test_default_image_name(self):
'registry.local/grocker-test-project-pep8:2.0.0',
'demo-app:2.0.0',
'registry.local/demo-app:2.0.0',
# with several extras and + sign
'grocker-test-project-other_extra-pep8:2.0.0-git1234',
'registry.local/grocker-test-project-other_extra-pep8:2.0.0-git1234',
'demo-app:2.0.0-git1234',
'registry.local/demo-app:2.0.0-git1234',
# from path
'grocker-test-project:1.2.3',
'registry.local/grocker-test-project:1.2.3',
Expand Down

0 comments on commit 3ad1f16

Please sign in to comment.