notify: Adds support for gotify open-source notification service.#5380
notify: Adds support for gotify open-source notification service.#5380TheSp1der wants to merge 6 commits into
Conversation
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThis PR adds Gotify as a supported Alertmanager notification receiver. It introduces Gotify config parsing and wiring, implements HTTP delivery and template rendering, and adds validation and notifier tests. ChangesGotify Receiver Support
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@notify/gotify/gotify.go`:
- Line 143: The Gotify auth header is incorrectly passing the token through the
template engine, which can mutate an opaque credential and bypass template
errors already checked earlier. Update the Gotify notifier logic in the function
that builds the request header to use the raw token directly in the X-Gotify-Key
header, matching the other notifier implementations that send credentials
without templating.
- Around line 106-108: Check tmplErr before parsing priority in gotify.Notify so
template failures are not masked by strconv.Atoi. In the priority handling
block, make sure the result of tmplText(n.conf.Priority) is accompanied by an
immediate tmplErr check before calling strconv.Atoi, and return that template
error directly if present. Keep the existing priority parsing path in Notify and
the later tmplErr handling consistent, but ensure the early priority parse
cannot turn a template failure into an "invalid syntax" error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: b8b87b8f-4049-4f3c-843b-2bd1be89a778
📒 Files selected for processing (7)
config/config.goconfig/receiver/receiver.gonotify/gotify/config.gonotify/gotify/config_test.gonotify/gotify/gotify.gonotify/gotify/gotify_test.gotemplate/default.tmpl
Prevent token from being processed by template engine. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Nicolaas Hyatt <39059405+TheSp1der@users.noreply.github.com>
Updates return message to more accurately represent error instead of possible confusing "invalid syntax". Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Nicolaas Hyatt <39059405+TheSp1der@users.noreply.github.com>
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
|
This looks like a simple stateles JSON post to me. So two questions:
|
|
That's a good question:
|
So the auth should be not an issue. The native webhhok supports many authentications ans cusomtizations. Especially setting a header is easy https://prometheus.io/docs/alerting/latest/configuration/#http_header
You can use a custom roundtripper to acheive that, see eg here https://github.com/prometheus/alertmanager/blob/main/notify/rocketchat/rocketchat.go#L77-L115 |
Fixes #2120
Summary
This PR adds a new Gotify receiver integration.
/messageAPI withX-Gotify-Keyauthentication.gotify_configsto the Alertmanager configuration and wires it into receiver integration building.gotify.default.titleandgotify.default.message.extras.client::display.contentTypefor markdown delivery.Which user-facing changes does this PR introduce?