Skip to content

Commit

Permalink
cycloid fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
folago committed Sep 10, 2024
1 parent 9e8175d commit 87d7985
Show file tree
Hide file tree
Showing 10,274 changed files with 946,952 additions and 946,952 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .ci/semgrep/errors/error-checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/tfresource"
)

func test1() {
Expand Down
28 changes: 14 additions & 14 deletions internal/acctest/acctest.go → acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ import (
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-aws/internal/acctest/jsoncmp"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/envvar"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
tfsync "github.com/hashicorp/terraform-provider-aws/internal/experimental/sync"
"github.com/hashicorp/terraform-provider-aws/internal/provider"
tfaccount "github.com/hashicorp/terraform-provider-aws/internal/service/account"
tfacmpca "github.com/hashicorp/terraform-provider-aws/internal/service/acmpca"
tfec2 "github.com/hashicorp/terraform-provider-aws/internal/service/ec2"
tfiam "github.com/hashicorp/terraform-provider-aws/internal/service/iam"
tforganizations "github.com/hashicorp/terraform-provider-aws/internal/service/organizations"
tfsts "github.com/hashicorp/terraform-provider-aws/internal/service/sts"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/acctest/jsoncmp"
"github.com/hashicorp/terraform-provider-aws/conns"
"github.com/hashicorp/terraform-provider-aws/envvar"
"github.com/hashicorp/terraform-provider-aws/errs"
"github.com/hashicorp/terraform-provider-aws/errs/sdkdiag"
tfsync "github.com/hashicorp/terraform-provider-aws/experimental/sync"
"github.com/hashicorp/terraform-provider-aws/provider"
tfaccount "github.com/hashicorp/terraform-provider-aws/service/account"
tfacmpca "github.com/hashicorp/terraform-provider-aws/service/acmpca"
tfec2 "github.com/hashicorp/terraform-provider-aws/service/ec2"
tfiam "github.com/hashicorp/terraform-provider-aws/service/iam"
tforganizations "github.com/hashicorp/terraform-provider-aws/service/organizations"
tfsts "github.com/hashicorp/terraform-provider-aws/service/sts"
"github.com/hashicorp/terraform-provider-aws/tfresource"
"github.com/hashicorp/terraform-provider-aws/names"
"github.com/jmespath/go-jmespath"
"github.com/mitchellh/mapstructure"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/acctest/crypto_test.go → acctest/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/acctest"
)

func TestTLSRSAPrivateKeyPEM(t *testing.T) {
Expand Down
File renamed without changes.
115 changes: 115 additions & 0 deletions acctest/framework.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package acctest

import (
"context"
"fmt"
"log"
"strings"

"github.com/hashicorp/terraform-plugin-framework/path"
fwresource "github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-aws/errs/fwdiag"
)

// Terraform Plugin Framework variants of standard acceptance test helpers.

// CheckFrameworkResourceDisappears destroys an existing resource out of band
//
// By default, this check will only copy root-level string arguments into the state
// used to delete the remote resource. For resources requiring nested or non-string
// arguments to be available for the delete operation, consider using
// CheckFrameworkResourceDisappearsWithStateFunc with a custom state function
// instead.
func CheckFrameworkResourceDisappears(
ctx context.Context,
provo *schema.Provider,
factory func(context.Context) (fwresource.ResourceWithConfigure, error),
n string,
) resource.TestCheckFunc {
return deleteFrameworkResource(ctx, provo, factory, n, rootStringStateFunc())
}

// CheckFrameworkResourceDisappearsWithStateFunc destroys an existing resource
// out of band, constructing state from the provided state function
func CheckFrameworkResourceDisappearsWithStateFunc(
ctx context.Context,
provo *schema.Provider,
factory func(context.Context) (fwresource.ResourceWithConfigure, error),
n string,
stateFunc func(ctx context.Context, state *tfsdk.State, is *terraform.InstanceState) error,
) resource.TestCheckFunc {
return deleteFrameworkResource(ctx, provo, factory, n, stateFunc)
}

func deleteFrameworkResource(
ctx context.Context,
provo *schema.Provider,
factory func(context.Context) (fwresource.ResourceWithConfigure, error),
n string,
stateFunc func(ctx context.Context, state *tfsdk.State, is *terraform.InstanceState) error,
) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("resource not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("resource ID missing: %s", n)
}

resource, err := factory(ctx)
if err != nil {
return err
}

resource.Configure(ctx, fwresource.ConfigureRequest{ProviderData: provo.Meta()}, &fwresource.ConfigureResponse{})

schemaResp := fwresource.SchemaResponse{}
resource.Schema(ctx, fwresource.SchemaRequest{}, &schemaResp)

// Construct a simple Framework State that contains just top-level attributes.
state := tfsdk.State{
Raw: tftypes.NewValue(schemaResp.Schema.Type().TerraformType(ctx), nil),
Schema: schemaResp.Schema,
}

err = stateFunc(ctx, &state, rs.Primary)
if err != nil {
return err
}

response := fwresource.DeleteResponse{}
resource.Delete(ctx, fwresource.DeleteRequest{State: state}, &response)

if response.Diagnostics.HasError() {
return fwdiag.DiagnosticsError(response.Diagnostics)
}

return nil
}
}

