Skip to content

Commit 8b73b4f

Browse files
author
Ivo Delmis
committed
feat(bash): add pagerduty-alert
SXT-600 Signed-off-by: Ivo Delmis <ivo@blockchaintp.com>
1 parent 57c03b2 commit 8b73b4f

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ default_language_version:
44
python: python3
55
repos:
66
- repo: https://github.com/commitizen-tools/commitizen
7-
rev: v2.17.4
7+
rev: v2.17.6
88
hooks:
99
- id: commitizen
1010
stages: [commit-msg]
@@ -48,11 +48,11 @@ repos:
4848
hooks:
4949
- id: markdownlint_docker
5050
- repo: https://github.com/pre-commit/mirrors-eslint
51-
rev: v7.25.0
51+
rev: v7.26.0
5252
hooks:
5353
- id: eslint
5454
- repo: https://github.com/pre-commit/pre-commit-hooks
55-
rev: v3.4.0
55+
rev: v4.0.1
5656
hooks:
5757
- id: check-added-large-files
5858
- id: check-case-conflict

bash/pagerduty-alert

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ options::parse_available "$@"
3636

3737
ALERT_TITLE=${ALERT_TITLE:="Test Alert"}
3838
ALERT_FROM=${ALERT_FROM:="no-reply@blockchaintp.com"}
39-
INCIDENT_KEY=${INCIDENT_KEY:="default_dedup"}
4039

4140
case $ALERT_TYPE in
4241
incident)

bash/pagerduty.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ function send_incident() {
3434
local alert_token="${5:?}"
3535
local incident_key="${6:?}"
3636

37-
incident_data() {
38-
cat <<EOF
39-
{ "incident": { "type": "$alert_type", "title": "$alert_title", "service": { "id": "$service_id", "type": "service_reference" }, "incident_key": "$incident_key" } }
37+
if [ -z "$incident_key" ]; then
38+
incident_data() {
39+
cat <<EOF
40+
{ "incident": { "type": "$alert_type", "title": "$alert_title", "service": { "id": "$service_id", "type": "service_reference" } } }
4041
EOF
41-
}
42+
}
43+
else
44+
incident_data() {
45+
cat <<EOF
46+
{ "incident": { "type": "$alert_type", "title": "$alert_title", "service": { "id": "$service_id", "type": "service_reference" }, "incident_key": "$incident_key" } }
47+
EOF
48+
}
49+
fi
4250

4351
_curl POST --header 'Content-Type: application/json' \
4452
--header 'Accept: application/vnd.pagerduty+json;version=2' \

0 commit comments

Comments
 (0)