matrix-org / matrix-hookshot

A bridge between Matrix and multiple project management services, such as GitHub, GitLab and JIRA.
https://matrix-org.github.io/matrix-hookshot/
Apache License 2.0
293 stars 68 forks source link

Ability to declaratively manage webhooks for rooms #636

Open Arkaniad opened 1 year ago

Arkaniad commented 1 year ago

Semi related to #635 - if we could do this managing a unique webhook transform would be less complex

Right now we're stringing together AlertManager alerts from multiple clusters into multiple channels. Our current workflow per-cluster-channel is thus:

Per environment:

This isn't a lot, but we are already having channels with ~5 webhooks each and if we have to update transforms it's laborious to do so to each and every one by hand.

It would be splendid if we could do something like this:

bridge: { ... }
generic: { ... }
listeners: { ... }
logging: { ... }
metrics:
  enabled: true
passFile: /data/passkey.pem
widgets:
  addToAdminRooms: false
  branding:
    widgetTitle: Hookshot Configuration
  publicUrl: https://webhook-hookshot.infra.foo.host/widgetapi/v1/static
  roomSetupWidget:
    addOnInvite: false
  setRoomName: false
rooms:
  - address: "#alert-room:foo.host"
    requiresInvite: true
    configureWidgets: true # overriden by roomSetupWidget above?

    webhooks:
      - name: "Foo Alerts"
        type: generic
        id: 8399849d-2fd8-4f1f-bf38-471f220a15a3
        jsTransform:
          enabled: true
          inline: |-
            stuff.do(true);
          # alternatively / preferably so we can map via k8s configmaps
          # file: /path/to/transform.js
3bbbeau commented 4 months ago

Agreed, currently I do something like:

{
  "name": "webhook-name",
  "transformationFunction": "result={....a lot of escaping within JS}"
}

...which gets really messy escaping within transformationFunction. I've seen yourself @Arkaniad and other users post full JS snippets; is there currently a more elegant way to do it or are you folks just sanitizing the escape characters when you post issues on here? I feel like I might be missing something here.