Skip to content

Commit

Permalink
Update to latest cloudflare-go changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyb3r-Jak3 committed Apr 19, 2023
1 parent 3e0efed commit 7625964
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 1 addition & 3 deletions internal/framework/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
}

Expand Down
11 changes: 9 additions & 2 deletions internal/framework/service/turnstile/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions internal/framework/service/turnstile/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down

0 comments on commit 7625964

Please sign in to comment.