Skip to content

Commit

Permalink
feat: add parallel run threshold props [sc-19200] (#285)
Browse files Browse the repository at this point in the history
* feat: add parallel run threshold props [sc-19200]

* feat: updates after go generate [sc-19200]

* feat: add tests [sc-19200]

* feat: add schema to heartbeat [sc-19200]

* feat: heartbeat generate [sc-19200]
  • Loading branch information
maxigimenez authored Feb 8, 2024
1 parent 6c91ede commit f611325
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 5 deletions.
48 changes: 46 additions & 2 deletions checkly/resource_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,26 @@ func resourceCheck() *schema.Resource {
},
},
},
"parallel_run_failure_threshold": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Applicable only for checks scheduled in parallel in multiple locations.",
},
"percentage": {
Type: schema.TypeInt,
Optional: true,
Default: 10,
Description: "Possible values are `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `100`, and `100`. (Default `10`).",
},
},
},
},
"ssl_certificates": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -663,6 +683,12 @@ func setFromAlertSettings(as checkly.AlertSettings) []tfMap {
"interval": as.Reminders.Interval,
},
},
"parallel_run_failure_threshold": []tfMap{
{
"enabled": as.ParallelRunFailureThreshold.Enabled,
"percentage": as.ParallelRunFailureThreshold.Percentage,
},
},
},
}
} else {
Expand All @@ -680,6 +706,12 @@ func setFromAlertSettings(as checkly.AlertSettings) []tfMap {
"interval": as.Reminders.Interval,
},
},
"parallel_run_failure_threshold": []tfMap{
{
"enabled": as.ParallelRunFailureThreshold.Enabled,
"percentage": as.ParallelRunFailureThreshold.Percentage,
},
},
},
}
}
Expand Down Expand Up @@ -859,8 +891,9 @@ func alertSettingsFromSet(s *schema.Set) checkly.AlertSettings {
}
res := s.List()[0].(tfMap)
alertSettings := checkly.AlertSettings{
EscalationType: res["escalation_type"].(string),
Reminders: remindersFromSet(res["reminders"].(*schema.Set)),
EscalationType: res["escalation_type"].(string),
Reminders: remindersFromSet(res["reminders"].(*schema.Set)),
ParallelRunFailureThreshold: parallelRunFailureThresholdFromSet(res["parallel_run_failure_threshold"].(*schema.Set)),
}

if alertSettings.EscalationType == checkly.RunBased {
Expand Down Expand Up @@ -954,6 +987,17 @@ func remindersFromSet(s *schema.Set) checkly.Reminders {
}
}

func parallelRunFailureThresholdFromSet(s *schema.Set) checkly.ParallelRunFailureThreshold {
if s.Len() == 0 {
return checkly.ParallelRunFailureThreshold{}
}
res := s.List()[0].(tfMap)
return checkly.ParallelRunFailureThreshold{
Enabled: res["enabled"].(bool),
Percentage: res["percentage"].(int),
}
}

func requestFromSet(s *schema.Set) checkly.Request {
if s.Len() == 0 {
return checkly.Request{}
Expand Down
20 changes: 20 additions & 0 deletions checkly/resource_check_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ func resourceCheckGroup() *schema.Resource {
},
},
},
"parallel_run_failure_threshold": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Applicable only for checks scheduled in parallel in multiple locations.",
},
"percentage": {
Type: schema.TypeInt,
Optional: true,
Default: 10,
Description: "Possible values are `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `100`, and `100`. (Default `10`).",
},
},
},
},
"ssl_certificates": {
Type: schema.TypeSet,
Optional: true,
Expand Down
4 changes: 4 additions & 0 deletions checkly/resource_check_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ const testCheckGroup_full = `
amount = 2
interval = 5
}
parallel_run_failure_threshold {
enabled = false
percentage = 10
}
}
local_setup_script = "setup-test"
local_teardown_script = "teardown-test"
Expand Down
4 changes: 4 additions & 0 deletions checkly/resource_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ const apiCheck_full = `
run_based_escalation {
failed_run_threshold = 1
}
parallel_run_failure_threshold {
enabled = false
percentage = 10
}
}
}
`
Expand Down
20 changes: 20 additions & 0 deletions checkly/resource_heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ func resourceHeartbeat() *schema.Resource {
},
},
},
"parallel_run_failure_threshold": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Applicable only for checks scheduled in parallel in multiple locations.",
},
"percentage": {
Type: schema.TypeInt,
Optional: true,
Default: 10,
Description: "Possible values are `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `100`, and `100`. (Default `10`).",
},
},
},
},
"ssl_certificates": {
Type: schema.TypeSet,
Optional: true,
Expand Down
10 changes: 10 additions & 0 deletions docs/resources/check.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,21 @@ Required:
Optional:

- `escalation_type` (String) Determines what type of escalation to use. Possible values are `RUN_BASED` or `TIME_BASED`.
- `parallel_run_failure_threshold` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--parallel_run_failure_threshold))
- `reminders` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--reminders))
- `run_based_escalation` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--run_based_escalation))
- `ssl_certificates` (Block Set, Deprecated) (see [below for nested schema](#nestedblock--alert_settings--ssl_certificates))
- `time_based_escalation` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--time_based_escalation))

