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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux