[libvirt] [jenkins-ci PATCH v2 17/20] quayadmin: Add list-tags command

Andrea Bolognani posted 20 patches 6 years, 5 months ago
[libvirt] [jenkins-ci PATCH v2 17/20] quayadmin: Add list-tags command
Posted by Andrea Bolognani 6 years, 5 months ago
The implementation is limited in that it will not work
properly if a repository contains more than 100 tags, but
that's not really a big concern for us as each repository is
only going to contain a single tag (latest).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 guests/quayadmin | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/guests/quayadmin b/guests/quayadmin
index f71ad2d..aa897f9 100755
--- a/guests/quayadmin
+++ b/guests/quayadmin
@@ -180,6 +180,26 @@ def run_delete_repo(config, args):
     print("Repository {}/{} deleted".format(args.namespace, args.repo))
 
 
+def run_list_tags(config, args):
+    endpoint = "/repository/{}/{}/tag".format(args.namespace, args.repo)
+    params = {
+        "onlyActiveTags": True,
+        "limit": 100,
+    }
+
+    res = get(config, endpoint, params=params, debug=args.debug)
+
+    if has_error(args.quiet, res, 200,
+                 "Cannot list tags for repository {}/{}"
+                 .format(args.namespace, args.repo)):
+        return 1
+
+    info = res.json()
+
+    for tag in info["tags"]:
+        print ("{}".format(tag["name"]))
+
+
 def run_list_builds(config, args):
     endpoint = "/repository/{}/{}/build".format(args.namespace, args.repo)
 
@@ -345,6 +365,15 @@ def build_parser_delete_repo(subparser):
     add_arg_repo(parser)
 
 
+def build_parser_list_tags(subparser):
+    parser = subparser.add_parser("list-tags", help="List repository tags")
+
+    parser.set_defaults(func=run_list_tags)
+
+    add_arg_namespace(parser)
+    add_arg_repo(parser)
+
+
 def build_parser_list_builds(subparser):
     parser = subparser.add_parser("list-builds", help="List repository builds")
 
@@ -410,6 +439,8 @@ def build_parser():
     build_parser_create_repo(subparser)
     build_parser_delete_repo(subparser)
 
+    build_parser_list_tags(subparser)
+
     build_parser_list_builds(subparser)
     build_parser_show_build(subparser)
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH v2 17/20] quayadmin: Add list-tags command
Posted by Daniel P. Berrangé 6 years, 5 months ago
On Wed, Jul 17, 2019 at 03:49:26PM +0200, Andrea Bolognani wrote:
> The implementation is limited in that it will not work
> properly if a repository contains more than 100 tags, but
> that's not really a big concern for us as each repository is
> only going to contain a single tag (latest).
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  guests/quayadmin | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list