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 fb6daacedd)
(cherry picked from commit 351bc64f4c)
This commit is contained in:
Cédric Jeanneret 2021-09-02 11:38:59 +02:00 committed by Ronelle Landy
parent e526919ff5
commit d5264c6845
1 changed files with 21 additions and 0 deletions

View File

@ -119,6 +119,18 @@ class Build(command.Command):
"host distro. (default: %(default)s)"
),
)
parser.add_argument(
"--tcib-extras",
dest="tcib_extras",
default=None,
metavar="<key=val>",
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",
@ -572,6 +584,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 = {}