Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: use quay.io tags api endpoint to list tags #671

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading