Skip to content

Commit

Permalink
Allow digests to be specified for DE
Browse files Browse the repository at this point in the history
  • Loading branch information
zkayyali812 committed Jan 15, 2025
1 parent 6861a5e commit 8c2e523
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/aap_eda/core/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@ def check_if_de_valid(image_url: str, eda_credential_id: int):
% {"image_url": image_url}
)

split = path.split(":", 1)
name = split[0]
digest = False
if "@sha256" in path:
split = path.split("@", 1)
name = split[0]
digest = True
else:
split = path.split(":", 1)
name = split[0]
# Get the tag sans any additional content. Any additional content
# is passed without validation.
tag = split[1] if (len(split) > 1) else None
Expand All @@ -121,7 +127,7 @@ def check_if_de_valid(image_url: str, eda_credential_id: int):
% {"image_url": image_url, "name": name}
)

if (tag is not None) and (
if (not digest and tag is not None) and (
not re.fullmatch(r"[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}", tag)
):
raise serializers.ValidationError(
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/api/test_decision_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ def test_create_decision_environment_with_empty_credential(
"registry.com/group/img1:latest",
"",
),
(
status.HTTP_201_CREATED,
"registry.com/group/img1@sha256:6e8985d6c50cf2eb577f17237ef9c05baa9c2f472a730f13784728cec1fdfab1", # noqa: E501
"",
),
(
status.HTTP_400_BAD_REQUEST,
"https://registry.com/group/img1:latest",
Expand Down

0 comments on commit 8c2e523

Please sign in to comment.