From 072481417147e7f3b824284e321d634958ab6c95 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sun, 24 Feb 2019 07:51:58 +0000 Subject: [PATCH 1/3] resource/cloudflare_load_balancer_monitor: Fix incorrect data type cast for port --- cloudflare/resource_cloudflare_load_balancer_monitor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudflare/resource_cloudflare_load_balancer_monitor.go b/cloudflare/resource_cloudflare_load_balancer_monitor.go index aa92724797..64f43d023a 100644 --- a/cloudflare/resource_cloudflare_load_balancer_monitor.go +++ b/cloudflare/resource_cloudflare_load_balancer_monitor.go @@ -143,7 +143,7 @@ func resourceCloudflareLoadBalancerPoolMonitorCreate(d *schema.ResourceData, met } if port, ok := d.GetOk("port"); ok { - loadBalancerMonitor.Port = port.(uint16) + loadBalancerMonitor.Port = uint16(port.(int)) } log.Printf("[DEBUG] Creating Cloudflare Load Balancer Monitor from struct: %+v", loadBalancerMonitor) @@ -188,7 +188,7 @@ func resourceCloudflareLoadBalancerPoolMonitorUpdate(d *schema.ResourceData, met } if port, ok := d.GetOk("port"); ok { - loadBalancerMonitor.Port = port.(uint16) + loadBalancerMonitor.Port = uint16(port.(int)) } log.Printf("[DEBUG] Update Cloudflare Load Balancer Monitor from struct: %+v", loadBalancerMonitor) From fbc174f722636201351f747b5f574f7943c2df33 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sun, 24 Feb 2019 08:31:19 +0000 Subject: [PATCH 2/3] Add validation to port field --- cloudflare/resource_cloudflare_load_balancer_monitor.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cloudflare/resource_cloudflare_load_balancer_monitor.go b/cloudflare/resource_cloudflare_load_balancer_monitor.go index 64f43d023a..a64eaf52bc 100644 --- a/cloudflare/resource_cloudflare_load_balancer_monitor.go +++ b/cloudflare/resource_cloudflare_load_balancer_monitor.go @@ -103,8 +103,9 @@ func resourceCloudflareLoadBalancerMonitor() *schema.Resource { }, "port": { - Type: schema.TypeInt, - Optional: true, + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(0, 65535), }, "created_on": { From 2bb397c79d5cfb4bc27c42986410cd260be6859a Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sun, 24 Feb 2019 08:32:43 +0000 Subject: [PATCH 3/3] Clean up imports --- cloudflare/resource_cloudflare_record_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cloudflare/resource_cloudflare_record_test.go b/cloudflare/resource_cloudflare_record_test.go index fc78a7ddd0..1daaf43f87 100644 --- a/cloudflare/resource_cloudflare_record_test.go +++ b/cloudflare/resource_cloudflare_record_test.go @@ -3,12 +3,10 @@ package cloudflare import ( "fmt" "os" + "regexp" "testing" - "time" - "regexp" - "github.com/cloudflare/cloudflare-go" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform"