From f6d67d8478cb6fee7db347e3709e130c5a0fd09a Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Fri, 9 Jun 2023 10:55:44 +0200 Subject: [PATCH] make newRepo for sidetag configurable --- plugins/cli/sidetag_cli.py | 13 ++++++++----- plugins/hub/sidetag.conf | 6 ++++++ plugins/hub/sidetag_hub.py | 13 ++++++++++--- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/plugins/cli/sidetag_cli.py b/plugins/cli/sidetag_cli.py index a8e16f86..58137c52 100644 --- a/plugins/cli/sidetag_cli.py +++ b/plugins/cli/sidetag_cli.py @@ -9,7 +9,8 @@ from optparse import OptionParser import koji from koji.plugin import export_cli -from koji_cli.lib import activate_session, arg_filter, watch_tasks +from koji_cli.commands import anon_handle_wait_repo +from koji_cli.lib import activate_session, arg_filter @export_cli @@ -37,7 +38,7 @@ def handle_add_sidetag(options, session, args): if opts.suffix: kwargs['suffix'] = opts.suffix try: - info = session.createSideTag(basetag, **kwargs) + tag = session.createSideTag(basetag, **kwargs) except koji.ActionNotAllowed: parser.error("Policy violation") except koji.ParameterError as ex: @@ -47,11 +48,13 @@ def handle_add_sidetag(options, session, args): raise if not opts.quiet: - print(info["name"]) + print(tag["name"]) if opts.wait: - return watch_tasks(session, [info['task_id']], quiet=opts.quiet, - poll_interval=options.poll_interval, topurl=options.topurl) + args = ["--target", tag["name"]] + if opts.quiet: + args.append("--quiet") + anon_handle_wait_repo(options, session, args) @export_cli diff --git a/plugins/hub/sidetag.conf b/plugins/hub/sidetag.conf index d4e55a48..20a44c4e 100644 --- a/plugins/hub/sidetag.conf +++ b/plugins/hub/sidetag.conf @@ -1,9 +1,15 @@ [sidetag] # automatically remove sidetag on untagging last package remove_empty = off + # potential suffixes for sidetag names # allowed_suffixes = + # template for sidetag names. It must contain basetag and tag_id parts # if allowed_suffixes is not empty and suffix was requested, it will be added # as {name_template}-{suffix}. (percent-signs need to be escaped) # name_template = {basetag}-side-{tag_id} + +# Automaticaly trigger newRepo task for every new sidetag. Otherwise let kojira +# prioritize these. +# trigger_new_repo = False diff --git a/plugins/hub/sidetag_hub.py b/plugins/hub/sidetag_hub.py index 4ff15760..8932571d 100644 --- a/plugins/hub/sidetag_hub.py +++ b/plugins/hub/sidetag_hub.py @@ -27,6 +27,7 @@ from kojihub.db import QueryProcessor, nextval CONFIG_FILE = "/etc/koji-hub/plugins/sidetag.conf" CONFIG = None ALLOWED_SUFFIXES = [] +TRIGGER_NEW_REPO = False def is_sidetag(taginfo, raise_error=False): @@ -136,9 +137,13 @@ def createSideTag(basetag, debuginfo=False, suffix=None): ) _create_build_target(sidetag_name, sidetag_id, sidetag_id) - # little higher priority than other newRepo tasks - args = koji.encode_args(sidetag_name, debuginfo=debuginfo) - task_id = make_task('newRepo', args, priority=14, channel='createrepo') + + if TRIGGER_NEW_REPO: + # little higher priority than other newRepo tasks + args = koji.encode_args(sidetag_name, debuginfo=debuginfo) + task_id = make_task('newRepo', args, priority=14, channel='createrepo') + else: + task_id = None return {"name": sidetag_name, "id": sidetag_id, 'task_id': task_id} @@ -367,3 +372,5 @@ if not CONFIG: NAME_TEMPLATE = CONFIG.get("sidetag", "name_template") else: NAME_TEMPLATE = '{basetag}-side-{tag_id}' + if CONFIG.has_option("sidetag", "trigger_new_repo"): + TRIGGER_NEW_REPO = CONFIG.getboolean("sidetag", "trigger_new_repo")