s/receivers/recipients/

master
Thomas Maier 2021-02-28 10:49:40 +01:00
rodzic 0e65215b17
commit a4888da145
3 zmienionych plików z 11 dodań i 11 usunięć

Wyświetl plik

@ -12,6 +12,6 @@ RUN adduser -D -g '' xmpp-webhook
USER xmpp-webhook
ENV XMPP_ID="" \
XMPP_PASS="" \
XMPP_RECEIVERS=""
XMPP_RECIPIENTS=""
EXPOSE 4321
CMD ["/xmpp-webhook"]

Wyświetl plik

@ -15,7 +15,7 @@ Check https://github.com/tmsmr/xmpp-webhook/blob/master/parser/ to learn how to
- `xmpp-webhook` is configured via environment variables:
- `XMPP_ID` - The JID we want to use
- `XMPP_PASS` - The password
- `XMPP_RECEIVERS` - Comma-seperated list of JID's
- `XMPP_RECIPIENTS` - Comma-seperated list of JID's
- `XMPP_SKIP_VERIFY` - Skip TLS verification (Optional)
- `XMPP_OVER_TLS` - Use dedicated TLS port (Optional)
- `XMPP_WEBHOOK_LISTEN_ADDRESS` - Bind address (Optional)
@ -26,14 +26,14 @@ curl -X POST -d @dev/grafana-webhook-alert-example.json localhost:4321/grafana
curl -X POST -d @dev/alertmanager-example.json localhost:4321/alertmanager
curl -X POST -d @dev/slack-compatible-notification-example.json localhost:4321/slack
```
- After parsing the body in the appropriate `parserFunc`, the notification is then distributed to the configured receivers.
- After parsing the body in the appropriate `parserFunc`, the notification is then distributed to the configured recipients.
## Run with Docker
### Build it
- Build image: `docker build -t xmpp-webhook .`
- Run: `docker run -e "XMPP_ID=alerts@example.org" -e "XMPP_PASS=xxx" -e "XMPP_RECEIVERS=receiver1@example.org,receiver2@example.org" -p 4321:4321 -d --name xmpp-webhook xmpp-webhook`
- Run: `docker run -e "XMPP_ID=alerts@example.org" -e "XMPP_PASS=xxx" -e "XMPP_RECIPIENTS=a@example.org,b@example.org" -p 4321:4321 -d --name xmpp-webhook xmpp-webhook`
### Use prebuilt image from Docker Hub
- Run: `docker run -e "XMPP_ID=alerts@example.org" -e "XMPP_PASS=xxx" -e "XMPP_RECEIVERS=receiver1@example.org,receiver2@example.org" -p 4321:4321 -d --name xmpp-webhook tmsmr/xmpp-webhook:latest`
- Run: `docker run -e "XMPP_ID=alerts@example.org" -e "XMPP_PASS=xxx" -e "XMPP_RECIPIENTS=a@example.org,b@example.org" -p 4321:4321 -d --name xmpp-webhook tmsmr/xmpp-webhook:latest`
## Installation
- Download and extract the latest tarball (GitHub release page)
@ -44,7 +44,7 @@ curl -X POST -d @dev/slack-compatible-notification-example.json localhost:4321/s
```
XMPP_ID='bot@example.com'
XMPP_PASS='passw0rd'
XMPP_RECEIVERS='jdoe@example.com,ops@example.com'
XMPP_RECIPIENTS='jdoe@example.com,ops@example.com'
```
- Enable and start the service:

10
main.go
Wyświetl plik

@ -72,10 +72,10 @@ func closeXMPP(session *xmpp.Session) {
}
func main() {
// get xmpp credentials, message receivers
// get xmpp credentials, message recipients
xi := os.Getenv("XMPP_ID")
xp := os.Getenv("XMPP_PASS")
xr := os.Getenv("XMPP_RECEIVERS")
xr := os.Getenv("XMPP_RECIPIENTS")
// get tls settings from env
_, skipTLSVerify := os.LookupEnv("XMPP_SKIP_VERIFY")
@ -87,9 +87,9 @@ func main() {
listenAddress = ":4321"
}
// check if xmpp credentials and receiver list are supplied
// check if xmpp credentials and recipient list are supplied
if xi == "" || xp == "" || xr == "" {
log.Fatal("XMPP_ID, XMPP_PASS or XMPP_RECEIVERS not set")
log.Fatal("XMPP_ID, XMPP_PASS or XMPP_RECIPIENTS not set")
}
myjid, err := jid.Parse(xi)
@ -147,7 +147,7 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// wait for messages from the webhooks and send them to all receivers
// wait for messages from the webhooks and send them to all recipients
go func() {
for m := range messages {
for _, r := range strings.Split(xr, ",") {