From 7625964f170ddb0008d8d0ef0d3bc56d72c1809f Mon Sep 17 00:00:00 2001 From: Cyb3r-Jak3 Date: Tue, 18 Apr 2023 18:00:05 -0400 Subject: [PATCH] Update to latest cloudflare-go changes --- internal/framework/provider/provider.go | 4 +--- internal/framework/service/turnstile/resource.go | 11 +++++++++-- internal/framework/service/turnstile/resource_test.go | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/framework/provider/provider.go b/internal/framework/provider/provider.go index 9b6d2c6311..489d6f6986 100644 --- a/internal/framework/provider/provider.go +++ b/internal/framework/provider/provider.go @@ -3,14 +3,13 @@ package provider import ( "context" "fmt" - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/turnstile" "log" "math" "regexp" "strconv" "testing" + "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/terraform-provider-cloudflare/internal/consts" "github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/rulesets" "github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider" @@ -308,7 +307,6 @@ func (p *CloudflareProvider) Configure(ctx context.Context, req provider.Configu func (p *CloudflareProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ rulesets.NewResource, - turnstile.NewResource, } } diff --git a/internal/framework/service/turnstile/resource.go b/internal/framework/service/turnstile/resource.go index 851b5f9560..5b66840e1e 100644 --- a/internal/framework/service/turnstile/resource.go +++ b/internal/framework/service/turnstile/resource.go @@ -63,7 +63,7 @@ func (r *TurnstileWidgetResource) Create(ctx context.Context, req resource.Creat widget := buildChallengeWidgetFromModel(data) createWidget, err := r.client.CreateTurnstileWidget(ctx, cloudflare.AccountIdentifier(data.AccountID.ValueString()), - cloudflare.CreateTurnstileWidgetRequest{ + cloudflare.CreateTurnstileWidgetParams{ OffLabel: widget.OffLabel, Name: widget.Name, Domains: widget.Domains, @@ -117,7 +117,14 @@ func (r *TurnstileWidgetResource) Update(ctx context.Context, req resource.Updat widget := buildChallengeWidgetFromModel(data) - updatedWidget, err := r.client.UpdateTurnstileWidget(ctx, cloudflare.AccountIdentifier(data.AccountID.ValueString()), widget) + updatedWidget, err := r.client.UpdateTurnstileWidget(ctx, cloudflare.AccountIdentifier(data.AccountID.ValueString()), cloudflare.UpdateTurnstileWidgetParams{ + OffLabel: widget.OffLabel, + Name: widget.Name, + Domains: widget.Domains, + Mode: widget.Mode, + BotFightMode: widget.BotFightMode, + Region: widget.Region, + }) if err != nil { resp.Diagnostics.AddError("Error reading challenge widget", err.Error()) diff --git a/internal/framework/service/turnstile/resource_test.go b/internal/framework/service/turnstile/resource_test.go index 0626898b8d..95743753d4 100644 --- a/internal/framework/service/turnstile/resource_test.go +++ b/internal/framework/service/turnstile/resource_test.go @@ -29,6 +29,7 @@ func TestAccCloudflareTurnstileWidgetBasic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "domains.0", "example.com"), resource.TestCheckResourceAttr(resourceName, "mode", "invisible"), resource.TestCheckResourceAttr(resourceName, "region", "world"), + resource.TestCheckResourceAttr(resourceName, "offlabel", "false"), ), }, {