Skip to content

Commit 7b9f982

Browse files
authored
U-7085 [monitor] Set strict defaults for parameters essential for monitoring (#172)
1 parent aba4909 commit 7b9f982

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GOLANGCI_LINT := golangci-lint run --disable-all \
88
-E staticcheck \
99
-E typecheck \
1010
-E unused
11-
VERSION := 0.20.2
11+
VERSION := 0.20.4
1212
.PHONY: test build
1313

1414
help:

internal/provider/resource_monitor.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ var monitorSchema = map[string]*schema.Schema{
120120
Description: "Required if monitor_type is set to keyword or udp. We will create a new incident if this keyword is missing on your page.",
121121
Type: schema.TypeString,
122122
Optional: true,
123-
Computed: true,
124123
},
125124
"expected_status_codes": {
126125
Description: "Required if monitor_type is set to expected_status_code. We will create a new incident if the status code returned from the server is not in the list of expected status codes.",
@@ -129,7 +128,6 @@ var monitorSchema = map[string]*schema.Schema{
129128
Type: schema.TypeInt,
130129
},
131130
Optional: true,
132-
Computed: true,
133131
},
134132
"call": {
135133
Description: "Whether to call when a new incident is created.",
@@ -190,7 +188,6 @@ var monitorSchema = map[string]*schema.Schema{
190188
" tcp and udp monitors accept any ports, while smtp, pop, and imap accept only the specified ports corresponding with their servers (e.g. \"25,465,587\" for smtp).",
191189
Type: schema.TypeString,
192190
Optional: true,
193-
Computed: true,
194191
},
195192
"regions": {
196193
Description: "An array of regions to set. Allowed values are [\"us\", \"eu\", \"as\", \"au\"] or any subset of these regions.",
@@ -245,7 +242,7 @@ var monitorSchema = map[string]*schema.Schema{
245242
Description: "HTTP Method used to make a request. Valid options: GET, HEAD, POST, PUT, PATCH",
246243
Type: schema.TypeString,
247244
Optional: true,
248-
Computed: true,
245+
Default: "GET",
249246
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
250247
return strings.EqualFold(old, new)
251248
},
@@ -264,7 +261,6 @@ var monitorSchema = map[string]*schema.Schema{
264261
Description: "Request body for POST, PUT, PATCH requests. Required if monitor_type is set to dns (domain to query the DNS server with).",
265262
Type: schema.TypeString,
266263
Optional: true,
267-
Computed: true,
268264
},
269265
"request_headers": {
270266
Description: "An array of request headers, consisting of name and value pairs",
@@ -276,7 +272,6 @@ var monitorSchema = map[string]*schema.Schema{
276272
},
277273
},
278274
Optional: true,
279-
Computed: true,
280275
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
281276
// Ignore ID changes
282277
attribute := strings.Split(k, ".")
@@ -291,14 +286,12 @@ var monitorSchema = map[string]*schema.Schema{
291286
Description: "Basic HTTP authentication username to include with the request.",
292287
Type: schema.TypeString,
293288
Optional: true,
294-
Computed: true,
295289
Sensitive: true,
296290
},
297291
"auth_password": {
298292
Description: "Basic HTTP authentication password to include with the request.",
299293
Type: schema.TypeString,
300294
Optional: true,
301-
Computed: true,
302295
Sensitive: true,
303296
},
304297

@@ -394,7 +387,6 @@ var monitorSchema = map[string]*schema.Schema{
394387
Description: "For Playwright monitors, the JavaScript source code of the scenario.",
395388
Type: schema.TypeString,
396389
Optional: true,
397-
Computed: true,
398390
},
399391
"scenario_name": {
400392
Description: "For Playwright monitors, the scenario name identifying the monitor in the UI. For Playwright monitors, either `url` or `scenario_name` must be provided.",

internal/provider/resource_monitor_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func TestResourceMonitorWithExpirationPolicyId(t *testing.T) {
336336
resource.TestCheckResourceAttr("betteruptime_monitor.this", "url", url),
337337
resource.TestCheckResourceAttr("betteruptime_monitor.this", "monitor_type", monitorType),
338338
resource.TestCheckResourceAttr("betteruptime_monitor.this", "expiration_policy_id", "0"),
339-
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","request_headers":null}`),
339+
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","http_method":"GET","request_headers":null}`),
340340
),
341341
},
342342
// Step 2 - update (set to non-null value).
@@ -637,7 +637,7 @@ func TestResourceMonitorWithDomainExpiration(t *testing.T) {
637637
resource.TestCheckResourceAttrSet("betteruptime_monitor.this", "id"),
638638
resource.TestCheckResourceAttr("betteruptime_monitor.this", "url", url),
639639
resource.TestCheckResourceAttr("betteruptime_monitor.this", "monitor_type", monitorType),
640-
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","request_headers":null}`),
640+
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","http_method":"GET","request_headers":null}`),
641641
),
642642
},
643643
// Step 2 - update (set to non-null value).
@@ -760,7 +760,7 @@ func TestResourceMonitorWithSSLExpiration(t *testing.T) {
760760
resource.TestCheckResourceAttrSet("betteruptime_monitor.this", "id"),
761761
resource.TestCheckResourceAttr("betteruptime_monitor.this", "url", url),
762762
resource.TestCheckResourceAttr("betteruptime_monitor.this", "monitor_type", monitorType),
763-
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","request_headers":null}`),
763+
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","http_method":"GET","request_headers":null}`),
764764
),
765765
},
766766
// Step 2 - update (set to non-null value).
@@ -1014,7 +1014,7 @@ func TestResourceMonitorWithDisabledExpirationChecks(t *testing.T) {
10141014
resource.TestCheckResourceAttr("betteruptime_monitor.this", "monitor_type", monitorType),
10151015
resource.TestCheckResourceAttr("betteruptime_monitor.this", "ssl_expiration", "-1"),
10161016
resource.TestCheckResourceAttr("betteruptime_monitor.this", "domain_expiration", "-1"),
1017-
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"ssl_expiration":null,"domain_expiration":null,"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","request_headers":null}`),
1017+
server.TestCheckCalledRequest("POST", "/api/v2/monitors", `{"ssl_expiration":null,"domain_expiration":null,"expiration_policy_id":null,"url":"http://example.com","monitor_type":"status","http_method":"GET","request_headers":null}`),
10181018
),
10191019
},
10201020
},

0 commit comments

Comments
 (0)