Skip to content

Commit

Permalink
fix: add default escalation settings when empty (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nacho Anaya authored Nov 8, 2022
1 parent 1bc4ffa commit 9328934
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion checkly/resource_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,12 @@ func basicAuthFromSet(s *schema.Set) *checkly.BasicAuth {

func alertSettingsFromSet(s *schema.Set) checkly.AlertSettings {
if s.Len() == 0 {
return checkly.AlertSettings{}
return checkly.AlertSettings{
EscalationType: checkly.RunBased,
RunBasedEscalation: checkly.RunBasedEscalation{
FailedRunThreshold: 1,
},
}
}
res := s.List()[0].(tfMap)
alertSettings := checkly.AlertSettings{
Expand Down
5 changes: 2 additions & 3 deletions checkly/resource_check_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func resourceCheckGroup() *schema.Resource {
"escalation_type": {
Type: schema.TypeString,
Optional: true,
Default: checkly.RunBased,
Description: "Determines what type of escalation to use. Possible values are `RUN_BASED` or `TIME_BASED`.",
},
"run_based_escalation": {
Expand All @@ -165,7 +166,6 @@ func resourceCheckGroup() *schema.Resource {
"failed_run_threshold": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "After how many failed consecutive check runs an alert notification should be sent. Possible values are between 1 and 5. (Default `1`).",
},
},
Expand All @@ -179,7 +179,6 @@ func resourceCheckGroup() *schema.Resource {
"minutes_failing_threshold": {
Type: schema.TypeInt,
Optional: true,
Default: 5,
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`).",
},
},
Expand Down Expand Up @@ -410,7 +409,6 @@ func resourceDataFromCheckGroup(g *checkly.Group, d *schema.ResourceData) error
d.Set("teardown_snippet_id", g.TearDownSnippetID)
d.Set("local_setup_script", g.LocalSetupScript)
d.Set("local_teardown_script", g.LocalTearDownScript)
d.Set("use_global_alert_settings", g.UseGlobalAlertSettings)
d.Set("alert_channel_subscription", g.AlertChannelSubscriptions)
d.Set("private_locations", g.PrivateLocations)

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

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

0 comments on commit 9328934

Please sign in to comment.