Skip to content

Commit 31511d0

Browse files
[U-1434] Add on_incident_reopened field to outgoing webhook resource (#177)
1 parent da2533d commit 31511d0

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GOLANGCI_LINT := golangci-lint run --disable-all \
88
-E staticcheck \
99
-E typecheck \
1010
-E unused
11-
VERSION := 0.20.5
11+
VERSION := 0.20.7
1212
.PHONY: test build
1313

1414
help:

docs/resources/betteruptime_outgoing_webhook.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ https://betterstack.com/docs/uptime/api/outgoing-webhook-integrations/
2525
- `custom_webhook_template_attributes` (Block List, Max: 1) Custom webhook template configuration. (see [below for nested schema](#nestedblock--custom_webhook_template_attributes))
2626
- `name` (String) The name of the outgoing webhook.
2727
- `on_incident_acknowledged` (Boolean) Whether to trigger webhook when incident is acknowledged. Only when `trigger_type=incident_change`.
28+
- `on_incident_reopened` (Boolean) Whether to trigger webhook when incident is reopened. Only when `trigger_type=incident_change`.
2829
- `on_incident_resolved` (Boolean) Whether to trigger webhook when incident is resolved. Only when `trigger_type=incident_change`.
2930
- `on_incident_started` (Boolean) Whether to trigger webhook when incident starts. Only when `trigger_type=incident_change`.
3031
- `team_name` (String) Used to specify the team the resource should be created in when using global tokens.

examples/advanced/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ resource "betteruptime_outgoing_webhook" "outgoing_webhook_1" {
481481
on_incident_started = true
482482
on_incident_acknowledged = false
483483
on_incident_resolved = false
484+
on_incident_reopened = false
484485

485486
custom_webhook_template_attributes {
486487
http_method = "get"

examples/advanced/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
betteruptime = {
55
source = "BetterStackHQ/better-uptime"
6-
version = ">= 0.20.5"
6+
version = ">= 0.20.7"
77
}
88
}
99
}

internal/provider/resource_outgoing_webhook.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ var outgoingWebhookSchema = map[string]*schema.Schema{
6565
Optional: true,
6666
Default: false,
6767
},
68+
"on_incident_reopened": {
69+
Description: "Whether to trigger webhook when incident is reopened. Only when `trigger_type=incident_change`.",
70+
Type: schema.TypeBool,
71+
Optional: true,
72+
Default: false,
73+
},
6874
"custom_webhook_template_attributes": {
6975
Description: "Custom webhook template configuration.",
7076
Type: schema.TypeList,
@@ -143,6 +149,7 @@ type outgoingWebhook struct {
143149
OnIncidentStarted *bool `json:"on_incident_started,omitempty"`
144150
OnIncidentAcknowledged *bool `json:"on_incident_acknowledged,omitempty"`
145151
OnIncidentResolved *bool `json:"on_incident_resolved,omitempty"`
152+
OnIncidentReopened *bool `json:"on_incident_reopened,omitempty"`
146153
CustomWebhookTemplateAttributes *customWebhookTemplateAttributes `json:"custom_webhook_template_attributes,omitempty"`
147154
TeamName *string `json:"team_name,omitempty"`
148155
}
@@ -158,7 +165,7 @@ func validateOutgoingWebhook(ctx context.Context, d *schema.ResourceDiff, m inte
158165
triggerType := d.Get("trigger_type").(string)
159166

160167
// Validate incident_change specific fields
161-
incidentFields := []string{"on_incident_started", "on_incident_acknowledged", "on_incident_resolved"}
168+
incidentFields := []string{"on_incident_started", "on_incident_acknowledged", "on_incident_resolved", "on_incident_reopened"}
162169

163170
for _, field := range incidentFields {
164171
if value, ok := d.GetOk(field); ok && value.(bool) {
@@ -209,6 +216,7 @@ func outgoingWebhookRef(in *outgoingWebhook, triggerType string) []struct {
209216
{k: "on_incident_started", v: &in.OnIncidentStarted},
210217
{k: "on_incident_acknowledged", v: &in.OnIncidentAcknowledged},
211218
{k: "on_incident_resolved", v: &in.OnIncidentResolved},
219+
{k: "on_incident_reopened", v: &in.OnIncidentReopened},
212220
}...)
213221
}
214222
return refs

internal/provider/resource_outgoing_webhook_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestResourceOutgoingWebhookIntegration(t *testing.T) {
3737
on_incident_started = true
3838
on_incident_acknowledged = true
3939
on_incident_resolved = true
40+
on_incident_reopened = true
4041
}
4142
`, name, url),
4243
Check: resource.ComposeTestCheckFunc(
@@ -47,6 +48,7 @@ func TestResourceOutgoingWebhookIntegration(t *testing.T) {
4748
resource.TestCheckResourceAttr("betteruptime_outgoing_webhook.this", "on_incident_started", "true"),
4849
resource.TestCheckResourceAttr("betteruptime_outgoing_webhook.this", "on_incident_acknowledged", "true"),
4950
resource.TestCheckResourceAttr("betteruptime_outgoing_webhook.this", "on_incident_resolved", "true"),
51+
resource.TestCheckResourceAttr("betteruptime_outgoing_webhook.this", "on_incident_reopened", "true"),
5052
),
5153
},
5254
// Step 2 - update
@@ -63,6 +65,7 @@ func TestResourceOutgoingWebhookIntegration(t *testing.T) {
6365
on_incident_started = false
6466
on_incident_acknowledged = true
6567
on_incident_resolved = true
68+
on_incident_reopened = true
6669
}
6770
`, name, url),
6871
Check: resource.ComposeTestCheckFunc(
@@ -86,6 +89,7 @@ func TestResourceOutgoingWebhookIntegration(t *testing.T) {
8689
on_incident_started = false
8790
on_incident_acknowledged = true
8891
on_incident_resolved = true
92+
on_incident_reopened = true
8993
}
9094
`, name, url),
9195
PlanOnly: true,

0 commit comments

Comments
 (0)