[libvirt] [jenkins-ci PATCH 0/2] quayadmin: Add create-build command

Once [1] has been merged, we'll be able to conveniently cause container images to be rebuilt without having to define custom triggers. [1] https://www.redhat.com/archives/libvir-list/2019-August/msg00399.html Andrea Bolognani (2): quayadmin: Fix endpoints quayadmin: Add create-build command guests/quayadmin | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) -- 2.21.0

Some of the endpoints for the Quay API are documented[1] as ending with a slash, and as it turns out the slash being there is actually critical to proper operation: if you leave it out, some APIs will behave on POST as if you had performed a GET, which is extremely confusing and not at all what we want. [1] https://docs.quay.io/api/swagger/ Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/quayadmin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/guests/quayadmin b/guests/quayadmin index 36ce183..02be0f4 100755 --- a/guests/quayadmin +++ b/guests/quayadmin @@ -181,7 +181,7 @@ def run_delete_repo(config, args): def run_list_tags(config, args): - endpoint = "/repository/{}/{}/tag".format(args.namespace, args.repo) + endpoint = "/repository/{}/{}/tag/".format(args.namespace, args.repo) params = { "onlyActiveTags": True, "limit": 100, @@ -201,7 +201,7 @@ def run_list_tags(config, args): def run_show_tag(config, args): - endpoint = "/repository/{}/{}/tag".format(args.namespace, args.repo) + endpoint = "/repository/{}/{}/tag/".format(args.namespace, args.repo) params = { "onlyActiveTags": True, "limit": 100, @@ -279,7 +279,7 @@ def run_delete_tag(config, args): def run_list_builds(config, args): - endpoint = "/repository/{}/{}/build".format(args.namespace, args.repo) + endpoint = "/repository/{}/{}/build/".format(args.namespace, args.repo) res = get(config, endpoint, debug=args.debug) @@ -319,7 +319,7 @@ def run_show_build(config, args): def run_list_triggers(config, args): - endpoint = "/repository/{}/{}/trigger".format(args.namespace, args.repo) + endpoint = "/repository/{}/{}/trigger/".format(args.namespace, args.repo) res = get(config, endpoint, debug=args.debug) -- 2.21.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- guests/quayadmin | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/guests/quayadmin b/guests/quayadmin index 02be0f4..8099d6a 100755 --- a/guests/quayadmin +++ b/guests/quayadmin @@ -318,6 +318,29 @@ def run_show_build(config, args): print(" started: {}".format(info["started"])) +def run_create_build(config, args): + endpoint = "/repository/{}/{}/build/".format(args.namespace, args.repo) + payload = { + "archive_url": args.archive_url, + } + + res = post(config, endpoint, payload=payload, debug=args.debug) + + if has_error(args.quiet, res, 201, + "Cannot create build for repository {}/{}" + .format(args.namespace, args.repo)): + return 1 + + if args.quiet: + return 0 + + info = res.json() + + print("Build {} created in repository {}/{}".format(info["id"], + args.namespace, + args.repo)) + + def run_list_triggers(config, args): endpoint = "/repository/{}/{}/trigger/".format(args.namespace, args.repo) @@ -415,6 +438,10 @@ def add_arg_image(parser): parser.add_argument("image", help="Image ID") +def add_arg_archive_url(parser): + parser.add_argument("archive_url", help="Archive URL") + + def build_parser_list_repos(subparser): parser = subparser.add_parser("list-repos", help="List container repositories") @@ -510,6 +537,16 @@ def build_parser_show_build(subparser): add_arg_build(parser) +def build_parser_create_build(subparser): + parser = subparser.add_parser("create-build", help="Create a new build") + + parser.set_defaults(func=run_create_build) + + add_arg_namespace(parser) + add_arg_repo(parser) + add_arg_archive_url(parser) + + def build_parser_list_triggers(subparser): parser = subparser.add_parser("list-triggers", help="List repository triggers") @@ -563,6 +600,7 @@ def build_parser(): build_parser_list_builds(subparser) build_parser_show_build(subparser) + build_parser_create_build(subparser) build_parser_list_triggers(subparser) build_parser_show_trigger(subparser) -- 2.21.0

On Mon, 2019-08-12 at 15:35 +0200, Andrea Bolognani wrote:
Once [1] has been merged, we'll be able to conveniently cause container images to be rebuilt without having to define custom triggers.
[1] https://www.redhat.com/archives/libvir-list/2019-August/msg00399.html
Andrea Bolognani (2): quayadmin: Fix endpoints quayadmin: Add create-build command
guests/quayadmin | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-)
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
participants (2)
-
Andrea Bolognani
-
Fabiano Fidêncio