From 88205cf59088ede289d96c76fe578e84f2f44d2e Mon Sep 17 00:00:00 2001 From: ryota-sakamoto Date: Fri, 28 May 2021 01:25:30 +0900 Subject: [PATCH] chore: update notifications-engine (#293) Signed-off-by: Ryota Sakamoto --- docs/services/email.md | 1 + docs/services/overview.md | 1 + docs/services/rocketchat.md | 96 +++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +- 5 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 docs/services/rocketchat.md diff --git a/docs/services/email.md b/docs/services/email.md index 38cf51a9..b5edf495 100644 --- a/docs/services/email.md +++ b/docs/services/email.md @@ -9,6 +9,7 @@ The Email notification service sends email notifications using SMTP protocol and * `username` - username * `password` - password * `from` - from email address +* `html` - optional bool, true or false ## Example diff --git a/docs/services/overview.md b/docs/services/overview.md index 94bd09af..176a2d5b 100644 --- a/docs/services/overview.md +++ b/docs/services/overview.md @@ -47,3 +47,4 @@ metadata: * [Webhook](./webhook.md) * [Telegram](./telegram.md) * [Teams](./teams.md) +* [Rocket.Chat](./rocketchat.md) diff --git a/docs/services/rocketchat.md b/docs/services/rocketchat.md new file mode 100644 index 00000000..554f42a8 --- /dev/null +++ b/docs/services/rocketchat.md @@ -0,0 +1,96 @@ +# Rocket.Chat + +## Parameters + +The Rocket.Chat notification service configuration includes following settings: + +* `email` - the Rocker.Chat user's email +* `password` - the Rocker.Chat user's password +* `alias` - optional alias that should be used to post message +* `icon` - optional message icon +* `avatar` - optional message avatar +* `serverUrl` - optional Rocket.Chat server url + +## Configuration + +1. Login to your RocketChat instance +2. Go to user management + +![2](https://user-images.githubusercontent.com/15252187/115824993-7ccad900-a411-11eb-89de-6a0c4438ffdf.png) + +3. Add new user with `bot` role. Also note that `Require password change` checkbox mus be not checked + +![3](https://user-images.githubusercontent.com/15252187/115825174-b4d21c00-a411-11eb-8f20-cda48cea9fad.png) + +4. Copy username and password that you was created for bot user +5. Create a public or private channel, or a team, for this example `my_channel` +6. Add your bot to this channel **otherwise it won't work** +7. Store email and password in argocd_notifications-secret Secret + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: +stringData: + rocketchat-email: + rocketchat-password: +``` + +8. Finally, use these credentials to configure the RocketChat integration in the `argocd-configmap` config map: + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: +data: + service.rocketchat: | + email: $rocketchat-email + password: $rocketchat-password +``` + +9. Create a subscription for your Rocket.Chat integration: + +*Note: channel, team or user must be prefixed with # or @ elsewhere we will be interpretative destination as a room ID* + +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + annotations: + notifications.argoproj.io/subscribe.on-sync-succeeded.rocketchat: #my_channel +``` + +## Templates + +Notification templates can be customized with RocketChat [attachments](https://developer.rocket.chat/api/rest-api/methods/chat/postmessage#attachments-detail). + +*Note: Attachments structure in Rocketchat is same with Slack attachments [feature](https://api.slack.com/messaging/composing/layouts).* + + + +The message attachments can be specified in `attachments` string fields under `rocketchat` field: + +```yaml +template.app-sync-status: | + message: | + Application {{.app.metadata.name}} sync is {{.app.status.sync.status}}. + Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. + rocketchat: + attachments: | + [{ + "title": "{{.app.metadata.name}}", + "title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", + "color": "#18be52", + "fields": [{ + "title": "Sync Status", + "value": "{{.app.status.sync.status}}", + "short": true + }, { + "title": "Repository", + "value": "{{.app.spec.source.repoURL}}", + "short": true + }] + }] +``` diff --git a/go.mod b/go.mod index 79ecbbb0..3071db2a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/argoproj/argo-cd/v2 v2.0.0-rc3 - github.com/argoproj/notifications-engine v0.2.1-0.20210507172642-597c59f3cb15 + github.com/argoproj/notifications-engine v0.2.1-0.20210527032340-6e7a43362ff1 github.com/evanphx/json-patch v4.9.0+incompatible github.com/ghodss/yaml v1.0.0 github.com/golang/mock v1.4.4 diff --git a/go.sum b/go.sum index 813d53a1..715db8c8 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,8 @@ github.com/argoproj/argo-cd/v2 v2.0.0-rc3 h1:jBuz8qqLL0gG6Nb892x3+eP+v/wjQpkdSOl github.com/argoproj/argo-cd/v2 v2.0.0-rc3/go.mod h1:Rw7fuyae0v8b3KMJoZp8jf5A2tBP2dQ8uWj9HTRZITo= github.com/argoproj/gitops-engine v0.3.1 h1:wM4RUzH54sWdchD7Ws8UdAIsjk08BmjN9bLuW79xKWk= github.com/argoproj/gitops-engine v0.3.1/go.mod h1:IBHhAkqlC+3r/wBWUitWSidQhPzlLoSTWp2htq3dyQk= -github.com/argoproj/notifications-engine v0.2.1-0.20210507172642-597c59f3cb15 h1:18ggmBbQfKoP2zF/M76X6eVlCUF9SZsnlc9odvEHLv4= -github.com/argoproj/notifications-engine v0.2.1-0.20210507172642-597c59f3cb15/go.mod h1:rKhm9LtebGKgLA/UtPtBeRUrrS/CT0U5az1jSfUiipw= +github.com/argoproj/notifications-engine v0.2.1-0.20210527032340-6e7a43362ff1 h1:xsnbKslPaYqedr5OXRU68raykzLx2zkLtmRo9xhDcvU= +github.com/argoproj/notifications-engine v0.2.1-0.20210527032340-6e7a43362ff1/go.mod h1:rKhm9LtebGKgLA/UtPtBeRUrrS/CT0U5az1jSfUiipw= github.com/argoproj/pkg v0.2.0 h1:ETgC600kr8WcAi3MEVY5sA1H7H/u1/IysYOobwsZ8No= github.com/argoproj/pkg v0.2.0/go.mod h1:F4TZgInLUEjzsWFB/BTJBsewoEy0ucnKSq6vmQiD/yc= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=