Skip to content

Commit

Permalink
Add disable option (#52)
Browse files Browse the repository at this point in the history
The `disable` option lets you temporarily disable Slack notifications
(for testing pipeline configurations or errors) without editing the whole
pipeline to remove or comment out the put steps and the resource itself.
  • Loading branch information
tprobinson authored and jhunt committed May 31, 2018
1 parent 12b1f97 commit ced1751
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -26,6 +26,7 @@ To setup an [Incoming Webhook](https://api.slack.com/incoming-webhooks) go to ht
- `insecure`: *Optional.* Connect to Slack insecurely - i.e. skip SSL validation. Defaults to false if not provided.
- `proxy`: *Optional.* Connect to Slack using an HTTP(S) proxy. In the form: `http://my.proxy:3128`
- `proxy_https_tunnel`: *Optional.* Set to `true` to use an HTTP proxy as an HTTPS tunnel.
- `disable`: *Optional.* Set to `true` to skip all messaging. Convenient for temporarily disabling notifications without editing your pipelines.
- `ca_certs`: *Optional.* An array of objects with the following format:

```yaml
Expand Down
10 changes: 9 additions & 1 deletion out
Expand Up @@ -14,6 +14,15 @@ payload=$(mktemp /tmp/resource-in.XXXXXX)

cat > "${payload}" <&0

timestamp="$(jq -n "{version:{timestamp:\"$(date +%s)\"}}")"

disable="$(jq -r '.source.disable' < "${payload}")"
if [[ "$disable" == "true" ]]
then
echo "$timestamp" >&3
exit 0
fi

webhook_url="$(jq -r '.source.url' < "${payload}")"
allow_insecure="$(jq -r '.source.insecure // "false"' < "${payload}")"
raw_ca_certs=$(jq -r '.source.ca_certs // []' < $payload)
Expand Down Expand Up @@ -187,5 +196,4 @@ EOF

fi

timestamp="$(jq -n "{version:{timestamp:\"$(date +%s)\"}}")"
echo "$timestamp $metadata $debug_info " | jq -s add >&3

0 comments on commit ced1751

Please sign in to comment.