<a id="nestedblock--alert_settings--parallel_run_failure_threshold"></a>
### Nested Schema for `alert_settings.parallel_run_failure_threshold`

Optional:

- `enabled` (Boolean) Applicable only for checks scheduled in parallel in multiple locations.
- `percentage` (Number) Possible values are `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `100`, and `100`. (Default `10`).


<a id="nestedblock--alert_settings--reminders"></a>
### Nested Schema for `alert_settings.reminders`

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/check_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,21 @@ Required:
Optional:

- `escalation_type` (String) Determines what type of escalation to use. Possible values are `RUN_BASED` or `TIME_BASED`.
- `parallel_run_failure_threshold` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--parallel_run_failure_threshold))
- `reminders` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--reminders))
- `run_based_escalation` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--run_based_escalation))
- `ssl_certificates` (Block Set, Deprecated) (see [below for nested schema](#nestedblock--alert_settings--ssl_certificates))
- `time_based_escalation` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--time_based_escalation))

<a id="nestedblock--alert_settings--parallel_run_failure_threshold"></a>
### Nested Schema for `alert_settings.parallel_run_failure_threshold`

Optional:

- `enabled` (Boolean) Applicable only for checks scheduled in parallel in multiple locations.
- `percentage` (Number) Possible values are `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `100`, and `100`. (Default `10`).


<a id="nestedblock--alert_settings--reminders"></a>
### Nested Schema for `alert_settings.reminders`

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/heartbeat.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,21 @@ Required:
Optional:

- `escalation_type` (String) Determines what type of escalation to use. Possible values are `RUN_BASED` or `TIME_BASED`.
- `parallel_run_failure_threshold` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--parallel_run_failure_threshold))
- `reminders` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--reminders))
- `run_based_escalation` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--run_based_escalation))
- `ssl_certificates` (Block Set, Deprecated) (see [below for nested schema](#nestedblock--alert_settings--ssl_certificates))
- `time_based_escalation` (Block Set) (see [below for nested schema](#nestedblock--alert_settings--time_based_escalation))

<a id="nestedblock--alert_settings--parallel_run_failure_threshold"></a>
### Nested Schema for `alert_settings.parallel_run_failure_threshold`

Optional:

- `enabled` (Boolean) Applicable only for checks scheduled in parallel in multiple locations.
- `percentage` (Number) Possible values are `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `100`, and `100`. (Default `10`).


<a id="nestedblock--alert_settings--reminders"></a>
### Nested Schema for `alert_settings.reminders`

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/aws/aws-sdk-go v1.44.122 // indirect
github.com/checkly/checkly-go-sdk v1.7.1
github.com/checkly/checkly-go-sdk v1.7.2
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.5.9
github.com/gruntwork-io/terratest v0.41.16
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/checkly/checkly-go-sdk v1.7.1 h1:6pIu821nf2OjzdaZ8hfNGKcIMaVLzaU7JWDJlk66XGM=
github.com/checkly/checkly-go-sdk v1.7.1/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo=
github.com/checkly/checkly-go-sdk v1.7.2 h1:+hDIURg7M+0HP4PhkZtQ3DdNQW6VwUeoSudC9iKLLgU=
github.com/checkly/checkly-go-sdk v1.7.2/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo=
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down

0 comments on commit f611325

Please sign in to comment.