Blob Blame History Raw
From 4b48dbcba45bf3ad44a3179380972b3ad6997616 Mon Sep 17 00:00:00 2001
From: Ken Dreyer <kdreyer@redhat.com>
Date: Fri, 11 Oct 2019 09:42:08 -0600
Subject: [PATCH 5/5] 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 <kdreyer@redhat.com>
---
 pyrpkg/__init__.py | 4 ++--
 pyrpkg/cli.py      | 7 +++++++
 tests/test_cli.py  | 5 +++++
 3 files changed, 14 insertions(+), 2 deletions(-)

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
@@ -1551,6 +1551,12 @@ see API KEY section of copr-cli(1) man page.
                  ' --build-release argument',
             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',
@@ -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
-- 
2.21.0