Templates for custom webhooks are defined with Go Template Syntax. In order to test them, you can use the provided testing script. It runs natively on any Go-lang supported platforms or you can use docker.
The testing scripts basically performs rendering of all templates located within the templates
directory using a representative set of example payloads injected into them which mimics the Kentik Notifications system. Adding a new file or editing an existing file in the templates directory with a .tmpl
extension and then running the test script should be sufficient to verify the correctness of the template.
Using double .json.tmpl
enables additional JSON validation of the output content.
The testing script stores rendered notifications within the output directory. It can be helpful to examine these files to verify that the contents of notifications will have the expected shape.
-
Make sure to have an up-to-date Go runtime setup.
-
Run tests using the command:
go test ./pkg
Running within docker allows you to make the same validation without bothering with setting up Go on your host machine:
- Make sure to have up-to-date Docker environment
- Run tests using example command:
docker run -v $PWD:/go/src/app -w /go/src/app golang:1.17 go test ./pkg
Please note running docker command won't update output
directory with rendered files as the docker container.