From: Michael Tremer Date: Mon, 10 Feb 2025 10:49:00 +0000 (+0000) Subject: registry: Add a tags handler X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f2afca68ec7f87ceb77056fd449f38ed6128f045;p=pbs.git registry: Add a tags handler This lists all available tags Signed-off-by: Michael Tremer --- diff --git a/src/web/__init__.py b/src/web/__init__.py index 0d0da656..e5a07af7 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -214,6 +214,10 @@ class Application(tornado.web.Application): (r"/v2/([a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*)*)/blobs/(sha256:[a-f0-9]{64})", registry.ManifestHandler), + # Tags + (r"/v2/([a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*)*)/tags/list", + registry.TagsHandler), + # Catch anything else (r"/v2/.*", registry.NotFoundHandler), ]) diff --git a/src/web/registry.py b/src/web/registry.py index 3c270040..df93b3bf 100644 --- a/src/web/registry.py +++ b/src/web/registry.py @@ -237,3 +237,23 @@ class BlobHandler(BaseHandler): # Send the blob! if send_body: await self.stream_blob(blob) + + +class TagsHandler(BaseHandler): + async def get(self, distro_slug): + # Fetch the distribution + distro = await self.backend.distros.get_by_slug(distro_slug) + if not distro: + raise NameUnknownError + + tags = [ + "latest", + ] + + for release in await distro.get_releases(): + tags.append(release.slug) + + self.finish({ + "name" : distro.slug, + "tags" : tags, + })