From b0932a9ae1a4894b7fcc1f574a79fca385e59e12 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Sep 07 2017 16:19:12 +0000 Subject: cli: add --arches support for koji_cointainerbuild add support for reading --arches for koji_containerbuilds and passing the argument on. Signed-off-by: Mark Langsdorf --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index d5f04ba..a81e4a5 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2536,7 +2536,7 @@ class Commands(object): self._run_command(cmd, shell=True) def osbs_build(self, config_file, config_section, target_override=False, - yum_repourls=[], nowait=False): + yum_repourls=[], nowait=False, platforms=None): # Because docker image should be built via Koji not in OSBS directly, # it is not necessary to make osbs as a hard dependency try: @@ -2560,6 +2560,10 @@ class Commands(object): component = self.module_name container_target = self.target if target_override else self.container_build_target + if platforms: + architecture = None + else: + architecture = 'x86_64' build = osbs.create_build( git_uri=git_uri, git_ref=git_ref, @@ -2567,7 +2571,8 @@ class Commands(object): user=user, component=component, target=container_target, - architecture="x86_64", + platforms=platforms, + architecture=architecture, yum_repourls=yum_repourls ) build_id = build.build_id @@ -2634,7 +2639,7 @@ class Commands(object): task_opts = {} for key in ('scratch', 'name', 'version', 'release', - 'yum_repourls', 'git_branch'): + 'yum_repourls', 'git_branch', 'arches'): if key in opts: task_opts[key] = opts[key] priority = opts.get("priority", None) diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 90874fc..9c4c15e 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -966,6 +966,11 @@ see API KEY section of copr-cli(1) man page. action='store_true', default=False, help="Don't wait on build") + self.container_build_parser.add_argument( + '--arches', + action='store', + nargs='*', + help='Limit a scratch build to an arch. May have multiple arches.') self.container_build_parser.set_defaults(command=self.container_build) @@ -1191,7 +1196,8 @@ see API KEY section of copr-cli(1) man page. opts = {"scratch": self.args.scratch, "quiet": self.args.q, "yum_repourls": self.args.repo_url, - "git_branch": self.cmd.branch_merge} + "git_branch": self.cmd.branch_merge, + "arches": self.args.arches} section_name = "%s.container-build" % self.name err_msg = "Missing %(option)s option in [%(plugin.section)s] section. " \ @@ -1241,7 +1247,8 @@ see API KEY section of copr-cli(1) man page. config_section=self.args.instance, target_override=target_override, yum_repourls=self.args.repo_url, - nowait=self.args.nowait + nowait=self.args.nowait, + platform=self.args.arches ) def container_build_setup(self): diff --git a/tests/test_cli.py b/tests/test_cli.py index 1372411..e9a5829 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -182,6 +182,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', + 'arches': None, }, kojiconfig=None, kojiprofile='koji', @@ -207,6 +208,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', + 'arches': None, }, kojiconfig=None, kojiprofile='koji', @@ -241,6 +243,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', + 'arches': None, }, kojiconfig='/path/to/koji.conf', kojiprofile=None,