Better errors for unknown secrets (#13072)

This commit is contained in:
Johann Kellerman 2018-03-11 12:51:03 +02:00 committed by GitHub
parent d74a2b68c1
commit f164a5a65f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -140,6 +140,9 @@ def run(script_args: List) -> int:
print(color(C_HEAD, 'Used Secrets:'))
for skey, sval in res['secrets'].items():
if sval is None:
print(' -', skey + ':', color('red', "not found"))
continue
print(' -', skey + ':', sval, color('cyan', '[from:', flatsecret
.get(skey, 'keyring') + ']'))
@ -308,7 +311,8 @@ def check_ha_config_file(config_dir):
return result.add_error("File configuration.yaml not found.")
config = load_yaml_config_file(config_path)
except HomeAssistantError as err:
return result.add_error(err)
return result.add_error(
"Error loading {}: {}".format(config_path, err))
finally:
yaml.clear_secret_cache()

View file

@ -288,8 +288,7 @@ def _secret_yaml(loader: SafeLineLoader,
# Catch if package installed and no config
credstash = None
_LOGGER.error("Secret %s not defined", node.value)
raise HomeAssistantError(node.value)
raise HomeAssistantError("Secret {} not defined".format(node.value))
yaml.SafeLoader.add_constructor('!include', _include_yaml)