Skip to content

Commit

Permalink
feat: add minutes to heartbeat resource, update docs [sc-18336] (#281)
Browse files Browse the repository at this point in the history
Co-authored-by: Maxi <[email protected]>
  • Loading branch information
miliberlin and maxigimenez authored Dec 15, 2023
1 parent 0c19cdd commit c594e3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
9 changes: 7 additions & 2 deletions checkly/resource_heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,15 @@ func resourceHeartbeat() *schema.Resource {
"period": {
Type: schema.TypeInt,
Required: true,
Description: "How often you expect a ping to the ping URL.",
},
"period_unit": {
Type: schema.TypeString,
Required: true,
ValidateFunc: func(value interface{}, key string) (warns []string, errs []error) {
v := value.(string)
isValid := false
options := []string{"seconds", "minutes", "days"}
options := []string{"seconds", "minutes", "hours", "days"}
for _, option := range options {
if v == option {
isValid = true
Expand All @@ -174,18 +175,20 @@ func resourceHeartbeat() *schema.Resource {
}
return warns, errs
},
Description: "Possible values `seconds`, `minutes`, `hours` and `days`.",
},
"grace": {
Type: schema.TypeInt,
Required: true,
Description: "How long Checkly should wait before triggering any alerts when a ping does not arrive within the set period.",
},
"grace_unit": {
Type: schema.TypeString,
Required: true,
ValidateFunc: func(value interface{}, key string) (warns []string, errs []error) {
v := value.(string)
isValid := false
options := []string{"seconds", "minutes", "days"}
options := []string{"seconds", "minutes", "hours", "days"}
for _, option := range options {
if v == option {
isValid = true
Expand All @@ -196,11 +199,13 @@ func resourceHeartbeat() *schema.Resource {
}
return warns, errs
},
Description: "Possible values `seconds`, `minutes`, `hours` and `days`.",
},
"ping_token": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Custom token to generate your ping URL. Checkly will expect a ping to `https://ping.checklyhq.com/[PING_TOKEN]`.",
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions checkly/resource_heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func TestAccHeartbeatCheckInvalidPeriodUnit(t *testing.T) {
accTestCase(t, []resource.TestStep{
{
Config: config,
ExpectError: regexp.MustCompile(`"heartbeat\.0\.period_unit" must be one of \[seconds minutes days\], got lightyear`),
ExpectError: regexp.MustCompile(`"heartbeat\.0\.period_unit" must be one of \[seconds minutes hours days\], got lightyear`),
},
})
}
Expand All @@ -151,7 +151,7 @@ func TestAccHeartbeatCheckInvalidGraceUnit(t *testing.T) {
accTestCase(t, []resource.TestStep{
{
Config: config,
ExpectError: regexp.MustCompile(`"heartbeat\.0\.grace_unit" must be one of \[seconds minutes days\], got lightyear`),
ExpectError: regexp.MustCompile(`"heartbeat\.0\.grace_unit" must be one of \[seconds minutes hours days\], got lightyear`),
},
})
}
Expand Down
10 changes: 5 additions & 5 deletions docs/resources/heartbeat.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ Heartbeats allows you to monitor your cron jobs and set up alerting, so you get

Required:

- `grace` (Number)
- `grace_unit` (String)
- `period` (Number)
- `period_unit` (String)
- `grace` (Number) How long Checkly should wait before triggering any alerts when a ping does not arrive within the set period.
- `grace_unit` (String) Possible values `seconds`, `minutes`, `hours` and `days`.
- `period` (Number) How often you expect a ping to the ping URL.
- `period_unit` (String) Possible values `seconds`, `minutes`, `hours` and `days`.

Optional:

- `ping_token` (String)
- `ping_token` (String) Custom token to generate your ping URL. Checkly will expect a ping to `https://ping.checklyhq.com/[PING_TOKEN]`.


<a id="nestedblock--alert_channel_subscription"></a>
Expand Down

0 comments on commit c594e3a

Please sign in to comment.