[jenkins-ci PATCH 18/20] quayadmin: Add show-tag command

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

 



The implementation is a bit awkward and surprising because the

  GET /api/v1/repository/{repository}/tag/{tag}/images

API does not report the information we're looking form in an
easy to consume form. It also suffers from the same limitations
as the list-tags command.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 guests/quayadmin | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/guests/quayadmin b/guests/quayadmin
index 5481e3f..69282da 100755
--- a/guests/quayadmin
+++ b/guests/quayadmin
@@ -193,6 +193,40 @@ def run_list_tags(config, args):
         print ("{}".format(tag["name"]))
 
 
+def run_show_tag(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()
+
+    image = None
+    for tag in info["tags"]:
+        if tag["name"] == args.tag:
+            image = tag["image_id"]
+            break
+
+    if image is not None:
+        print("tag:")
+        print("  namespace: {}".format(args.namespace))
+        print("  repo: {}".format(args.repo))
+        print("  id: {}".format(args.tag))
+        print("  image: {}".format(image))
+    else:
+        print("Cannot query tag {} for repository {}/{}: Not Found (404)"
+              .format(args.tag, args.namespace, args.repo))
+        return 1
+
+
 def run_list_builds(config, args):
     endpoint = "/repository/{}/{}/build".format(args.namespace, args.repo)
 
@@ -314,6 +348,10 @@ def add_arg_build(parser):
     parser.add_argument("build", help="Build ID")
 
 
+def add_arg_tag(parser):
+    parser.add_argument("tag", help="Tag ID")
+
+
 def build_parser_list_repos(subparser):
     parser = subparser.add_parser("list-repos", help="List container repositories")
 
@@ -359,6 +397,16 @@ def build_parser_list_tags(subparser):
     add_arg_repo(parser)
 
 
+def build_parser_show_tag(subparser):
+    parser = subparser.add_parser("show-tag", help="Show tag information")
+
+    parser.set_defaults(func=run_show_tag)
+
+    add_arg_namespace(parser)
+    add_arg_repo(parser)
+    add_arg_tag(parser)
+
+
 def build_parser_list_builds(subparser):
     parser = subparser.add_parser("list-builds", help="List repository builds")
 
@@ -425,6 +473,7 @@ def build_parser():
     build_parser_delete_repo(subparser)
 
     build_parser_list_tags(subparser)
+    build_parser_show_tag(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