From 351bc64f4cbd823bcfc33676b11af4d2eac831c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Thu, 2 Sep 2021 11:38:59 +0200 Subject: [PATCH] Allow to pass arbitrary parameters to TCIB image config This new parameter takes key=value format, and can be passed multiple times. Those key/values can then be used within the image description files in order to make them support different releases, or just use the value in case we have a specific version (python-version for instance). This will be useful in order to support container builds on both CS8 and CS9 releases without too many duplications or headaches. Note that a "tcib_" prefix is enforced for the keys. Closes-Bug: #1942510 Change-Id: I7fe4d59f1fb76ba59d065b56c5900f4d3cfcda2e (cherry picked from commit fb6daacedd733fbaa801507a7acf14c699faf0c5) --- tripleoclient/v2/tripleo_container_image.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tripleoclient/v2/tripleo_container_image.py b/tripleoclient/v2/tripleo_container_image.py index 6050b6700..db21ca2d4 100644 --- a/tripleoclient/v2/tripleo_container_image.py +++ b/tripleoclient/v2/tripleo_container_image.py @@ -111,6 +111,18 @@ class Build(command.Command): "host distro. (default: %(default)s)" ), ) + parser.add_argument( + "--tcib-extras", + dest="tcib_extras", + default=None, + metavar="", + action='append', + help=_( + "TCIB extra variables you want to pass. They can be later " + "used within TCIB files as conditonals. Can be passed " + "multiple times(default: %(default)s)" + ), + ) parser.add_argument( "--exclude", dest="excludes", @@ -564,6 +576,15 @@ class Build(command.Command): "ansible_connection": "local", } ) + if parsed_args.tcib_extras: + for extras in parsed_args.tcib_extras: + key, value = extras.split('=') + # Enforce format in order to get some consistency + if not key.startswith('tcib_'): + raise ValueError('Wrong key format {key}. ' + 'We expect "tcib_" prefix, such as ' + 'tcib_{key}'.format(key=key)) + image_config[key] = value if parsed_args.rhel_modules: rhel_modules = {}