From 174f61ce13d47c84a1a9f697c7c6b7c817db73f7 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Oct 11 2019 15:56:39 +0000 Subject: [PATCH 1/3] container-build: add --isolated argument Add support for a new "--isolated" argument to the container-build sub-command. Isolated builds will only update the {version}-{release} unique tag and the primary tag in target container registry. Also, OSBS's bump_release plugin will ignore isolated builds. Users must specify a --build-release argument when the use the --isolated argument. Signed-off-by: Ken Dreyer --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 8e0960b..1aa1c2b 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -3125,7 +3125,7 @@ class Commands(object): source = self.construct_build_url() task_opts = {} - for key in ('scratch', 'name', 'version', 'release', + for key in ('scratch', 'name', 'version', 'release', 'isolated', 'yum_repourls', 'git_branch', 'signing_intent', 'compose_ids', 'skip_build'): if key in opts: diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 7ab146d..0845d99 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -1545,6 +1545,13 @@ see API KEY section of copr-cli(1) man page. help="Specify a release value for this build's NVR") parser.add_argument( + '--isolated', + help='Do not auto-increment the release value or update' + ' additional tags in the registry. You must use the' + ' --build-release argument', + action="store_true") + + parser.add_argument( '--scratch', help='Scratch build', action="store_true") @@ -1981,6 +1988,7 @@ see API KEY section of copr-cli(1) man page. opts = {"scratch": self.args.scratch, "quiet": self.args.q, "release": self.args.build_release, + "isolated": self.args.isolated, "git_branch": self.cmd.branch_merge, "arches": self.args.arches, "skip_build": self.args.skip_build} @@ -1995,6 +2003,11 @@ see API KEY section of copr-cli(1) man page. "signing_intent": self.args.signing_intent, }) + if self.args.isolated and not self.args.build_release: + self.container_build_parser.error( + 'missing --build-release: using --isolated requires' + ' --build-release option') + section_name = "%s.container-build" % self.name err_msg = "Missing %(option)s option in [%(plugin.section)s] section. " \ "Using %(option)s from [%(root.section)s]" diff --git a/tests/test_cli.py b/tests/test_cli.py index ae87030..35b37d6 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -224,6 +224,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'scratch': False, 'quiet': False, 'release': None, + 'isolated': False, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', 'arches': None, @@ -254,6 +255,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'scratch': False, 'quiet': False, 'release': None, + 'isolated': False, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', 'arches': None, @@ -293,6 +295,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'scratch': False, 'quiet': False, 'release': None, + 'isolated': False, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', 'arches': None, @@ -350,6 +353,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'scratch': False, 'quiet': False, 'release': None, + 'isolated': False, 'git_branch': 'eng-rhel-7', 'arches': None, 'skip_build': False From 10de8c40d2f2964ce0c4f643a143c59e5fa11f94 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Oct 11 2019 16:48:42 +0000 Subject: [PATCH 2/3] tests: add container-build --isolated test Verify the behavior of the container-build "--isolated" option. Signed-off-by: Ken Dreyer --- diff --git a/tests/test_cli.py b/tests/test_cli.py index 35b37d6..fa18647 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -271,6 +271,36 @@ class TestContainerBuildWithKoji(CliTestCase): flatpak=False ) + def test_isolated(self): + cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'container-build', + '--isolated', '--build-release', '99'] + + with patch('sys.argv', new=cli_cmd): + cli = self.new_cli() + cli.container_build_koji() + + self.mock_container_build_koji.assert_called_once_with( + False, + opts={ + 'scratch': False, + 'quiet': False, + 'release': '99', + 'isolated': True, + 'yum_repourls': None, + 'git_branch': 'eng-rhel-7', + 'arches': None, + 'signing_intent': None, + 'compose_ids': None, + 'skip_build': False + }, + kojiconfig=None, + kojiprofile='koji', + build_client=utils.build_client, + koji_task_watcher=koji_cli.lib.watch_tasks, + nowait=False, + flatpak=False + ) + def test_using_deprecated_kojiconfig(self): """test_build_using_deprecated_kojiconfig From 4b48dbcba45bf3ad44a3179380972b3ad6997616 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Oct 11 2019 16:48:51 +0000 Subject: [PATCH 3/3] container-build: add --koji-parent-build argument Add support for a new "--koji-parent-build" argument to the container-build sub-command. OSBS allows users to dynamically override the Dockerfile's "FROM" image at build time. This allows you to build your container against a specific parent image without pushing changes to dist-git. Signed-off-by: Ken Dreyer --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 1aa1c2b..b139fe0 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -3126,8 +3126,8 @@ class Commands(object): task_opts = {} for key in ('scratch', 'name', 'version', 'release', 'isolated', - 'yum_repourls', 'git_branch', 'signing_intent', 'compose_ids', - 'skip_build'): + 'koji_parent_build', 'yum_repourls', 'git_branch', + 'signing_intent', 'compose_ids', 'skip_build'): if key in opts: task_opts[key] = opts[key] diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 0845d99..0036136 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -1552,6 +1552,12 @@ see API KEY section of copr-cli(1) man page. action="store_true") parser.add_argument( + '--koji-parent-build', + default=None, + help='Specify a Koji NVR for the parent container image. This' + ' will override the "FROM" value in your Dockerfile.') + + parser.add_argument( '--scratch', help='Scratch build', action="store_true") @@ -1989,6 +1995,7 @@ see API KEY section of copr-cli(1) man page. "quiet": self.args.q, "release": self.args.build_release, "isolated": self.args.isolated, + "koji_parent_build": self.args.koji_parent_build, "git_branch": self.cmd.branch_merge, "arches": self.args.arches, "skip_build": self.args.skip_build} diff --git a/tests/test_cli.py b/tests/test_cli.py index fa18647..0868a30 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -225,6 +225,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'release': None, 'isolated': False, + 'koji_parent_build': None, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', 'arches': None, @@ -256,6 +257,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'release': None, 'isolated': False, + 'koji_parent_build': None, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', 'arches': None, @@ -286,6 +288,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'release': '99', 'isolated': True, + 'koji_parent_build': None, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', 'arches': None, @@ -326,6 +329,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'release': None, 'isolated': False, + 'koji_parent_build': None, 'yum_repourls': None, 'git_branch': 'eng-rhel-7', 'arches': None, @@ -384,6 +388,7 @@ class TestContainerBuildWithKoji(CliTestCase): 'quiet': False, 'release': None, 'isolated': False, + 'koji_parent_build': None, 'git_branch': 'eng-rhel-7', 'arches': None, 'skip_build': False