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:
parent
8829fc32ab
commit
5751de1096
@ -95,11 +95,16 @@ def process_file(
|
|||||||
:returns: False if validation failed, True otherwise
|
:returns: False if validation failed, True otherwise
|
||||||
"""
|
"""
|
||||||
conf = kobo.conf.PyConfigParser()
|
conf = kobo.conf.PyConfigParser()
|
||||||
|
|
||||||
|
# Make sure variables are ready before processing config template
|
||||||
conf.load_from_dict(defines or {})
|
conf.load_from_dict(defines or {})
|
||||||
|
|
||||||
for source in sources:
|
for source in sources:
|
||||||
load_source(source, conf)
|
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:
|
if not just_dump:
|
||||||
errors, _ = pungi.checks.validate(conf, offline=offline)
|
errors, _ = pungi.checks.validate(conf, offline=offline)
|
||||||
if errors:
|
if errors:
|
||||||
@ -149,7 +154,8 @@ def main():
|
|||||||
metavar="VAR=VALUE",
|
metavar="VAR=VALUE",
|
||||||
type=config_utils.validate_definition,
|
type=config_utils.validate_definition,
|
||||||
help=(
|
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."
|
"Can be used multiple times."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user