Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump github.com/cloudflare/cloudflare-go from 0.70.0 to 0.72.0 #2584

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2584.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:dependency
provider: bumps github.com/cloudflare/cloudflare-go from 0.70.0 to 0.72.0
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/cloudflare/cloudflare-go v0.70.0
github.com/cloudflare/cloudflare-go v0.72.0
github.com/fatih/color v1.13.0 // indirect
github.com/google/uuid v1.3.0
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7N
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/cloudflare-go v0.70.0 h1:4opGbUygM8DjirUuaz23jn3akuAcnOCEx+0nQtQEcFo=
github.com/cloudflare/cloudflare-go v0.70.0/go.mod h1:VW6GuazkaZ4xEDkFt24lkXQUsE8q7BiGqDniC2s8WEM=
github.com/cloudflare/cloudflare-go v0.72.0 h1:khsJV4IE3I7U8eK9CUreGnxQm16MEFN5d0xPJfPnA+0=
github.com/cloudflare/cloudflare-go v0.72.0/go.mod h1:VW6GuazkaZ4xEDkFt24lkXQUsE8q7BiGqDniC2s8WEM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ func dataSourceCloudflareAccessIdentityProviderRead(ctx context.Context, d *sche
return diag.FromErr(err)
}

var providers []cloudflare.AccessIdentityProvider
if identifier.Type == AccountType {
providers, err = client.AccessIdentityProviders(ctx, identifier.Value)
} else {
providers, err = client.ZoneLevelAccessIdentityProviders(ctx, identifier.Value)
}
providers, _, err := client.ListAccessIdentityProviders(ctx, identifier, cloudflare.ListAccessIdentityProvidersParams{})

