mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
Cleanup the output of 'esphome config' command.
When running `esphome config` as a CLI tool, the output adds some escaping to any config property that ends with 'password', 'key', 'psk', or 'ssid' so that the dashboard can redact secrets. I was using `esphome config` for linting purposes and having the output transformed like this was causing problems for me. I attempted to figure out how to tell when the tool was being run in a context where the output would be going to the dashboard so that it would only do that under those circumstances, but I wasn't able to determine if there was any way to detect that. Since I couldn't figure that out I did what felt like the next best thing and just modified the regex so that only wraps those values when they don't start with `!secret`, which fixes the problem for my use case, and having the dashboard only redact values that actually contain secrets seems like a win to me too.
This commit is contained in:
parent
ca8e45cf4c
commit
a4e70e9750
1 changed files with 3 additions and 1 deletions
|
@ -414,7 +414,9 @@ def command_config(args, config):
|
|||
# add the console decoration so the front-end can hide the secrets
|
||||
if not args.show_secrets:
|
||||
output = re.sub(
|
||||
r"(password|key|psk|ssid)\: (.+)", r"\1: \\033[5m\2\\033[6m", output
|
||||
r"(password|key|psk|ssid)\: ((?!\!secret).+)",
|
||||
r"\1: \\033[5m\2\\033[6m",
|
||||
output,
|
||||
)
|
||||
if not CORE.quiet:
|
||||
safe_print(output)
|
||||
|
|
Loading…
Reference in a new issue