-
Notifications
You must be signed in to change notification settings - Fork 7
/
commands
executable file
·57 lines (47 loc) · 1.4 KB
/
commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/config"
case "$1" in
webhooks)
cat "$HOOKS_FILE" 2>/dev/null
;;
webhooks:add)
[[ -z $2 ]] && echo "Please specify a webhook URL to add" && exit 1
if grep -Fxq "$2" "$HOOKS_FILE" 2>/dev/null; then
echo "URL already registered"
exit 1
fi
echo "$2" >> "$HOOKS_FILE"
echo "URL added"
;;
webhooks:remove)
[[ -z $2 ]] && echo "Please specify a webhook URL to remove" && exit 1
grep -Fxv "$2" "$HOOKS_FILE" >"${HOOKS_FILE}.new" 2>/dev/null || :
mv "${HOOKS_FILE}.new" "$HOOKS_FILE"
echo "URL removed (if it was present)"
;;
help | webhooks:help)
help_content_func() {
#shellcheck disable=SC2034
declare desc="return webhooks plugin help content"
cat<<help_content
webhooks Lists webhook URLs
webhooks:add <url> Adds a webhook URL
webhooks:remove <url> Removes a webhook URL
help_content
}
if [[ $1 = "webhooks:help" ]]; then
echo -e 'Usage: dokku webhooks[:COMMAND]'
echo ''
echo 'Allows triggering external webhooks'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
else
help_content_func
fi
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac