Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate configuration handling to the confuse lib, take 2 #364

Merged
merged 23 commits into from
Feb 12, 2023

Conversation

jinnatar
Copy link
Contributor

@jinnatar jinnatar commented Feb 10, 2023

This enables:

  • Conservative config defaults in src/default_config.yaml, which leads to smaller and leaner custom configs.
  • Config validation with confuse templates or at-use get methods with type checking.
  • Easier future mutation of config format as defaults can carry over sane defaults.

This change touches all integrations and has minor potential for subtle breakage.

The following notifiers have been thoroughly tested:

  • Telegram
  • Pushover
  • IFTTT
  • MQTT
  • SMTP
  • Script
  • Discord

Notifiers not tested:

  • Slack

Notifiers with known issues:

  • Grafana, WIP

Notifiers I cannot test myself:

  • Pushcut

Groundwork for fixing #361

I've tested and verified the following to function:
- Telegram
- Pushover
This ensures the backwards compatibility is still carried forward of
enabling misconfigured handlers.
This prevents it getting interpreted as a valid notifier and causing a
warning.
Now only the showcases are run where other tokens are also present
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.
Also amend SMTP testing to allow setting SMTP auth
Copy link
Owner

@martomi martomi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work, thanks!

SMTP_ENABLE_AUTH=true \
SMTP_USERNAME=username \
SMTP_PASSWORD=password \
python3 -m unittest tests.notifier.test_smtp_notifier
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing these!

@@ -141,8 +141,6 @@ git pull
./install.sh
```

> Important: Automated migration of config is not supported. Please check that your `config.yaml` has all new fields introduced in `config-example.yaml` and add anything missing. If correctly migrated, you shouldn't get any ERROR logs.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@@ -29,7 +31,7 @@ keep_alive_monitor:
# Enable this and you'll receive a daily summary notification
# on your farm performance at the specified time of the day.
daily_stats:
enable: true
enable: true # default: false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excellent comment! In a future iteration (e.g. when we bump the major version to 1.0) we can switch to more optimistic defaults but as discussed in the previous PR, now we’re keeping the conservative defaults from the code.

"remote_host": str,
"remote_user": str,
"remote_port": int,
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@martomi martomi merged commit 228b23d into martomi:main Feb 12, 2023
@martomi
Copy link
Owner

martomi commented Feb 12, 2023

@Artanicus sorry, I might have merged while you’re still in WIP (just read the updated PR description). Feel free to finish the rest in a separate PR, as this one was already looking good and was quite large so I wanted to have it in master as a base for other changes :-)

@jinnatar
Copy link
Contributor Author

No worries, all in all it's fairly solid. Slack I haven't tested yet (slightly more complex integration) but will, Grafana I know fails because it violates a few notifier conventions (have a WIP fix I'll PR separately since it's a bit opinionated), and Pushcut I can't test since they support such a limited set of platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants