[Validator Run] Don't rely on parameter file extension
This patch safely loads extra vars file using YAML method by default and
don't rely anymore on a probable existence of a file extension.
Change-Id: Ia09ca1de9502cd6c99910a6f18ee775c613c10dc
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
(cherry picked from commit cd0e24bbe3
)
This commit is contained in:
parent
21d8e7c2c9
commit
e4ae6d2523
|
@ -330,11 +330,14 @@ class TripleOValidatorRun(command.Command):
|
||||||
limit = parsed_args.limit
|
limit = parsed_args.limit
|
||||||
extra_vars = parsed_args.extra_vars
|
extra_vars = parsed_args.extra_vars
|
||||||
if parsed_args.extra_vars_file:
|
if parsed_args.extra_vars_file:
|
||||||
with open(parsed_args.extra_vars_file, 'r') as env_file:
|
try:
|
||||||
if '.json' in parsed_args.extra_vars_file:
|
with open(parsed_args.extra_vars_file, 'r') as env_file:
|
||||||
extra_vars.update(json.load(env_file))
|
extra_vars.update(yaml.safe_load(env_file.read()))
|
||||||
else:
|
except yaml.YAMLError as e:
|
||||||
extra_vars.update(yaml.load(env_file))
|
error_msg = (
|
||||||
|
"The request body must be properly formatted YAML/JSON. "
|
||||||
|
"Details: %s." % e)
|
||||||
|
raise exceptions.CommandError(error_msg)
|
||||||
|
|
||||||
# We don't check if the file exists in order to support
|
# We don't check if the file exists in order to support
|
||||||
# passing a string such as "localhost,", like we can do with
|
# passing a string such as "localhost,", like we can do with
|
||||||
|
|
Loading…
Reference in New Issue