Improve error message around hieradata override file
If the file specified is empty, we currently throw a generic message about it not being in the correct format. Let's add a check to make sure the file is not empty before attempting to parse it as yaml. Change-Id: I702da1170484c0d10c3ae836ec3f7550975a341c Closes-Bug: #1810436
This commit is contained in:
parent
7a6432aa45
commit
8ddcc2cd14
@ -1071,6 +1071,12 @@ class Deploy(command.Command):
|
||||
|
||||
target = override_file
|
||||
data = open(target, 'r').read()
|
||||
if not data.strip():
|
||||
# since an empty file isn't valid yaml, let's be more specific
|
||||
msg = (_("hieradata override file (%s) cannot be empty") % target)
|
||||
self.log.error(msg)
|
||||
raise exceptions.DeploymentError(msg)
|
||||
|
||||
hiera_data = yaml.safe_load(data)
|
||||
if not hiera_data:
|
||||
msg = (_('Unsupported data format in hieradata override %s') %
|
||||
|
Loading…
x
Reference in New Issue
Block a user