Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix example json in template.md #629

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions docs/Templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ In additional to the [built-in Go template functions and features][tt], `webhook
In the example JSON template file below (YAML is also supported), the `payload-hmac-sha1` matching rule looks up the HMAC secret from the environment using the `getenv` template function.
Additionally, the result is piped through the built-in Go template function `js` to ensure that the result is a well-formed Javascript/JSON string.

```
```json
[
{
"id": "webhook",
"execute-command": "/home/adnan/redeploy-go-webhook.sh",
"command-working-directory": "/home/adnan/go",
"response-message": "I got the payload!",
"response-headers":
[
"response-headers": [
{
"name": "Access-Control-Allow-Origin",
"value": "*"
}
],
"pass-arguments-to-command":
[
"pass-arguments-to-command": [
{
"source": "payload",
"name": "head_commit.id"
Expand All @@ -37,29 +36,23 @@ Additionally, the result is piped through the built-in Go template function `js`
"name": "pusher.email"
}
],
"trigger-rule":
{
"and":
[
"trigger-rule": {
"and": [
{
"match":
{
"match": {
"type": "payload-hmac-sha1",
"secret": "{{ getenv "XXXTEST_SECRET" | js }}",
"parameter":
{
"secret": "{{ getenv \"XXXTEST_SECRET\" | js }}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escaping these quotes is not accurate here. This is a Go template, not a JSON file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I did not read the template.md file properly when I created this PR. The missing [ is the only actual issue.

"parameter": {
"source": "header",
"name": "X-Hub-Signature"
}
}
},
{
"match":
{
"match": {
"type": "value",
"value": "refs/heads/master",
"parameter":
{
"parameter": {
"source": "payload",
"name": "ref"
}
Expand All @@ -69,7 +62,6 @@ Additionally, the result is piped through the built-in Go template function `js`
}
}
]

```

[w]: https://github.com/adnanh/webhook
Expand Down