Skip to content

Commit 52a80f8

Browse files
authored
Merge pull request #671 from singularityhub/list-tags
bug: use quay.io tags api endpoint to list tags
2 parents 4870b9f + a3764b3 commit 52a80f8

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
1414
The versions coincide with releases on pip. Only major versions will be released as tags on Github.
1515

1616
## [0.0.x](https://github.com/singularityhub/singularity-hpc/tree/main) (0.0.x)
17+
- use quay.io api to list tags since does not conform to oci (0.1.28)
1718
- filter out vex and sbom tags (0.1.27)
1819
- unpin yaml dependency (0.1.26)
1920
- Change format of config command output to only show setting values, not keys, for parseability (0.1.25)

shpc/main/container/update/docker.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,37 @@ def tags(self):
3434
"""
3535
Get image tags.
3636
"""
37+
# Quay does not follow the distribution spec, crane only returns 50
38+
if "quay.io" in self.container_name:
39+
return self.tags_quay()
40+
3741
url = "%s/ls/%s" % (self.apiroot, self.container_name)
3842
response = self.get_request(url)
3943
tags = [x.strip() for x in response.text.split("\n") if x.strip()]
4044
# Don't include tags for vex or sbom
4145
tags = [x for x in tags if not re.search("[.](sbom|vex)$", x)]
4246
return tags
4347

48+
def tags_quay(self):
49+
"""
50+
Custom endpoint to handle quay and pagination.
51+
"""
52+
repository = self.container_name.replace("quay.io/", "", 1)
53+
page = 1
54+
tags = []
55+
has_more = True
56+
while has_more:
57+
url = f"https://quay.io/api/v1/repository/{repository}/tag/?limit=100&page={page}"
58+
response = self.get_request(url).json()
59+
new_tags = [
60+
x.get("name") for x in response.get("tags", {}) if x.get("name")
61+
]
62+
new_tags = [x for x in new_tags if not re.search("[.](sbom|vex)$", x)]
63+
tags += new_tags
64+
has_more = response.get("has_additional") is True
65+
page += 1
66+
return tags
67+
4468
def manifest(self, tag):
4569
url = "%s/manifest/%s:%s" % (self.apiroot, self.container_name, tag)
4670
response = self.get_request(url)

shpc/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__copyright__ = "Copyright 2021-2024, Vanessa Sochat"
33
__license__ = "MPL 2.0"
44

5-
__version__ = "0.1.27"
5+
__version__ = "0.1.28"
66
AUTHOR = "Vanessa Sochat"
77
88
NAME = "singularity-hpc"

0 commit comments

Comments
 (0)