From 5751de109633cb8cf57d9d9467e2a898e34c8cbd Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Thu, 24 Oct 2019 10:17:07 +0800 Subject: [PATCH] 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 --- bin/pungi-config-dump | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/pungi-config-dump b/bin/pungi-config-dump index f8d29601..39caf4b0 100755 --- a/bin/pungi-config-dump +++ b/bin/pungi-config-dump @@ -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." ), )