-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add support to get docker image tag list #446
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create dedicated classes for that, something like ArtifactoryDockerRepo
and ArtifactoryDockerImage
, so it'd be possible to use it this way
arti = ArtifactoryPath("....", username, password)
repo: ArtifactoryDockerRepo = arti.docker_repo("reponame")
repo.images: Iterable[ArtifactoryDockerImage]
for image in repo.images:
image: ArtifactoryDockerImage
for tag in image.tags:
tag: ArtifactoryDockerImageTag
print(f"Removing {image.name} - {image.tag}")
tag.delete()
Right now it looks just like a simple API client
We could place it somewhere in new dohq_artifactory.docker
, because it has nothing to do with ArtifactoryPath
, but it can use it under the hood, like a client
https://github.com/devopshq/artifactory/tree/master/dohq_artifactory
Thanks for your review. This change is similar to Lines 1290 to 1293 in b116902
The original thought is that I want to migrate the Docker image from Artifactory to Nexus, but currently, there is no out-of-box way to get a full list of docker image tag. With this PR, I can do it as below. from artifactory import ArtifactoryPath
url = 'https://artifactory.example.com/artifactory'
apikey = 'foo'
p = ArtifactoryPath(url, apikey=apikey)
docker_repo = 'foo'
registry_arti = 'artifactory.example.com'
registry_nexus = 'nexus.example.com'
registry_nexus_repo = 'example-docker-preprod-local'
for docker_image in p.get_docker_images(docker_repo):
for docker_image_tag in p.get_docker_image_tags(docker_repo, docker_image):
src = f'{registry_arti}/{docker_repo}/{docker_image}:{docker_image_tag}'
dst = f'{registry_nexus}/{registry_nexus_repo}/{docker_repo}/{docker_image}:{docker_image_tag}'
cmd = f'skopeo copy docker://{src} docker://{dst}'
print(cmd) Let me know if you have any concern. |
That is not the approach we should go in the library, sorry. The script looks simple, anyone can implement it with pure python, it doesn't give any pros to using it in object related way. It's fine to have such method in some sort of Accessor or ArtifactoryAPI , but no in the top level |
Thank you all the same |
Get docker image list
Reference: