Skip to content

Commit 7054b46

Browse files
Merge pull request #555 from Alex-Izquierdo/fix-digest
fix: move digest label to the repository instead of tag
2 parents 108d9f3 + 34a7f0f commit 7054b46

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

podman/api/parse_utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@
1313

1414

1515
def parse_repository(name: str) -> tuple[str, Optional[str]]:
16-
"""Parse repository image name from tag or digest
16+
"""Parse repository image name from tag.
1717
1818
Returns:
1919
item 1: repository name
20-
item 2: Either digest and tag, tag, or None
20+
item 2: Either tag or None
2121
"""
22-
# split image name and digest
23-
elements = name.split("@", 1)
24-
if len(elements) == 2:
25-
return elements[0], elements[1]
26-
2722
# split repository and image name from tag
2823
# tags need to be split from the right since
2924
# a port number might increase the split list len by 1

podman/domain/registry_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def pull(self, platform: Optional[str] = None) -> Image:
4040
Args:
4141
platform: Platform for which to pull Image. Default: None (all platforms.)
4242
"""
43-
repository = api.parse_repository(self.image_name)
43+
repository, _ = api.parse_repository(self.image_name)
4444
return self.manager.pull(repository, tag=self.id, platform=platform)
4545

4646
def has_platform(self, platform: Union[str, Mapping[str, Any]]) -> bool:

podman/tests/unit/test_parse_utils.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,39 @@ class TestCase:
2929
),
3030
TestCase(
3131
name="@digest",
32-
input="quay.io/libpod/testimage@71f1b47263fc",
33-
expected=("quay.io/libpod/testimage", "71f1b47263fc"),
32+
input="quay.io/libpod/testimage@sha256:71f1b47263fc",
33+
expected=("quay.io/libpod/testimage@sha256", "71f1b47263fc"),
3434
),
3535
TestCase(
3636
name=":tag",
3737
input="quay.io/libpod/testimage:latest",
3838
expected=("quay.io/libpod/testimage", "latest"),
3939
),
40+
TestCase(
41+
name=":tag@digest",
42+
input="quay.io/libpod/testimage:latest@sha256:71f1b47263fc",
43+
expected=("quay.io/libpod/testimage:latest@sha256", "71f1b47263fc"),
44+
),
4045
TestCase(
4146
name=":port",
4247
input="quay.io:5000/libpod/testimage",
4348
expected=("quay.io:5000/libpod/testimage", None),
4449
),
4550
TestCase(
4651
name=":port@digest",
47-
input="quay.io:5000/libpod/testimage@71f1b47263fc",
48-
expected=("quay.io:5000/libpod/testimage", "71f1b47263fc"),
52+
input="quay.io:5000/libpod/testimage@sha256:71f1b47263fc",
53+
expected=("quay.io:5000/libpod/testimage@sha256", "71f1b47263fc"),
4954
),
5055
TestCase(
5156
name=":port:tag",
5257
input="quay.io:5000/libpod/testimage:latest",
5358
expected=("quay.io:5000/libpod/testimage", "latest"),
5459
),
60+
TestCase(
61+
name=":port:tag:digest",
62+
input="quay.io:5000/libpod/testimage:latest@sha256:71f1b47263fc",
63+
expected=("quay.io:5000/libpod/testimage:latest@sha256", "71f1b47263fc"),
64+
),
5565
]
5666

5767
for case in cases:

0 commit comments

Comments
 (0)