kopia lustrzana https://github.com/tmsmr/xmpp-webhook
s/receivers/recipients/
rodzic
0e65215b17
commit
a4888da145
|
@ -12,6 +12,6 @@ RUN adduser -D -g '' xmpp-webhook
|
||||||
USER xmpp-webhook
|
USER xmpp-webhook
|
||||||
ENV XMPP_ID="" \
|
ENV XMPP_ID="" \
|
||||||
XMPP_PASS="" \
|
XMPP_PASS="" \
|
||||||
XMPP_RECEIVERS=""
|
XMPP_RECIPIENTS=""
|
||||||
EXPOSE 4321
|
EXPOSE 4321
|
||||||
CMD ["/xmpp-webhook"]
|
CMD ["/xmpp-webhook"]
|
||||||
|
|
10
README.md
10
README.md
|
@ -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-webhook` is configured via environment variables:
|
||||||
- `XMPP_ID` - The JID we want to use
|
- `XMPP_ID` - The JID we want to use
|
||||||
- `XMPP_PASS` - The password
|
- `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_SKIP_VERIFY` - Skip TLS verification (Optional)
|
||||||
- `XMPP_OVER_TLS` - Use dedicated TLS port (Optional)
|
- `XMPP_OVER_TLS` - Use dedicated TLS port (Optional)
|
||||||
- `XMPP_WEBHOOK_LISTEN_ADDRESS` - Bind address (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/alertmanager-example.json localhost:4321/alertmanager
|
||||||
curl -X POST -d @dev/slack-compatible-notification-example.json localhost:4321/slack
|
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
|
## Run with Docker
|
||||||
### Build it
|
### Build it
|
||||||
- Build image: `docker build -t xmpp-webhook .`
|
- 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
|
### 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
|
## Installation
|
||||||
- Download and extract the latest tarball (GitHub release page)
|
- 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_ID='bot@example.com'
|
||||||
XMPP_PASS='passw0rd'
|
XMPP_PASS='passw0rd'
|
||||||
XMPP_RECEIVERS='jdoe@example.com,ops@example.com'
|
XMPP_RECIPIENTS='jdoe@example.com,ops@example.com'
|
||||||
```
|
```
|
||||||
|
|
||||||
- Enable and start the service:
|
- Enable and start the service:
|
||||||
|
|
10
main.go
10
main.go
|
@ -72,10 +72,10 @@ func closeXMPP(session *xmpp.Session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// get xmpp credentials, message receivers
|
// get xmpp credentials, message recipients
|
||||||
xi := os.Getenv("XMPP_ID")
|
xi := os.Getenv("XMPP_ID")
|
||||||
xp := os.Getenv("XMPP_PASS")
|
xp := os.Getenv("XMPP_PASS")
|
||||||
xr := os.Getenv("XMPP_RECEIVERS")
|
xr := os.Getenv("XMPP_RECIPIENTS")
|
||||||
|
|
||||||
// get tls settings from env
|
// get tls settings from env
|
||||||
_, skipTLSVerify := os.LookupEnv("XMPP_SKIP_VERIFY")
|
_, skipTLSVerify := os.LookupEnv("XMPP_SKIP_VERIFY")
|
||||||
|
@ -87,9 +87,9 @@ func main() {
|
||||||
listenAddress = ":4321"
|
listenAddress = ":4321"
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if xmpp credentials and receiver list are supplied
|
// check if xmpp credentials and recipient list are supplied
|
||||||
if xi == "" || xp == "" || xr == "" {
|
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)
|
myjid, err := jid.Parse(xi)
|
||||||
|
@ -147,7 +147,7 @@ func main() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
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() {
|
go func() {
|
||||||
for m := range messages {
|
for m := range messages {
|
||||||
for _, r := range strings.Split(xr, ",") {
|
for _, r := range strings.Split(xr, ",") {
|
||||||
|
|
Ładowanie…
Reference in New Issue