-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate configuration handling to the confuse lib (#364)
* WIP: Transform log parsing and handling to use the confuse lib * Default log level to INFO, include stern warning with defaults * Implement the confuse library handling in notifiers I've tested and verified the following to function: - Telegram - Pushover * Expect ConfigViews correctly in typing * Simplify wallet mojo testing * Amend documentation for new config handling. * Explicitly handle daily_stats average times as floats * Make non_skipped_signage_points checking typing explicit * Type signage_point_stats init values explicitly * Fix silly confuse import * More explicit typing and minor cleanup * Validate log consumer config via confuse templates * Add more type safety to notifier parsing * Fix handler enable checking This ensures the backwards compatibility is still carried forward of enabling misconfigured handlers. * Also disable confuse.exceptions type checking since there are no stubs * Fix template formatting with black * Set config defaults to the conservative values that were in code * Move notifier_defaults config block to top level This prevents it getting interpreted as a valid notifier and causing a warning. * Add comments to config-example.yaml where the default differs * Handle MQTT notifier type checking via confuse * Improve testability of tests that use SHOWCASE_NOTIFICATIONS Now only the showcases are run where other tokens are also present * Dedupe test env variables of mqtt & smtp with prefixes Also, switch SMTP testing to verify SMTP_HOST, not SMTP_USERNAME as username is not a mandatory param for smtp to work, but a host is. * Validate SMTP notifier credentials with template Also amend SMTP testing to allow setting SMTP auth
- Loading branch information
Showing
43 changed files
with
524 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,15 @@ verify the sender email. | |
Test with: | ||
|
||
``` | ||
SENDER="[email protected]" SENDER_NAME="ChiaDog" RECIPIENT="[email protected]" HOST=smtp.example.com PORT=587 USERNAME_SMTP=username PASSWORD_SMTP=password python3 -m unittest tests.notifier.test_smtp_notifier | ||
SMTP_SENDER="[email protected]" \ | ||
SMTP_SENDER_NAME="ChiaDog" \ | ||
SMTP_RECIPIENT="[email protected]" \ | ||
SMTP_HOST=smtp.example.com \ | ||
SMTP_PORT=587 \ | ||
SMTP_ENABLE_AUTH=true \ | ||
SMTP_USERNAME=username \ | ||
SMTP_PASSWORD=password \ | ||
python3 -m unittest tests.notifier.test_smtp_notifier | ||
``` | ||
|
||
## Slack | ||
|
@@ -113,7 +121,7 @@ Messages sent to the MQTT topic look like this: | |
Test with: | ||
|
||
``` | ||
HOST=<hostname> PORT=<port> TOPIC=<mqtt_topic> python3 -m unittest tests.notifier.test_mqtt_notifier | ||
MQTT_HOST=<hostname> MQTT_PORT=<port> MQTT_TOPIC=<mqtt_topic> python3 -m unittest tests.notifier.test_mqtt_notifier | ||
``` | ||
|
||
Or with full parameters: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
[tool.black] | ||
line-length = 120 | ||
line-length = 120 | ||
|
||
# No type hints: https://github.com/beetbox/confuse/issues/121 | ||
[[tool.mypy.overrides]] | ||
module = ["confuse", "confuse.exceptions"] | ||
ignore_missing_imports = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ python-dateutil~=2.8.1 | |
PyYAML==5.4 | ||
retry==0.9.2 | ||
pygtail==0.11.1 | ||
confuse==2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.