Skip to content

Commit dcb5206

Browse files
authored
feat: allow people to choose IP family with api checks [sc-20606] (#296)
1 parent bc1d1a5 commit dcb5206

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

checkly/resource_check.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,26 @@ func resourceCheck() *schema.Resource {
467467
},
468468
Description: "Set up HTTP basic authentication (username & password).",
469469
},
470+
"ip_family": {
471+
Type: schema.TypeString,
472+
Optional: true,
473+
Default: "IPv4",
474+
Description: "IP Family to be used when executing the api check. The value can be either IPv4 or IPv6.",
475+
ValidateFunc: func(value interface{}, key string) (warns []string, errs []error) {
476+
v := value.(string)
477+
isValid := false
478+
options := []string{"IPv4", "IPv6"}
479+
for _, option := range options {
480+
if v == option {
481+
isValid = true
482+
}
483+
}
484+
if !isValid {
485+
errs = append(errs, fmt.Errorf("%q must be one of %v, got %s", key, options, v))
486+
}
487+
return warns, errs
488+
},
489+
},
470490
},
471491
},
472492
Description: "An API check might have one request config.",
@@ -730,6 +750,7 @@ func setFromRequest(r checkly.Request) []tfMap {
730750
s["query_parameters"] = mapFromKeyValues(r.QueryParameters)
731751
s["assertion"] = setFromAssertions(r.Assertions)
732752
s["basic_auth"] = setFromBasicAuth(r.BasicAuth)
753+
s["ip_family"] = r.IPFamily
733754
return []tfMap{s}
734755
}
735756

@@ -1015,6 +1036,7 @@ func requestFromSet(s *schema.Set) checkly.Request {
10151036
QueryParameters: keyValuesFromMap(res["query_parameters"].(tfMap)),
10161037
Assertions: assertionsFromSet(res["assertion"].(*schema.Set)),
10171038
BasicAuth: basicAuthFromSet(res["basic_auth"].(*schema.Set)),
1039+
IPFamily: res["ip_family"].(string),
10181040
}
10191041
}
10201042

docs/resources/check.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ Optional:
321321
- `body_type` (String) The `Content-Type` header of the request. Possible values `NONE`, `JSON`, `FORM`, `RAW`, and `GRAPHQL`.
322322
- `follow_redirects` (Boolean)
323323
- `headers` (Map of String)
324+
- `ip_family` (String) IP Family to be used when executing the api check. The value can be either IPv4 or IPv6.
324325
- `method` (String) The HTTP method to use for this API check. Possible values are `GET`, `POST`, `PUT`, `HEAD`, `DELETE`, `PATCH`. (Default `GET`).
325326
- `query_parameters` (Map of String)
326327
- `skip_ssl` (Boolean)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/aws/aws-sdk-go v1.44.122 // indirect
7-
github.com/checkly/checkly-go-sdk v1.7.2
7+
github.com/checkly/checkly-go-sdk v1.7.3
88
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
99
github.com/google/go-cmp v0.5.9
1010
github.com/gruntwork-io/terratest v0.41.16

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
231231
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
232232
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
233233
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
234-
github.com/checkly/checkly-go-sdk v1.7.2 h1:+hDIURg7M+0HP4PhkZtQ3DdNQW6VwUeoSudC9iKLLgU=
235-
github.com/checkly/checkly-go-sdk v1.7.2/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo=
234+
github.com/checkly/checkly-go-sdk v1.7.3 h1:tq3urAH58N9y5XLzOsaPpY55smfuz7Wv3adIiNddMv8=
235+
github.com/checkly/checkly-go-sdk v1.7.3/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo=
236236
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
237237
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
238238
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=

0 commit comments

Comments
 (0)