if err != nil {
return diag.FromErr(fmt.Errorf("error listing Access Identity Providers: %w", err))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestAccCloudflareAccessIdentityProviderDataSourceNotFound(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccCheckCloudflareAccessIdentityProviderDataSource_NotFound(accountID, rnd),
ExpectError: regexp.MustCompile(regexp.QuoteMeta("no Access Identity Providers found")),
ExpectError: regexp.MustCompile(`no Access Identity Providers found|no Access Identity Provider matching name`),
},
},
})
Expand Down
38 changes: 10 additions & 28 deletions internal/sdkv2provider/resource_cloudflare_access_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func resourceCloudflareAccessApplicationCreate(ctx context.Context, d *schema.Re

appType := d.Get("type").(string)

newAccessApplication := cloudflare.AccessApplication{
newAccessApplication := cloudflare.CreateAccessApplicationParams{
Name: d.Get("name").(string),
Domain: d.Get("domain").(string),
Type: cloudflare.AccessApplicationType(appType),
Expand Down Expand Up @@ -81,14 +81,10 @@ func resourceCloudflareAccessApplicationCreate(ctx context.Context, d *schema.Re
return diag.FromErr(err)
}

var accessApplication cloudflare.AccessApplication
if identifier.Type == AccountType {
accessApplication, err = client.CreateAccessApplication(ctx, identifier.Value, newAccessApplication)
} else {
accessApplication, err = client.CreateZoneLevelAccessApplication(ctx, identifier.Value, newAccessApplication)
}
accessApplication, err := client.CreateAccessApplication(ctx, identifier, newAccessApplication)

if err != nil {
return diag.FromErr(fmt.Errorf("error creating Access Application for %s %q: %w", identifier.Type, identifier.Value, err))
return diag.FromErr(fmt.Errorf("error creating Access Application for %s %q: %w", identifier.Level, identifier.Identifier, err))
}

d.SetId(accessApplication.ID)
Expand All @@ -104,12 +100,7 @@ func resourceCloudflareAccessApplicationRead(ctx context.Context, d *schema.Reso
return diag.FromErr(err)
}

var accessApplication cloudflare.AccessApplication
if identifier.Type == AccountType {
accessApplication, err = client.AccessApplication(ctx, identifier.Value, d.Id())
} else {
accessApplication, err = client.ZoneLevelAccessApplication(ctx, identifier.Value, d.Id())
}
accessApplication, err := client.GetAccessApplication(ctx, identifier, d.Id())

if err != nil {
var notFoundError *cloudflare.NotFoundError
Expand Down Expand Up @@ -160,7 +151,7 @@ func resourceCloudflareAccessApplicationUpdate(ctx context.Context, d *schema.Re

appType := d.Get("type").(string)

updatedAccessApplication := cloudflare.AccessApplication{
updatedAccessApplication := cloudflare.UpdateAccessApplicationParams{
ID: d.Id(),
Name: d.Get("name").(string),
Domain: d.Get("domain").(string),
Expand Down Expand Up @@ -210,14 +201,9 @@ func resourceCloudflareAccessApplicationUpdate(ctx context.Context, d *schema.Re
return diag.FromErr(err)
}

var accessApplication cloudflare.AccessApplication
if identifier.Type == AccountType {
accessApplication, err = client.UpdateAccessApplication(ctx, identifier.Value, updatedAccessApplication)
} else {
accessApplication, err = client.UpdateZoneLevelAccessApplication(ctx, identifier.Value, updatedAccessApplication)
}
accessApplication, err := client.UpdateAccessApplication(ctx, identifier, updatedAccessApplication)
if err != nil {
return diag.FromErr(fmt.Errorf("error updating Access Application for %s %q: %w", identifier.Type, identifier.Value, err))
return diag.FromErr(fmt.Errorf("error updating Access Application for %s %q: %w", identifier.Level, identifier.Identifier, err))
}

if accessApplication.ID == "" {
Expand All @@ -238,13 +224,9 @@ func resourceCloudflareAccessApplicationDelete(ctx context.Context, d *schema.Re
return diag.FromErr(err)
}

if identifier.Type == AccountType {
err = client.DeleteAccessApplication(ctx, identifier.Value, appID)
} else {
err = client.DeleteZoneLevelAccessApplication(ctx, identifier.Value, appID)
}
err = client.DeleteAccessApplication(ctx, identifier, appID)
if err != nil {
return diag.FromErr(fmt.Errorf("error deleting Access Application for %s %q: %w", identifier.Type, identifier.Value, err))
return diag.FromErr(fmt.Errorf("error deleting Access Application for %s %q: %w", identifier.Level, identifier.Identifier, err))
}

readErr := resourceCloudflareAccessApplicationRead(ctx, d, meta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func testSweepCloudflareAccessApplications(r string) error {

// Zone level Access Applications.
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID")
zoneAccessApps, _, err := client.ZoneLevelAccessApplications(context.Background(), zoneID, cloudflare.PaginationOptions{})
zoneAccessApps, _, err := client.ListAccessApplications(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListAccessApplicationsParams{})
if err != nil {
tflog.Error(ctx, fmt.Sprintf("Failed to fetch zone level Access Applications: %s", err))
}
Expand All @@ -44,14 +44,14 @@ func testSweepCloudflareAccessApplications(r string) error {
}

for _, accessApp := range zoneAccessApps {
if err := client.DeleteZoneLevelAccessApplication(context.Background(), zoneID, accessApp.ID); err != nil {
if err := client.DeleteAccessApplication(context.Background(), cloudflare.ZoneIdentifier(zoneID), accessApp.ID); err != nil {
tflog.Error(ctx, fmt.Sprintf("Failed to delete zone level Access Application %s", accessApp.ID))
}
}

// Account level Access Applications.
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
accountAccessApps, _, err := client.AccessApplications(context.Background(), accountID, cloudflare.PaginationOptions{})
accountAccessApps, _, err := client.ListAccessApplications(context.Background(), cloudflare.AccountIdentifier(accountID), cloudflare.ListAccessApplicationsParams{})
if err != nil {
tflog.Error(ctx, fmt.Sprintf("Failed to fetch account level Access Applications: %s", err))
}
Expand All @@ -62,7 +62,7 @@ func testSweepCloudflareAccessApplications(r string) error {
}

for _, accessApp := range accountAccessApps {
if err := client.DeleteAccessApplication(context.Background(), accountID, accessApp.ID); err != nil {
if err := client.DeleteAccessApplication(context.Background(), cloudflare.AccountIdentifier(accountID), accessApp.ID); err != nil {
tflog.Error(ctx, fmt.Sprintf("Failed to delete account level Access Application %s", accessApp.ID))
}
}
Expand All @@ -87,7 +87,7 @@ func TestAccCloudflareAccessApplication_BasicZone(t *testing.T) {
CheckDestroy: testAccCheckCloudflareAccessApplicationDestroy,
Steps: []resource.TestStep{
{
Config: testAccCloudflareAccessApplicationConfigBasic(rnd, domain, AccessIdentifier{Type: ZoneType, Value: zoneID}),
Config: testAccCloudflareAccessApplicationConfigBasic(rnd, domain, cloudflare.ZoneIdentifier(zoneID)),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, consts.ZoneIDSchemaKey, zoneID),
resource.TestCheckResourceAttr(name, "name", rnd),
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestAccCloudflareAccessApplication_BasicAccount(t *testing.T) {
CheckDestroy: testAccCheckCloudflareAccessApplicationDestroy,
Steps: []resource.TestStep{
{
Config: testAccCloudflareAccessApplicationConfigBasic(rnd, domain, AccessIdentifier{Type: AccountType, Value: accountID}),
Config: testAccCloudflareAccessApplicationConfigBasic(rnd, domain, cloudflare.AccountIdentifier(accountID)),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, consts.AccountIDSchemaKey, accountID),
resource.TestCheckResourceAttr(name, "name", rnd),
Expand Down Expand Up @@ -489,7 +489,7 @@ func TestAccCloudflareAccessApplication_WithSelfHostedDomains(t *testing.T) {
CheckDestroy: testAccCheckCloudflareAccessApplicationDestroy,
Steps: []resource.TestStep{
{
Config: testAccCloudflareAccessApplicationWithSelfHostedDomains(rnd, domain, AccessIdentifier{Type: AccountType, Value: accountID}),
Config: testAccCloudflareAccessApplicationWithSelfHostedDomains(rnd, domain, cloudflare.AccountIdentifier(accountID)),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, consts.AccountIDSchemaKey, accountID),
resource.TestCheckResourceAttr(name, "name", rnd),
Expand All @@ -506,7 +506,7 @@ func TestAccCloudflareAccessApplication_WithSelfHostedDomains(t *testing.T) {
})
}

func testAccCloudflareAccessApplicationConfigBasic(rnd string, domain string, identifier AccessIdentifier) string {
func testAccCloudflareAccessApplicationConfigBasic(rnd string, domain string, identifier *cloudflare.ResourceContainer) string {
return fmt.Sprintf(`
resource "cloudflare_access_application" "%[1]s" {
%[3]s_id = "%[4]s"
Expand All @@ -516,7 +516,7 @@ resource "cloudflare_access_application" "%[1]s" {
session_duration = "24h"
auto_redirect_to_identity = false
}
`, rnd, domain, identifier.Type, identifier.Value)
`, rnd, domain, identifier.Type, identifier.Identifier)
}

func testAccCloudflareAccessApplicationConfigWithCORS(rnd, zoneID, domain string) string {
Expand Down Expand Up @@ -733,7 +733,7 @@ resource "cloudflare_access_application" "%[1]s" {
`, rnd, zoneID, domain)
}

func testAccCloudflareAccessApplicationWithSelfHostedDomains(rnd string, domain string, identifier AccessIdentifier) string {
func testAccCloudflareAccessApplicationWithSelfHostedDomains(rnd string, domain string, identifier *cloudflare.ResourceContainer) string {
return fmt.Sprintf(`
resource "cloudflare_access_application" "%[1]s" {
%[3]s_id = "%[4]s"
Expand All @@ -746,7 +746,7 @@ resource "cloudflare_access_application" "%[1]s" {
"d2.%[1]s.%[2]s"
]
}
`, rnd, domain, identifier.Type, identifier.Value)
`, rnd, domain, identifier.Type, identifier.Identifier)
}

func testAccCheckCloudflareAccessApplicationDestroy(s *terraform.State) error {
Expand All @@ -759,14 +759,14 @@ func testAccCheckCloudflareAccessApplicationDestroy(s *terraform.State) error {

var notFoundError *cloudflare.NotFoundError
if rs.Primary.Attributes[consts.ZoneIDSchemaKey] != "" {
_, err := client.ZoneLevelAccessApplication(context.Background(), rs.Primary.Attributes[consts.ZoneIDSchemaKey], rs.Primary.ID)
_, err := client.GetAccessApplication(context.Background(), cloudflare.ZoneIdentifier(rs.Primary.Attributes[consts.ZoneIDSchemaKey]), rs.Primary.ID)
if !errors.As(err, &notFoundError) {
return fmt.Errorf("AccessApplication still exists")
}
}

if rs.Primary.Attributes[consts.AccountIDSchemaKey] != "" {
_, err := client.AccessApplication(context.Background(), rs.Primary.Attributes[consts.AccountIDSchemaKey], rs.Primary.ID)
_, err := client.GetAccessApplication(context.Background(), cloudflare.AccountIdentifier(rs.Primary.Attributes[consts.AccountIDSchemaKey]), rs.Primary.ID)
if !errors.As(err, &notFoundError) {
return fmt.Errorf("AccessApplication still exists")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@ func resourceCloudflareAccessCACertificateCreate(ctx context.Context, d *schema.
return diag.FromErr(err)
}

var accessCACert cloudflare.AccessCACertificate
if identifier.Type == AccountType {
accessCACert, err = client.CreateAccessCACertificate(ctx, identifier.Value, d.Get("application_id").(string))
} else {
accessCACert, err = client.CreateZoneLevelAccessCACertificate(ctx, identifier.Value, d.Get("application_id").(string))
}
accessCACert, err := client.CreateAccessCACertificate(ctx, identifier, cloudflare.CreateAccessCACertificateParams{ApplicationID: d.Get("application_id").(string)})
if err != nil {
return diag.FromErr(fmt.Errorf("error creating Access CA Certificate for %s %q: %w", identifier.Type, identifier.Value, err))
return diag.FromErr(fmt.Errorf("error creating Access CA Certificate for %s %q: %w", identifier.Level, identifier.Identifier, err))
}

d.SetId(accessCACert.ID)
Expand All @@ -62,12 +57,7 @@ func resourceCloudflareAccessCACertificateRead(ctx context.Context, d *schema.Re
return diag.FromErr(err)
}

var accessCACert cloudflare.AccessCACertificate
if identifier.Type == AccountType {
accessCACert, err = client.AccessCACertificate(ctx, identifier.Value, applicationID)
} else {
accessCACert, err = client.ZoneLevelAccessCACertificate(ctx, identifier.Value, applicationID)
}
accessCACert, err := client.GetAccessCACertificate(ctx, identifier, applicationID)

if err != nil {
var notFoundError *cloudflare.NotFoundError
Expand Down Expand Up @@ -100,11 +90,7 @@ func resourceCloudflareAccessCACertificateDelete(ctx context.Context, d *schema.
return diag.FromErr(err)
}

if identifier.Type == AccountType {
err = client.DeleteAccessCACertificate(ctx, identifier.Value, applicationID)
} else {
err = client.DeleteZoneLevelAccessCACertificate(ctx, identifier.Value, applicationID)
}
err = client.DeleteAccessCACertificate(ctx, identifier, applicationID)

if err != nil {
return diag.FromErr(err)
Expand All @@ -124,7 +110,7 @@ func resourceCloudflareAccessCACertificateImport(ctx context.Context, d *schema.

identifierType, identifierID, applicationID, accessCACertificateID := attributes[0], attributes[1], attributes[2], attributes[3]

if AccessIdentifierType(identifierType) != AccountType && AccessIdentifierType(identifierType) != ZoneType {
if !contains([]string{"zone", "account"}, identifierType) {
return nil, fmt.Errorf("invalid id (\"%s\") specified, should be in format \"account/accountID/applicationID/accessCACertificateID\" or \"zone/zoneID/applicationID/accessCACertificateID\"", d.Id())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccCloudflareAccessCACertificate_AccountLevel(t *testing.T) {
CheckDestroy: testAccCheckCloudflareAccessCACertificateDestroy,
Steps: []resource.TestStep{
{
Config: testAccCloudflareAccessCACertificateBasic(rnd, domain, AccessIdentifier{Type: AccountType, Value: accountID}),
Config: testAccCloudflareAccessCACertificateBasic(rnd, domain, cloudflare.AccountIdentifier(accountID)),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, consts.AccountIDSchemaKey, accountID),
resource.TestCheckResourceAttrSet(name, "application_id"),
Expand All @@ -54,7 +54,7 @@ func TestAccCloudflareAccessCACertificate_ZoneLevel(t *testing.T) {
CheckDestroy: testAccCheckCloudflareAccessCACertificateDestroy,
Steps: []resource.TestStep{
{
Config: testAccCloudflareAccessCACertificateBasic(rnd, domain, AccessIdentifier{Type: ZoneType, Value: zoneID}),
Config: testAccCloudflareAccessCACertificateBasic(rnd, domain, cloudflare.ZoneIdentifier(zoneID)),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, consts.ZoneIDSchemaKey, zoneID),
resource.TestCheckResourceAttrSet(name, "application_id"),
Expand All @@ -66,7 +66,7 @@ func TestAccCloudflareAccessCACertificate_ZoneLevel(t *testing.T) {
})
}

func testAccCloudflareAccessCACertificateBasic(resourceName, domain string, identifier AccessIdentifier) string {
func testAccCloudflareAccessCACertificateBasic(resourceName, domain string, identifier *cloudflare.ResourceContainer) string {
return fmt.Sprintf(`
resource "cloudflare_access_application" "%[1]s" {
name = "%[1]s"
Expand All @@ -77,7 +77,7 @@ resource "cloudflare_access_application" "%[1]s" {
resource "cloudflare_access_ca_certificate" "%[1]s" {
%[3]s_id = "%[4]s"
application_id = cloudflare_access_application.%[1]s.id
}`, resourceName, domain, identifier.Type, identifier.Value)
}`, resourceName, domain, identifier.Type, identifier.Identifier)
}

func testAccCheckCloudflareAccessCACertificateDestroy(s *terraform.State) error {
Expand All @@ -88,12 +88,12 @@ func testAccCheckCloudflareAccessCACertificateDestroy(s *terraform.State) error
continue
}

_, err := client.AccessCACertificate(context.Background(), rs.Primary.Attributes[consts.AccountIDSchemaKey], rs.Primary.ID)
_, err := client.GetAccessCACertificate(context.Background(), cloudflare.AccountIdentifier(rs.Primary.Attributes[consts.AccountIDSchemaKey]), rs.Primary.ID)
if err == nil {
return fmt.Errorf("Access CA certificate still exists")
}

_, err = client.ZoneLevelAccessCACertificate(context.Background(), rs.Primary.Attributes[consts.ZoneIDSchemaKey], rs.Primary.ID)
_, err = client.GetAccessCACertificate(context.Background(), cloudflare.ZoneIdentifier(rs.Primary.Attributes[consts.ZoneIDSchemaKey]), rs.Primary.ID)
if err == nil {
return fmt.Errorf("Access CA certificate still exists")
}
Expand Down
Loading