// rootStringStateFunc copies root-level string arguments into `state`
func rootStringStateFunc() func(ctx context.Context, state *tfsdk.State, is *terraform.InstanceState) error {
return func(ctx context.Context, state *tfsdk.State, is *terraform.InstanceState) error {
for name, v := range is.Attributes {
if name == "%" || strings.Contains(name, ".") {
continue
}

if err := fwdiag.DiagnosticsError(state.SetAttribute(ctx, path.Root(name), v)); err != nil {
log.Printf("[WARN] %s(%s): %s", name, v, err)
}
}
return nil
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package jsoncmp_test
import (
"testing"

"github.com/hashicorp/terraform-provider-aws/internal/acctest/jsoncmp"
"github.com/hashicorp/terraform-provider-aws/acctest/jsoncmp"
)

func TestDiff(t *testing.T) {
Expand Down
File renamed without changes.
195 changes: 195 additions & 0 deletions acctest/partition_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package acctest_test

import (
"testing"

"github.com/hashicorp/terraform-provider-aws/acctest"
"github.com/hashicorp/terraform-provider-aws/names"
)

func TestIsIsolatedPartition(t *testing.T) {
t.Parallel()

testCases := []struct {
input string
expected bool
}{
{
input: names.StandardPartitionID,
expected: false,
},
{
input: names.ChinaPartitionID,
expected: false,
},
{
input: names.USGovCloudPartitionID,
expected: false,
},
{
input: names.ISOPartitionID,
expected: true,
},
{
input: names.ISOBPartitionID,
expected: true,
},
{
input: names.ISOEPartitionID,
expected: true,
},
{
input: names.ISOFPartitionID,
expected: true,
},
}

for _, testCase := range testCases {
t.Run(testCase.input, func(t *testing.T) {
t.Parallel()

if got, want := acctest.IsIsolatedPartition(testCase.input), testCase.expected; got != want {
t.Errorf("got: %#v, expected: %#v", got, want)
}
})
}
}

func TestIsIsolatedRegion(t *testing.T) {
t.Parallel()

testCases := []struct {
input string
expected bool
}{
{
input: names.USEast1RegionID,
expected: false,
},
{
input: names.CNNorth1RegionID,
expected: false,
},
{
input: names.USGovEast1RegionID,
expected: false,
},
{
input: names.USISOEast1RegionID,
expected: true,
},
{
input: names.USISOBEast1RegionID,
expected: true,
},
{
input: names.EUISOEWest1RegionID,
expected: true,
},
}

for _, testCase := range testCases {
t.Run(testCase.input, func(t *testing.T) {
t.Parallel()

if got, want := acctest.IsIsolatedRegion(testCase.input), testCase.expected; got != want {
t.Errorf("got: %#v, expected: %#v", got, want)
}
})
}
}

func TestIsStandardPartition(t *testing.T) {
t.Parallel()

testCases := []struct {
input string
expected bool
}{
{
input: names.StandardPartitionID,
expected: true,
},
{
input: names.ChinaPartitionID,
expected: false,
},
{
input: names.USGovCloudPartitionID,
expected: false,
},
{
input: names.ISOPartitionID,
expected: false,
},
{
input: names.ISOBPartitionID,
expected: false,
},
{
input: names.ISOEPartitionID,
expected: false,
},
{
input: names.ISOFPartitionID,
expected: false,
},
}

for _, testCase := range testCases {
t.Run(testCase.input, func(t *testing.T) {
t.Parallel()

if got, want := acctest.IsStandardPartition(testCase.input), testCase.expected; got != want {
t.Errorf("got: %#v, expected: %#v", got, want)
}
})
}
}

func TestIsStandardRegion(t *testing.T) {
t.Parallel()

testCases := []struct {
input string
expected bool
}{
{
input: names.USEast1RegionID,
expected: true,
},
{
input: names.CNNorth1RegionID,
expected: false,
},
{
input: names.USGovEast1RegionID,
expected: false,
},
{
input: names.USISOEast1RegionID,
expected: false,
},
{
input: names.USISOBEast1RegionID,
expected: false,
},
{
input: names.EUISOEWest1RegionID,
expected: false,
},
}

for _, testCase := range testCases {
t.Run(testCase.input, func(t *testing.T) {
t.Parallel()

if got, want := acctest.IsStandardRegion(testCase.input), testCase.expected; got != want {
t.Errorf("got: %#v, expected: %#v", got, want)
}
})
}
}
4 changes: 2 additions & 2 deletions internal/acctest/s3.go → acctest/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
tfs3 "github.com/hashicorp/terraform-provider-aws/internal/service/s3"
"github.com/hashicorp/terraform-provider-aws/conns"
tfs3 "github.com/hashicorp/terraform-provider-aws/service/s3"
)

func S3BucketHasTag(ctx context.Context, bucketName, key, value string) resource.TestCheckFunc {
Expand Down
File renamed without changes.
Loading

0 comments on commit 87d7985

Please sign in to comment.