Skip to content

Commit 9328934

Browse files
author
Nacho Anaya
authored
fix: add default escalation settings when empty (#207)
1 parent 1bc4ffa commit 9328934

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

checkly/resource_check.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,12 @@ func basicAuthFromSet(s *schema.Set) *checkly.BasicAuth {
736736

737737
func alertSettingsFromSet(s *schema.Set) checkly.AlertSettings {
738738
if s.Len() == 0 {
739-
return checkly.AlertSettings{}
739+
return checkly.AlertSettings{
740+
EscalationType: checkly.RunBased,
741+
RunBasedEscalation: checkly.RunBasedEscalation{
742+
FailedRunThreshold: 1,
743+
},
744+
}
740745
}
741746
res := s.List()[0].(tfMap)
742747
alertSettings := checkly.AlertSettings{

checkly/resource_check_group.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func resourceCheckGroup() *schema.Resource {
155155
"escalation_type": {
156156
Type: schema.TypeString,
157157
Optional: true,
158+
Default: checkly.RunBased,
158159
Description: "Determines what type of escalation to use. Possible values are `RUN_BASED` or `TIME_BASED`.",
159160
},
160161
"run_based_escalation": {
@@ -165,7 +166,6 @@ func resourceCheckGroup() *schema.Resource {
165166
"failed_run_threshold": {
166167
Type: schema.TypeInt,
167168
Optional: true,
168-
Default: 1,
169169
Description: "After how many failed consecutive check runs an alert notification should be sent. Possible values are between 1 and 5. (Default `1`).",
170170
},
171171
},
@@ -179,7 +179,6 @@ func resourceCheckGroup() *schema.Resource {
179179
"minutes_failing_threshold": {
180180
Type: schema.TypeInt,
181181
Optional: true,
182-
Default: 5,
183182
Description: "After how many minutes after a check starts failing an alert should be sent. Possible values are `5`, `10`, `15`, and `30`. (Default `5`).",
184183
},
185184
},
@@ -410,7 +409,6 @@ func resourceDataFromCheckGroup(g *checkly.Group, d *schema.ResourceData) error
410409
d.Set("teardown_snippet_id", g.TearDownSnippetID)
411410
d.Set("local_setup_script", g.LocalSetupScript)
412411
d.Set("local_teardown_script", g.LocalTearDownScript)
413-
d.Set("use_global_alert_settings", g.UseGlobalAlertSettings)
414412
d.Set("alert_channel_subscription", g.AlertChannelSubscriptions)
415413
d.Set("private_locations", g.PrivateLocations)
416414

@@ -431,6 +429,7 @@ func resourceDataFromCheckGroup(g *checkly.Group, d *schema.ResourceData) error
431429
if err := d.Set("alert_settings", setFromAlertSettings(g.AlertSettings)); err != nil {
432430
return fmt.Errorf("error setting alert settings for resource %s: %s", d.Id(), err)
433431
}
432+
d.Set("use_global_alert_settings", g.UseGlobalAlertSettings)
434433

435434
if err := d.Set("api_check_defaults", setFromAPICheckDefaults(g.APICheckDefaults)); err != nil {
436435
return fmt.Errorf("error setting request for resource %s: %s", d.Id(), err)

0 commit comments

Comments
 (0)