Skip to content

Commit

Permalink
validation: check for whitespaces in the image specification
Browse files Browse the repository at this point in the history
  • Loading branch information
audrium committed May 6, 2022
1 parent 4d1ba19 commit e0a03a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Version 0.9.0 (UNRELEASED)
--------------------------

- Changes REANA specification loading and validation functionality by porting some of the logic to ``reana-commons``.
- Fixes ``validate --environment`` command to detect illegal white space characters in image names.

Version 0.8.2 (UNRELEASED)
--------------------------
Expand Down
4 changes: 4 additions & 0 deletions reana_client/validation/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ def _validate_image_tag(self, image):
"type": "success",
"message": "Environment image {} has the correct format.".format(image),
}
if " " in image:
raise EnvironmentValidationError(
f"Environment image '{image}' contains illegal characters."
)
if ":" in image:
environment = image.split(":", 1)
image_name, image_tag = environment[0], environment[-1]
Expand Down
1 change: 1 addition & 0 deletions tests/test_validate_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
("foo:master", "tag is not recommended", False),
("foo:bar:baz", "has invalid tag", True),
("foo:bar:", "has invalid tag", True),
("foo:bar ", "contains illegal characters", True),
],
)
def test_validate_environment_image_tag(image, output, exit_):
Expand Down

0 comments on commit e0a03a0

Please sign in to comment.