Skip to content

Commit

Permalink
bug: use quay.io tags api endpoint to list tags
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch committed Mar 18, 2024
1 parent 4870b9f commit a3764b3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pip. Only major versions will be released as tags on Github.

## [0.0.x](https://github.com/singularityhub/singularity-hpc/tree/main) (0.0.x)
- use quay.io api to list tags since does not conform to oci (0.1.28)
- filter out vex and sbom tags (0.1.27)
- unpin yaml dependency (0.1.26)
- Change format of config command output to only show setting values, not keys, for parseability (0.1.25)
Expand Down
24 changes: 24 additions & 0 deletions shpc/main/container/update/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,37 @@ def tags(self):
"""
Get image tags.
"""
# Quay does not follow the distribution spec, crane only returns 50
if "quay.io" in self.container_name:
return self.tags_quay()

url = "%s/ls/%s" % (self.apiroot, self.container_name)
response = self.get_request(url)
tags = [x.strip() for x in response.text.split("\n") if x.strip()]
# Don't include tags for vex or sbom
tags = [x for x in tags if not re.search("[.](sbom|vex)$", x)]
return tags

def tags_quay(self):
"""
Custom endpoint to handle quay and pagination.
"""
repository = self.container_name.replace("quay.io/", "", 1)
page = 1
tags = []
has_more = True
while has_more:
url = f"https://quay.io/api/v1/repository/{repository}/tag/?limit=100&page={page}"
response = self.get_request(url).json()
new_tags = [
x.get("name") for x in response.get("tags", {}) if x.get("name")
]
new_tags = [x for x in new_tags if not re.search("[.](sbom|vex)$", x)]
tags += new_tags
has_more = response.get("has_additional") is True
page += 1
return tags

def manifest(self, tag):
url = "%s/manifest/%s:%s" % (self.apiroot, self.container_name, tag)
response = self.get_request(url)
Expand Down
2 changes: 1 addition & 1 deletion shpc/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__copyright__ = "Copyright 2021-2024, Vanessa Sochat"
__license__ = "MPL 2.0"

__version__ = "0.1.27"
__version__ = "0.1.28"
AUTHOR = "Vanessa Sochat"
EMAIL = "[email protected]"
NAME = "singularity-hpc"
Expand Down

0 comments on commit a3764b3

Please sign in to comment.