config-dump: Allow overwritting config via -e option

The -e option was designed for defining missing config item,
but users always try to use it to overwrite existing config.

Now it works as expected.

JIRA: COMPOSE-3718
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2019-10-24 10:17:07 +08:00
parent 8829fc32ab
commit 5751de1096
1 changed files with 7 additions and 1 deletions

View File

@ -95,11 +95,16 @@ def process_file(
:returns: False if validation failed, True otherwise
"""
conf = kobo.conf.PyConfigParser()
# Make sure variables are ready before processing config template
conf.load_from_dict(defines or {})
for source in sources:
load_source(source, conf)
# Load again to overwrite exsting config with the value provided in command line
conf.load_from_dict(defines or {})
if not just_dump:
errors, _ = pungi.checks.validate(conf, offline=offline)
if errors:
@ -149,7 +154,8 @@ def main():
metavar="VAR=VALUE",
type=config_utils.validate_definition,
help=(
"Define a variable on command line and inject it into the config file. "
"Define missing or overwrite existing config item in the config file, "
"or assign value to template variable. "
"Can be used multiple times."
),
)