Closed zhan9san closed 6 months ago
Thanks for your review.
This change is similar to get_properties
method.
https://github.com/devopshq/artifactory/blob/b1169024750ee7a3e567d5493d2d9652d5c47918/artifactory.py#L1290-L1293
a simple API client
can works fine. Maybe it is the PR title makes you confused. I'd like to change it to Add support to get docker image tag list
.
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.
a simple API client can works fine.
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 ArtifactoryPath
, this one should be as much as possible class based and give some additional types to help developers understand the underlying relationships.
Thank you all the same
Get docker image list
Reference: