From 77eda8c60d58390a67bf2eb2caa7de6e3041926e Mon Sep 17 00:00:00 2001 From: Tomas Basham Date: Wed, 12 Oct 2022 14:33:48 +0000 Subject: [PATCH] feat(uptime): apply default value for status codes --- Makefile | 4 ++++ docs/resources/uptime_check.md | 5 +---- internal/provider/resource_uptime_check.go | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1dbe2f9..f58fc3d 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,10 @@ $(BINARY_NAME): @echo "building provider" @go build -o $@ +.PHONY: docs +docs: + @go generate ./... + .PHONY: testacc testacc: TF_ACC=1 $(GO) test ./... -v $(TESTARGS) -timeout 120m diff --git a/docs/resources/uptime_check.md b/docs/resources/uptime_check.md index b9e201a..2899928 100644 --- a/docs/resources/uptime_check.md +++ b/docs/resources/uptime_check.md @@ -126,10 +126,6 @@ Optional: ### Nested Schema for `http_check` -Required: - -- `status_codes` (Set of String) List of status codes that trigger an alert - Optional: - `basic_authentication` (Block List, Max: 1) Basic Authentication (RFC7235) configuration block (see [below for nested schema](#nestedblock--http_check--basic_authentication)) @@ -141,6 +137,7 @@ Optional: - `request_method` (String) Type of HTTP check. Either HTTP, or HEAD - `request_payload` (Map of String) Payload submitted with the request. Setting this updates the check to use the HTTP POST verb. Only one of `request_payload` or `request_payload_raw` may be specified - `request_payload_raw` (String) Raw payload submitted with the request. Setting this updates the check to use the HTTP POST verb. Only one of `request_payload` or `request_payload_raw` may be specified +- `status_codes` (Set of String) List of status codes that trigger an alert. If not specified then the default status codes are used. Once set, the default status codes cannot be restored and ommitting this field does not clear the attribute - `timeout` (Number) The number of seconds to wait to receive the first byte - `user_agent` (String) Custom user agent string set when testing - `validate_ssl` (Boolean) Whether to send an alert if the SSL certificate is soon to expire diff --git a/internal/provider/resource_uptime_check.go b/internal/provider/resource_uptime_check.go index dd74913..842005b 100644 --- a/internal/provider/resource_uptime_check.go +++ b/internal/provider/resource_uptime_check.go @@ -194,9 +194,10 @@ func resourceStatusCakeUptimeCheck() *schema.Resource { }, "status_codes": &schema.Schema{ Type: schema.TypeSet, - Required: true, + Computed: true, + Optional: true, MinItems: 1, - Description: "List of status codes that trigger an alert", + Description: "List of status codes that trigger an alert. If not specified then the default status codes are used. Once set, the default status codes cannot be restored and ommitting this field does not clear the attribute", Elem: &schema.Schema{ Type: schema.TypeString, ValidateFunc: intvalidation.StringIsNumerical,