Skip to content

Commit 3320cd0

Browse files
committed
Allow digests to be specified for DE
1 parent 65a64d4 commit 3320cd0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/aap_eda/core/validators.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ def check_if_de_valid(image_url: str, eda_credential_id: int):
102102
% {"image_url": image_url}
103103
)
104104

105-
split = path.split(":", 1)
106-
name = split[0]
105+
digest = False
106+
if "@sha256" in path:
107+
split = path.split("@", 1)
108+
name = split[0]
109+
digest = True
110+
else:
111+
split = path.split(":", 1)
112+
name = split[0]
107113
# Get the tag sans any additional content. Any additional content
108114
# is passed without validation.
109115
tag = split[1] if (len(split) > 1) else None
@@ -121,7 +127,7 @@ def check_if_de_valid(image_url: str, eda_credential_id: int):
121127
% {"image_url": image_url, "name": name}
122128
)
123129

124-
if (tag is not None) and (
130+
if (not digest and tag is not None) and (
125131
not re.fullmatch(r"[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}", tag)
126132
):
127133
raise serializers.ValidationError(

tests/integration/api/test_decision_environment.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ def test_create_decision_environment_with_empty_credential(
345345
"registry.com/group/img1:latest",
346346
"",
347347
),
348+
(
349+
status.HTTP_201_CREATED,
350+
"registry.com/group/img1@sha256:6e8985d6c50cf2eb577f17237ef9c05baa9c2f472a730f13784728cec1fdfab1", # noqa: E501
351+
"",
352+
),
348353
(
349354
status.HTTP_400_BAD_REQUEST,
350355
"https://registry.com/group/img1:latest",

0 commit comments

Comments
 (0)