kubeshop / botkube

An app that helps you monitor your Kubernetes cluster, debug critical deployments & gives recommendations for standard practices
https://botkube.io
MIT License
2.11k stars 289 forks source link

Add variable substitution into webhook url parameters #1453

Open oreillymj opened 3 months ago

oreillymj commented 3 months ago

Overview

It would be really useful to be able to dynamically put values from an event triggering a webhook into the URL parameters. For example, it would be nice to expose variables based on JSON path

botkube/kubernetes: context: *default-plugin-context enabled: true config: namespaces: ns-test event: types:

Then in a webhook url, refer to the values above as follows

webhook:
  enabled: true
  url: "http://echo.cluster.local/param?action=someaction&namespace={config.namespaces.value}&event={config.event.types.value}&label={config.labels.value[0]}&labels={config.label.values}&resource={config.resources.type.value}"

Where multiple items can trigger an event, like create,update then the event which triggered the webhook is available as a value. Where items like annotations or labels are an array, you can specify the index or pass the entire array as a base64 encoded JSON array.

It would also be nice to refer to fields in the resource, so for example secrets in a certificate can put into the URL

Acceptance Criteria

Reason

It makes the webhook much more useful for passing values into a REST API.