Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/quayadmin | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/guests/quayadmin b/guests/quayadmin
index de88c55..dd612da 100755
--- a/guests/quayadmin
+++ b/guests/quayadmin
@@ -211,6 +211,28 @@ def run_show_trigger(config, args):
print(" activatable: {}".format(info["can_invoke"]))
+def run_activate_trigger(config, args):
+ endpoint = "/repository/{}/{}/trigger/{}/start".format(args.namespace,
+ args.repo,
+ args.trigger)
+ payload = {
+ "commit_sha": args.commit,
+ }
+
+ res = post(config, endpoint, payload=payload, debug=args.debug)
+
+ if has_error(args.quiet, res, 201,
+ "Cannot activate trigger {} for repository {}/{}"
+ .format(args.trigger, args.namespace, args.repo)):
+ return 1
+
+ info = res.json()
+
+ if not args.quiet:
+ print("Build {} for {}/{} created".format(info["id"],
+ args.namespace, args.repo))
+
+
def add_arg_namespace(parser):
parser.add_argument("namespace", help="Organization or user
name")
@@ -227,6 +249,10 @@ def add_arg_trigger(parser):
parser.add_argument("trigger", help="Trigger ID")
+def add_arg_commit(parser):
+ parser.add_argument("commit", help="Git commit hash")
+
+
def build_parser_list_repos(subparser):
parser = subparser.add_parser("list-repos", help="List container
repositories")
@@ -282,6 +308,17 @@ def build_parser_show_trigger(subparser):
add_arg_trigger(parser)
+def build_parser_activate_trigger(subparser):
+ parser = subparser.add_parser("activate-trigger", help="Start build
from trigger")
+
+ parser.set_defaults(func=run_activate_trigger)
+
+ add_arg_namespace(parser)
+ add_arg_repo(parser)
+ add_arg_trigger(parser)
+ add_arg_commit(parser)
+
+
def build_parser():
parser = argparse.ArgumentParser(
description="quay.io client admin tool"
@@ -300,6 +337,7 @@ def build_parser():
build_parser_list_triggers(subparser)
build_parser_show_trigger(subparser)
+ build_parser_activate_trigger(subparser)
return parser
--
2.21.0