From b6ad3a90484c4bd43f9258396ca310f38ab5a770 Mon Sep 17 00:00:00 2001 From: Jack Zhang Date: Wed, 6 Mar 2024 18:36:57 +0800 Subject: [PATCH] add support for docker image operation --- artifactory.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/artifactory.py b/artifactory.py index 21247db..13354bd 100755 --- a/artifactory.py +++ b/artifactory.py @@ -2321,6 +2321,33 @@ def from_aql(self, result): ) return obj + def get_docker_images(self, docker_repo): + """ + Get Docker image list from docker repo + :param docker_repo: Docker repository to list + :return: List[image] + """ + url = f"{self.drive.rstrip('/')}/api/docker/{docker_repo}/v2/_catalog" + r = self.session.get(url) + raise_for_status(r) + content = r.json() + + return content["repositories"] + + def get_docker_image_tags(self, docker_repo, docker_image): + """ + Get Docker image list from docker repo + :param docker_repo: Docker repository + :param docker_image: Docker image to list + :return: List[tag] + """ + url = f"{self.drive.rstrip('/')}/api/docker/{docker_repo}/v2/{docker_image}/tags/list" + r = self.session.get(url) + raise_for_status(r) + content = r.json() + + return content["tags"] + def promote_docker_image( self, source_repo,