From a8a428a23dd0ab8b1b5fca2107c36c039e2c9554 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Wed, 3 Mar 2021 14:57:21 +1100 Subject: [PATCH] fix nil check for query_string --- cloudflare/resource_cloudflare_page_rule.go | 2 +- cloudflare/resource_cloudflare_page_rule_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cloudflare/resource_cloudflare_page_rule.go b/cloudflare/resource_cloudflare_page_rule.go index baa8936658..6f7c2c3dd3 100644 --- a/cloudflare/resource_cloudflare_page_rule.go +++ b/cloudflare/resource_cloudflare_page_rule.go @@ -899,7 +899,7 @@ func transformToCloudflarePageRuleAction(id string, value interface{}, d *schema // Ensure that if no `include`, `exclude` or `ignore` attributes are // set, we default to including all query string parameters in the // cache key. - if !ignore.(bool) { + if ignore == nil || !ignore.(bool) { if (!ok1 || len(exclude.([]interface{})) == 0) && (!ok2 || len(include.([]interface{})) == 0) { sectionOutput["include"] = "*" } diff --git a/cloudflare/resource_cloudflare_page_rule_test.go b/cloudflare/resource_cloudflare_page_rule_test.go index 203ca5ab3b..1cca0a01d3 100644 --- a/cloudflare/resource_cloudflare_page_rule_test.go +++ b/cloudflare/resource_cloudflare_page_rule_test.go @@ -324,8 +324,8 @@ func TestCacheKeyFieldsNilValue(t *testing.T) { t.Fatalf("Unexpected error transforming page rule action: %s", err) } - if !reflect.DeepEqual(pageRuleAction.Value.(map[string]interface{})["query_string"], map[string]interface{}{"include": []interface{}{"*"}}) { - t.Fatalf("Unexpected transformToCloudflarePageRuleAction result, expected %#v, got %#v", map[string]interface{}{"include": []interface{}{"*"}}, pageRuleAction.Value.(map[string]interface{})["query_string"]) + if !reflect.DeepEqual(pageRuleAction.Value.(map[string]interface{})["query_string"], map[string]interface{}{"include": "*"}) { + t.Fatalf("Unexpected transformToCloudflarePageRuleAction result, expected %#v, got %#v", map[string]interface{}{"include": "*"}, pageRuleAction.Value.(map[string]interface{})["query_string"]) } }