From 53a12c6fea813598851af65390695a69c8f29b76 Mon Sep 17 00:00:00 2001 From: Ondřej Nosek Date: Oct 09 2024 01:28:31 +0000 Subject: Add draft builds support Generally, it means adding `--draft` argument to the koji build command. JIRA: RHELCMP-14108 Signed-off-by: Ondřej Nosek --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 573fc36..c3e1722 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2456,7 +2456,7 @@ class Commands(object): def build(self, skip_tag=False, scratch=False, background=False, url=None, chain=None, arches=None, sets=False, nvr_check=True, - fail_fast=False, custom_user_metadata=None): + fail_fast=False, custom_user_metadata=None, draft=False): """Initiate a build in build system :param bool skip_tag: Skip the tag action after the build. @@ -2473,6 +2473,7 @@ class Commands(object): will cause the entire build to fail if any subtask/architecture build fails. :param str custom_user_metadata: JSON string of custom metadata + :param bool draft: Perform a draft build. Default is False. :return: task ID returned from Koji API ``build`` and ``chainBuild``. :rtype: int """ @@ -2524,6 +2525,9 @@ class Commands(object): if scratch: opts['scratch'] = True cmd.append('--scratch') + if draft: + opts['draft'] = True + cmd.append('--draft') if background: cmd.append('--background') priority = 5 # magic koji number :/ diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 97c2904..bf2cfa1 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -548,9 +548,13 @@ class cliClient(object): build_parser.add_argument( '--skip-tag', action='store_true', default=False, help='Do not attempt to tag package') - build_parser.add_argument( + build_type_group = build_parser.add_mutually_exclusive_group() + build_type_group.add_argument( '--scratch', action='store_true', default=False, help='Perform a scratch build') + build_type_group.add_argument( + '--draft', action='store_true', default=False, + help='Perform a draft build') build_parser.add_argument( '--srpm', nargs='?', const='CONSTRUCT', help='Build from an srpm. If no srpm is provided with this option' @@ -2125,7 +2129,8 @@ class cliClient(object): sets=sets, nvr_check=nvr_check, fail_fast=self.args.fail_fast, - custom_user_metadata=custom_user_metadata) + custom_user_metadata=custom_user_metadata, + draft=self.args.draft) def chainbuild(self): """Implement chain-build command""" @@ -2176,6 +2181,7 @@ class cliClient(object): self.args.chain = urls self.args.skip_tag = False self.args.scratch = False + self.args.draft = False return self.build(sets) def clean(self): @@ -2936,6 +2942,7 @@ class cliClient(object): # A scratch build is just a build with --scratch self.args.scratch = True self.args.skip_tag = False + self.args.draft = False return self.build() def sources(self):