From 4006a6c33da55de1913da0846c232187c6a305ca Mon Sep 17 00:00:00 2001 From: Daniel Corbett <38925638+daniel-corbett@users.noreply.github.com> Date: Mon, 12 Jun 2023 03:00:20 -0400 Subject: [PATCH] BUG/MINOR: do not set default response code (#186) `response_code` is only valid for for the `block` action. By setting a default it forces it to be set for all action types including those that it is not valid for. When `response_code` is empty on a blocking action the API just defaults to using the site default (e.g. 406). This commit removes the default from the Terraform provider for `response_code` and also updates the documentation to indicate that it is only valid for the `block` action type. --- docs/index.md | 2 +- docs/resources/site_rule.md | 2 +- provider/resource_site_rule.go | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/index.md b/docs/index.md index 8a79cee..6853d38 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ page_title: "sigsci Provider" subcategory: "" description: |- - + --- ## Requirements diff --git a/docs/resources/site_rule.md b/docs/resources/site_rule.md index e3c16b4..2aa6c31 100644 --- a/docs/resources/site_rule.md +++ b/docs/resources/site_rule.md @@ -250,7 +250,7 @@ Required: Optional: - `redirect_url` (String) URL to redirect to when blocking response code is set to 301 or 302 -- `response_code` (Number) HTTP code agent for agent to respond with. range: 301, 302, or 400-599, defaults to '406' if not provided +- `response_code` (Number) HTTP code agent for agent to respond with. range: 301, 302, or 400-599, defaults to '406' if not provided. Only valid with the 'block' action type. - `signal` (String) signal id to tag ### Templated Signals diff --git a/provider/resource_site_rule.go b/provider/resource_site_rule.go index 7280ab4..64ddf2c 100644 --- a/provider/resource_site_rule.go +++ b/provider/resource_site_rule.go @@ -2,7 +2,6 @@ package provider import ( "fmt" - "net/http" "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -74,10 +73,9 @@ func resourceSiteRule() *schema.Resource { }, "response_code": { Type: schema.TypeInt, - Description: "HTTP code agent for agent to respond with. range: 301, 302, or 400-599, defaults to '406' if not provided", + Description: "HTTP code agent for agent to respond with. range: 301, 302, or 400-599, defaults to '406' if not provided. Only valid with the 'block' action type.", Optional: true, ValidateFunc: validateActionResponseCode, - Default: http.StatusNotAcceptable, }, "redirect_url": { Type: schema.TypeString,