From 4b3137cd18c50b745369bff667e949abd8c11b6e Mon Sep 17 00:00:00 2001 From: Nikolai Mishin Date: Sun, 27 Aug 2023 22:40:36 +0200 Subject: [PATCH] Add Consecutive_up and Consecutive_down for load_balancer_monitor resource --- .changelog/2723.txt | 3 +++ ...source_cloudflare_load_balancer_monitor.go | 24 ++++++++++++------- ...e_cloudflare_load_balancer_monitor_test.go | 4 ++++ ...schema_cloudflare_load_balancer_monitor.go | 14 +++++++++++ 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 .changelog/2723.txt diff --git a/.changelog/2723.txt b/.changelog/2723.txt new file mode 100644 index 00000000000..9c00e73ad35 --- /dev/null +++ b/.changelog/2723.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +load_balancer_monitor: add support for `consecutive_up`, `consecutive_down` +``` diff --git a/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor.go b/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor.go index f9c357dcfb0..39ffafc7ade 100644 --- a/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor.go +++ b/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor.go @@ -39,10 +39,12 @@ func resourceCloudflareLoadBalancerPoolMonitorCreate(ctx context.Context, d *sch client := meta.(*cloudflare.API) loadBalancerMonitor := cloudflare.LoadBalancerMonitor{ - Timeout: d.Get("timeout").(int), - Type: d.Get("type").(string), - Interval: d.Get("interval").(int), - Retries: d.Get("retries").(int), + Timeout: d.Get("timeout").(int), + Type: d.Get("type").(string), + Interval: d.Get("interval").(int), + Retries: d.Get("retries").(int), + Consecutive_up: d.Get("consecutive_up").(int), + Consecutive_down: d.Get("consecutive_down").(int), } if description, ok := d.GetOk("description"); ok { @@ -124,11 +126,13 @@ func resourceCloudflareLoadBalancerPoolMonitorUpdate(ctx context.Context, d *sch client := meta.(*cloudflare.API) loadBalancerMonitor := cloudflare.LoadBalancerMonitor{ - ID: d.Id(), - Timeout: d.Get("timeout").(int), - Type: d.Get("type").(string), - Interval: d.Get("interval").(int), - Retries: d.Get("retries").(int), + ID: d.Id(), + Timeout: d.Get("timeout").(int), + Type: d.Get("type").(string), + Interval: d.Get("interval").(int), + Retries: d.Get("retries").(int), + Consecutive_up: d.Get("consecutive_up").(int), + Consecutive_down: d.Get("consecutive_down").(int), } if description, ok := d.GetOk("description"); ok { @@ -246,6 +250,8 @@ func resourceCloudflareLoadBalancerPoolMonitorRead(ctx context.Context, d *schem d.Set("description", loadBalancerMonitor.Description) d.Set("interval", loadBalancerMonitor.Interval) + d.Set("consecutive_up", loadBalancerMonitor.Consecutive_up) + d.Set("consecutive_down", loadBalancerMonitor.Consecutive_down) d.Set("method", loadBalancerMonitor.Method) d.Set("port", int(loadBalancerMonitor.Port)) d.Set("retries", loadBalancerMonitor.Retries) diff --git a/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor_test.go b/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor_test.go index 6ed52c526f4..6f41b2d003d 100644 --- a/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor_test.go +++ b/internal/sdkv2provider/resource_cloudflare_load_balancer_monitor_test.go @@ -105,6 +105,8 @@ func TestAccCloudflareLoadBalancerMonitor_FullySpecified(t *testing.T) { resource.TestCheckResourceAttr(name, "path", "/custom"), resource.TestCheckResourceAttr(name, "header.#", "1"), resource.TestCheckResourceAttr(name, "retries", "5"), + resource.TestCheckResourceAttr(name, "consecutive_up", "2"), + resource.TestCheckResourceAttr(name, "consecutive_down", "2"), resource.TestCheckResourceAttr(name, "port", "8080"), resource.TestCheckResourceAttr(name, "expected_body", "dead"), resource.TestCheckResourceAttr(name, "probe_zone", zoneName), @@ -424,6 +426,8 @@ resource "cloudflare_load_balancer_monitor" "%[3]s" { path = "/custom" interval = 60 retries = 5 + consecutive_up = 2 + consecutive_down = 2 port = 8080 description = "this is a very weird load balancer" probe_zone = "%[1]s" diff --git a/internal/sdkv2provider/schema_cloudflare_load_balancer_monitor.go b/internal/sdkv2provider/schema_cloudflare_load_balancer_monitor.go index 6184af5f694..98bd3070e2b 100644 --- a/internal/sdkv2provider/schema_cloudflare_load_balancer_monitor.go +++ b/internal/sdkv2provider/schema_cloudflare_load_balancer_monitor.go @@ -86,6 +86,20 @@ func resourceCloudflareLoadBalancerMonitorSchema() map[string]*schema.Schema { Description: "Do not validate the certificate when monitor use HTTPS. Only valid if `type` is \"http\" or \"https\"", }, + "consecutive_down": { + Type: schema.TypeInt, + Optional: true, + Default: 2, + Description: "The timeout (in seconds) before marking the health check as failed.", + }, + + "consecutive_up": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + Description: "The timeout (in seconds) before marking the health check as failed.", + }, + "expected_body": { Type: schema.TypeString, Optional: true,