Skip to content

Commit

Permalink
Merge pull request #114 from uptime-com/release/2.9.0
Browse files Browse the repository at this point in the history
Release/2.9.0
  • Loading branch information
gigovich authored Oct 4, 2024
2 parents b97ed40 + 5031c31 commit 86340ca
Show file tree
Hide file tree
Showing 19 changed files with 947 additions and 36 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Uptime.com Terraform provider changelog

## v2.9.0

- Add `uptime_check_maintenance` resource
- Add `sensitivity` to `uptime_check_icmp`, fix #97
- Fix `uptime_percent_calculation` value `AVERAGE` for `uptime_check_group` resource, fix #87
- Upgrade dependencies

## v2.8.0

- Add `uptime_scheduled_report` resource

## v2.7.0

- Add `uptime_sla_report` resource
- Fix TCP check SSL configuration option

## v2.6.0

- Add validation for HTTP check custom port field
- Update documentation
- Upgrade dependencies
Expand Down
1 change: 1 addition & 0 deletions docs/resources/check_icmp.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Monitor network activity for a specific domain or IP address
- `locations` (Set of String)
- `notes` (String)
- `num_retries` (Number) How many times the check should be retried before a location is considered down
- `sensitivity` (Number) How many locations should be down before an alert is sent
- `sla` (Attributes) SLA related attributes (see [below for nested schema](#nestedatt--sla))
- `tags` (Set of String)
- `use_ip_version` (String) Whether to use IPv4 or IPv6 for the check.
Expand Down
42 changes: 42 additions & 0 deletions docs/resources/check_maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "uptime_check_maintenance Resource - terraform-provider-uptime"
subcategory: ""
description: |-
Set maintenance windows for a check
---

# uptime_check_maintenance (Resource)

Set maintenance windows for a check



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `check_id` (Number)

### Optional

- `schedule` (Attributes Set) (see [below for nested schema](#nestedatt--schedule))
- `state` (String)

<a id="nestedatt--schedule"></a>
### Nested Schema for `schedule`

Optional:

- `from_time` (String)
- `monthday` (Number)
- `monthday_from` (Number)
- `monthday_to` (Number)
- `once_end_date` (String)
- `once_start_date` (String)
- `to_time` (String)
- `type` (String)
- `weekdays` (Set of Number)


21 changes: 12 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module github.com/uptime-com/terraform-provider-uptime

go 1.21.3
go 1.22.0

toolchain go1.23.1

require (
github.com/dustinkirkland/golang-petname v0.0.0-20230927204539-348648eed816
github.com/google/go-cmp v0.6.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/terraform-plugin-framework v1.11.0
github.com/hashicorp/terraform-plugin-framework v1.12.0
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-go v0.24.0
github.com/hashicorp/terraform-plugin-testing v1.10.0
github.com/nsf/jsondiff v0.0.0-20230430225905-43f6cf3098c1
github.com/pkg/errors v0.9.1
github.com/shopspring/decimal v1.4.0
github.com/stretchr/testify v1.9.0
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240909144813-ed02ddd58c28
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20241003114205-5aa12ad3c97a
)

require (
Expand All @@ -31,7 +34,7 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
Expand Down Expand Up @@ -61,15 +64,15 @@ require (
github.com/zclconf/go-cty v1.15.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.66.2 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
44 changes: 18 additions & 26 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB1
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A=
github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI=
github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0=
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
Expand All @@ -80,12 +80,14 @@ github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVW
github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg=
github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec=
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
github.com/hashicorp/terraform-plugin-framework v1.11.0 h1:M7+9zBArexHFXDx/pKTxjE6n/2UCXY6b8FIq9ZYhwfE=
github.com/hashicorp/terraform-plugin-framework v1.11.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM=
github.com/hashicorp/terraform-plugin-framework v1.12.0 h1:7HKaueHPaikX5/7cbC1r9d1m12iYHY+FlNZEGxQ42CQ=
github.com/hashicorp/terraform-plugin-framework v1.12.0/go.mod h1:N/IOQ2uYjW60Jp39Cp3mw7I/OpC/GfZ0385R0YibmkE=
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0 h1:v3DapR8gsp3EM8fKMh6up9cJUFQ2iRaFsYLP8UJnCco=
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0/go.mod h1:c3PnGE9pHBDfdEVG9t1S1C9ia5LW+gkFR0CygXlM8ak=
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E=
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo=
github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co=
github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ=
github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U=
github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE=
Expand Down Expand Up @@ -155,18 +157,8 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240816091657-01f29c8b455e h1:CQaxAz5fo8eNmE8+G9K9qppM6NKASlbjPN9WK1ShvlM=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240816091657-01f29c8b455e/go.mod h1:jtWeB/tQ00fLX2r9OwKfTnxQ/PMR0YjmhTuc9RZH2h0=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240826141822-cfb94390fa95 h1:LzsPMkKVHjZjiE+TASYmnRJ2gsF52HqItcs2l6bKVbA=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240826141822-cfb94390fa95/go.mod h1:jtWeB/tQ00fLX2r9OwKfTnxQ/PMR0YjmhTuc9RZH2h0=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240826143229-a0300708e548 h1:YwiDjbozNBe17R8Oy5QnumHh71Lc4+S5G2vC8mAyE/g=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240826143229-a0300708e548/go.mod h1:jtWeB/tQ00fLX2r9OwKfTnxQ/PMR0YjmhTuc9RZH2h0=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240829075731-38b4feeffc12 h1:4EwfHypfh6BxyUYTcVwccp+YPvqshl4klonwhK9ssO4=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240829075731-38b4feeffc12/go.mod h1:jtWeB/tQ00fLX2r9OwKfTnxQ/PMR0YjmhTuc9RZH2h0=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240909143903-2201e1ed51bd h1:CPhzpLzR8yQxk4TwQ4NmqzeEV/MJkFYFI9b6lVXxIhM=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240909143903-2201e1ed51bd/go.mod h1:jtWeB/tQ00fLX2r9OwKfTnxQ/PMR0YjmhTuc9RZH2h0=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240909144813-ed02ddd58c28 h1:m8H8Q1ZXZEZQk74afxryN2NuRLuMEWi6oB/KjAl7evU=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20240909144813-ed02ddd58c28/go.mod h1:jtWeB/tQ00fLX2r9OwKfTnxQ/PMR0YjmhTuc9RZH2h0=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20241003114205-5aa12ad3c97a h1:bMIbbcsD3mnLzVD0fxnJk1sW+fRiT/yFw9gW2Rz1rsw=
github.com/uptime-com/uptime-client-go/v2 v2.0.0-20241003114205-5aa12ad3c97a/go.mod h1:jtWeB/tQ00fLX2r9OwKfTnxQ/PMR0YjmhTuc9RZH2h0=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
Expand All @@ -192,8 +184,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -234,14 +226,14 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo=
google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4=
google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
8 changes: 7 additions & 1 deletion internal/provider/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

type SetPrimitives interface {
string | int64 | float64 | bool
string | int64 | float64 | int32 | bool
}

type SetAttributeAdapter[P SetPrimitives] struct{}
Expand All @@ -26,6 +26,8 @@ func (a SetAttributeAdapter[P]) Slice(v types.Set) []P {
res[i] = any(elems[i].(types.String).ValueString()).(P)
case types.BoolType:
res[i] = any(elems[i].(types.Bool).ValueBool()).(P)
case types.Int32Type:
res[i] = any(elems[i].(types.Int32).ValueInt32()).(P)
case types.Int64Type:
res[i] = any(elems[i].(types.Int64).ValueInt64()).(P)
case types.Float64Type:
Expand All @@ -45,6 +47,8 @@ func (a SetAttributeAdapter[P]) SliceValue(p []P) types.Set {
elems = append(elems, types.StringValue(x))
case bool:
elems = append(elems, types.BoolValue(x))
case int32:
elems = append(elems, types.Int32Value(x))
case int64:
elems = append(elems, types.Int64Value(x))
case float64:
Expand All @@ -58,6 +62,8 @@ func (a SetAttributeAdapter[P]) SliceValue(p []P) types.Set {
return types.SetValueMust(types.StringType, elems)
case []bool:
return types.SetValueMust(types.BoolType, elems)
case []int32:
return types.SetValueMust(types.Int32Type, elems)
case []int64:
return types.SetValueMust(types.Int64Type, elems)
case []float64:
Expand Down
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (p *providerImpl) Resources(ctx context.Context) []func() resource.Resource
func() resource.Resource { return NewCheckUDPResource(ctx, p) },
func() resource.Resource { return NewCheckWHOISResource(ctx, p) },
func() resource.Resource { return NewCheckWebhookResource(ctx, p) },
func() resource.Resource { return NewCheckMaintenanceResource(ctx, p) },

func() resource.Resource { return NewContactResource(ctx, p) },
func() resource.Resource { return NewStatusPageResource(ctx, p) },
Expand Down
33 changes: 33 additions & 0 deletions internal/provider/resource_check_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,36 @@ func TestAccCheckGroupResource_ResponseTime(t *testing.T) {
},
}))
}

func TestAccCheckGroupResource_PercentCalculation(t *testing.T) {
names := []string{
petname.Generate(3, "-"),
petname.Generate(3, "-"),
}
resource.Test(t, testCaseFromSteps(t, []resource.TestStep{
{
ConfigVariables: config.Variables{
"name": config.StringVariable(names[0]),
"uptime_percent_calculation": config.StringVariable("UP_DOWN_STATES"),
},
ConfigDirectory: config.StaticDirectory("testdata/resource_check_group/percent_calculation"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("uptime_check_group.test", "name", names[0]),
resource.TestCheckResourceAttr("uptime_check_group.test", "config.response_time.check_type", "HTTP"),
resource.TestCheckResourceAttr("uptime_check_group.test", "config.uptime_percent_calculation", "UP_DOWN_STATES"),
),
},
{
ConfigVariables: config.Variables{
"name": config.StringVariable(names[1]),
"uptime_percent_calculation": config.StringVariable("AVERAGE"),
},
ConfigDirectory: config.StaticDirectory("testdata/resource_check_group/percent_calculation"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("uptime_check_group.test", "name", names[1]),
resource.TestCheckResourceAttr("uptime_check_group.test", "config.response_time.check_type", "HTTP"),
resource.TestCheckResourceAttr("uptime_check_group.test", "config.uptime_percent_calculation", "AVERAGE"),
),
},
}))
}
4 changes: 4 additions & 0 deletions internal/provider/resource_check_icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewCheckICMPResource(_ context.Context, p *providerImpl) resource.Resource
"use_ip_version": UseIPVersionSchemaAttribute(),
"notes": NotesSchemaAttribute(),
"include_in_global_metrics": IncludeInGlobalMetricsSchemaAttribute(),
"sensitivity": SensitivitySchemaAttribute(2),
"sla": SLASchemaAttribute(),
},
},
Expand All @@ -55,6 +56,7 @@ type CheckICMPResourceModel struct {
UseIPVersion types.String `tfsdk:"use_ip_version"`
Notes types.String `tfsdk:"notes"`
IncludeInGlobalMetrics types.Bool `tfsdk:"include_in_global_metrics"`
Sensitivity types.Int64 `tfsdk:"sensitivity"`
SLA types.Object `tfsdk:"sla"`

sla *SLAAttribute `tfsdk:"-"`
Expand Down Expand Up @@ -97,6 +99,7 @@ func (a CheckICMPResourceModelAdapter) ToAPIArgument(model CheckICMPResourceMode
UseIPVersion: model.UseIPVersion.ValueString(),
Notes: model.Notes.ValueString(),
IncludeInGlobalMetrics: model.IncludeInGlobalMetrics.ValueBool(),
Sensitivity: model.Sensitivity.ValueInt64(),
}

if model.sla != nil {
Expand Down Expand Up @@ -126,6 +129,7 @@ func (a CheckICMPResourceModelAdapter) FromAPIResult(api upapi.Check) (*CheckICM
UseIPVersion: types.StringValue(api.UseIPVersion),
Notes: types.StringValue(api.Notes),
IncludeInGlobalMetrics: types.BoolValue(api.IncludeInGlobalMetrics),
Sensitivity: types.Int64Value(api.Sensitivity),
SLA: a.SLAAttributeValue(SLAAttribute{
Latency: DurationValueFromDecimalSeconds(api.ResponseTimeSLA),
Uptime: DecimalValue(api.UptimeSLA),
Expand Down
26 changes: 26 additions & 0 deletions internal/provider/resource_check_icmp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,29 @@ func TestAccCheckICMPResource_NumRetries(t *testing.T) {
},
}))
}

func TestAccCheckICMPResource_Sensitivity(t *testing.T) {
name := petname.Generate(3, "-")
resource.Test(t, testCaseFromSteps(t, []resource.TestStep{
{
ConfigDirectory: config.StaticDirectory("testdata/resource_check_icmp/sensitivity"),
ConfigVariables: config.Variables{
"name": config.StringVariable(name),
"sensitivity": config.IntegerVariable(3),
},
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("uptime_check_icmp.test", "sensitivity", "3"),
),
},
{
ConfigDirectory: config.StaticDirectory("testdata/resource_check_icmp/sensitivity"),
ConfigVariables: config.Variables{
"name": config.StringVariable(name),
"sensitivity": config.IntegerVariable(1),
},
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("uptime_check_icmp.test", "sensitivity", "1"),
),
},
}))
}
Loading

0 comments on commit 86340ca

Please sign in to comment.