config: Allow validating configuration in JSON

JIRA: COMPOSE-3318
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-03-04 14:36:28 +01:00
parent 357f556d69
commit a206a73db1

View File

@ -79,7 +79,13 @@ def read_variants(compose, config):
def run(config, topdir, has_old, offline): def run(config, topdir, has_old, offline):
conf = kobo.conf.PyConfigParser() conf = kobo.conf.PyConfigParser()
conf.load_from_file(config) if config.endswith(".json"):
with open(config) as f:
conf.load_from_dict(json.load(f))
conf.opened_files = [config]
conf._open_file = config
else:
conf.load_from_file(config)
errors, warnings = pungi.checks.validate(conf, offline=offline) errors, warnings = pungi.checks.validate(conf, offline=offline)
if errors or warnings: if errors or warnings: