Skip to content

Commit a01f275

Browse files
committed
provider/pd: read urgency from config, defaults to "high"
1 parent 2e52b54 commit a01f275

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

internal/config/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ type PagerDuty struct {
114114
// From is an email address of a valid user associated with the account making the request
115115
From string `yaml:"from"`
116116

117-
RoutingKey string
117+
RoutingKey string `yaml:"routingKey"`
118+
119+
Urgency string `yaml:"urgency"`
118120
}
119121

120122
func ReadPagerDutyFromEnv() *PagerDuty {

internal/provider/pd/incidents.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package pd
22

33
import (
4+
"cmp"
45
"context"
56
"fmt"
67
"strings"
@@ -42,7 +43,7 @@ func (c *client) createInitialIncident(ctx context.Context, service *pagerduty.S
4243
Details: "This incident will be active and used by deadcheck to alert you when check-ins do not occur as expected. Deadcheck will update this incident to reflect the current status of check-in.",
4344
},
4445
IncidentKey: uuid.NewString(),
45-
Urgency: "low",
46+
Urgency: c.urgency(),
4647
EscalationPolicy: &pagerduty.APIReference{
4748
ID: ep.ID,
4849
Type: "escalation_policy",
@@ -105,7 +106,7 @@ func (c *client) snoozeIncident(ctx context.Context, logger log.Logger, inc *pag
105106
{
106107
ID: inc.ID,
107108
Title: fmt.Sprintf("%s did not check-in, expected check-in at %v", service.Name, expectedCheckin),
108-
Urgency: "high",
109+
Urgency: c.urgency(),
109110
},
110111
}
111112
_, err = c.underlying.ManageIncidentsWithContext(ctx, c.pdConfig.From, update)
@@ -131,3 +132,7 @@ func (c *client) resolveIncident(ctx context.Context, inc *pagerduty.Incident) e
131132
}
132133
return nil
133134
}
135+
136+
func (c *client) urgency() string {
137+
return cmp.Or(c.pdConfig.Urgency, "high")
138+
}

0 commit comments

Comments
 (0)