diff --git a/internal/generate/serviceendpointtests/file.tmpl b/internal/generate/serviceendpointtests/file.tmpl index ab0b5823ab9..f10ccd84f79 100644 --- a/internal/generate/serviceendpointtests/file.tmpl +++ b/internal/generate/serviceendpointtests/file.tmpl @@ -38,6 +38,9 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + {{- if gt (len .Aliases) 0 }} + "github.com/hashicorp/go-cty/cty" + {{- end }} "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -129,7 +132,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName{{ $i }}EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, {{ end }} @@ -205,7 +208,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName{{ $i }}EndpointInConfig, withAliasName{{ $j }}EndpointInConfig, }, - expected: expectAliasName{{ $i }}ConfigEndpoint(), + expected: conflictsWith(expectAliasName{{ $i }}ConfigEndpoint()), }, {{ end }} @@ -592,6 +595,19 @@ func withAliasName{{ $i }}EndpointInConfig(setup *caseSetup) { } {{ end }} +{{ if gt (len .Aliases) 0 }} +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + {{ range $i, $alias := .Aliases -}} + aliasName{{ $i }}, + {{ end }} + )) + return e +} +{{ end }} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 6c8f39dedce..ee399ccb860 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -8,12 +8,14 @@ import ( "errors" "fmt" "os" + "strings" "time" "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" awsbase "github.com/hashicorp/aws-sdk-go-base/v2" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -865,18 +867,50 @@ func expandIgnoreTags(ctx context.Context, tfMap map[string]interface{}) *tftags func expandEndpoints(_ context.Context, tfList []interface{}) (map[string]string, diag.Diagnostics) { var diags diag.Diagnostics + endpointsPath := cty.GetAttrPath("endpoints") + + if l := len(tfList); l > 1 { + diags = append(diags, errs.NewAttributeWarningDiagnostic( + endpointsPath, + "Invalid Attribute Value", + fmt.Sprintf("Attribute %q should have at most 1 element, got %d."+ + "\n\nThis will be an error in a future release.", + errs.PathString(endpointsPath), l), + )) + } + endpoints := make(map[string]string) - for _, tfMapRaw := range tfList { + for i, tfMapRaw := range tfList { tfMap, ok := tfMapRaw.(map[string]interface{}) if !ok { continue } + elementPath := endpointsPath.IndexInt(i) + for _, endpoint := range names.Endpoints() { pkg := endpoint.ProviderPackage + if len(endpoint.Aliases) > 0 { + count := 0 + attrs := []string{pkg} + if tfMap[pkg] != "" { + count++ + } + for _, alias := range endpoint.Aliases { + attrs = append(attrs, alias) + if tfMap[alias] != "" { + count++ + } + } + + if count > 1 { + diags = append(diags, ConflictingEndpointsWarningDiag(elementPath, attrs...)) + } + } + if endpoints[pkg] == "" { if v := tfMap[pkg].(string); v != "" { endpoints[pkg] = v @@ -941,3 +975,18 @@ func DeprecatedEnvVarDiag(envvar, replacement string) diag.Diagnostic { fmt.Sprintf(`The environment variable "%s" is deprecated. Use environment variable "%s" instead.`, envvar, replacement), ) } + +func ConflictingEndpointsWarningDiag(elementPath cty.Path, attrs ...string) diag.Diagnostic { + attrPaths := make([]string, len(attrs)) + for i, attr := range attrs { + path := elementPath.GetAttr(attr) + attrPaths[i] = `"` + errs.PathString(path) + `"` + } + return errs.NewAttributeWarningDiagnostic( + elementPath, + "Invalid Attribute Combination", + fmt.Sprintf("Only one of the following attributes should be set: %s"+ + "\n\nThis will be an error in a future release.", + strings.Join(attrPaths, ", ")), + ) +} diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index cd39a1d3d9a..3b279ba06f6 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/names" @@ -64,6 +65,7 @@ func TestEndpointMultipleKeys(t *testing.T) { //nolint:paralleltest endpoints map[string]string expectedService string expectedEndpoint string + expectedDiags diag.Diagnostics }{ { endpoints: map[string]string{ @@ -86,6 +88,11 @@ func TestEndpointMultipleKeys(t *testing.T) { //nolint:paralleltest }, expectedService: names.Transcribe, expectedEndpoint: "https://transcribe.fake.test", + expectedDiags: diag.Diagnostics{ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + "transcribe", + "transcribeservice", + )}, }, } @@ -101,10 +108,8 @@ func TestEndpointMultipleKeys(t *testing.T) { //nolint:paralleltest endpoints[k] = v } - var expectedDiags diag.Diagnostics - results, diags := expandEndpoints(ctx, []interface{}{endpoints}) - if diff := cmp.Diff(diags, expectedDiags, cmp.Comparer(sdkdiag.Comparer)); diff != "" { + if diff := cmp.Diff(diags, testcase.expectedDiags, cmp.Comparer(sdkdiag.Comparer)); diff != "" { t.Errorf("unexpected diagnostics difference: %s", diff) } diff --git a/internal/service/amp/service_endpoints_gen_test.go b/internal/service/amp/service_endpoints_gen_test.go index d4f73b6e29c..f90a42643b1 100644 --- a/internal/service/amp/service_endpoints_gen_test.go +++ b/internal/service/amp/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -104,7 +105,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -153,7 +154,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -398,6 +399,16 @@ func withAliasName1EndpointInConfig(setup *caseSetup) { endpoints[aliasName1] = aliasName1ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/appautoscaling/service_endpoints_gen_test.go b/internal/service/appautoscaling/service_endpoints_gen_test.go index 86afd209161..1443fc2c249 100644 --- a/internal/service/appautoscaling/service_endpoints_gen_test.go +++ b/internal/service/appautoscaling/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/appintegrations/service_endpoints_gen_test.go b/internal/service/appintegrations/service_endpoints_gen_test.go index fce8e4f48ee..7300197c2f7 100644 --- a/internal/service/appintegrations/service_endpoints_gen_test.go +++ b/internal/service/appintegrations/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/ce/service_endpoints_gen_test.go b/internal/service/ce/service_endpoints_gen_test.go index 433fae70550..a41c959506f 100644 --- a/internal/service/ce/service_endpoints_gen_test.go +++ b/internal/service/ce/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/cloudcontrol/service_endpoints_gen_test.go b/internal/service/cloudcontrol/service_endpoints_gen_test.go index fcf267e9159..8a6b3972ecf 100644 --- a/internal/service/cloudcontrol/service_endpoints_gen_test.go +++ b/internal/service/cloudcontrol/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/cloudhsmv2/service_endpoints_gen_test.go b/internal/service/cloudhsmv2/service_endpoints_gen_test.go index a5057648ae3..501c1480170 100644 --- a/internal/service/cloudhsmv2/service_endpoints_gen_test.go +++ b/internal/service/cloudhsmv2/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/cognitoidp/service_endpoints_gen_test.go b/internal/service/cognitoidp/service_endpoints_gen_test.go index b2c9756daf2..e5c8706b3bd 100644 --- a/internal/service/cognitoidp/service_endpoints_gen_test.go +++ b/internal/service/cognitoidp/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/configservice/service_endpoints_gen_test.go b/internal/service/configservice/service_endpoints_gen_test.go index be10a3c2bb4..cc6259c353c 100644 --- a/internal/service/configservice/service_endpoints_gen_test.go +++ b/internal/service/configservice/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/cur/service_endpoints_gen_test.go b/internal/service/cur/service_endpoints_gen_test.go index d067a9c26a4..4f0f425ebf9 100644 --- a/internal/service/cur/service_endpoints_gen_test.go +++ b/internal/service/cur/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/deploy/service_endpoints_gen_test.go b/internal/service/deploy/service_endpoints_gen_test.go index 23a67f0de19..66bc5169420 100644 --- a/internal/service/deploy/service_endpoints_gen_test.go +++ b/internal/service/deploy/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/dms/service_endpoints_gen_test.go b/internal/service/dms/service_endpoints_gen_test.go index 4d16212d5c8..f739a1f8155 100644 --- a/internal/service/dms/service_endpoints_gen_test.go +++ b/internal/service/dms/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -104,7 +105,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -153,7 +154,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -388,6 +389,16 @@ func withAliasName1EndpointInConfig(setup *caseSetup) { endpoints[aliasName1] = aliasName1ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/ds/service_endpoints_gen_test.go b/internal/service/ds/service_endpoints_gen_test.go index 072de5eb7c1..3efc0fd5bae 100644 --- a/internal/service/ds/service_endpoints_gen_test.go +++ b/internal/service/ds/service_endpoints_gen_test.go @@ -19,6 +19,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -95,7 +96,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -356,6 +357,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/elasticbeanstalk/service_endpoints_gen_test.go b/internal/service/elasticbeanstalk/service_endpoints_gen_test.go index e1362d4a2a9..fa174162af4 100644 --- a/internal/service/elasticbeanstalk/service_endpoints_gen_test.go +++ b/internal/service/elasticbeanstalk/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/elasticsearch/service_endpoints_gen_test.go b/internal/service/elasticsearch/service_endpoints_gen_test.go index a056b2b3654..2b2bbc23d99 100644 --- a/internal/service/elasticsearch/service_endpoints_gen_test.go +++ b/internal/service/elasticsearch/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -104,7 +105,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -153,7 +154,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -388,6 +389,16 @@ func withAliasName1EndpointInConfig(setup *caseSetup) { endpoints[aliasName1] = aliasName1ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/elb/service_endpoints_gen_test.go b/internal/service/elb/service_endpoints_gen_test.go index 503f847ef3f..0b097f80895 100644 --- a/internal/service/elb/service_endpoints_gen_test.go +++ b/internal/service/elb/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/elbv2/service_endpoints_gen_test.go b/internal/service/elbv2/service_endpoints_gen_test.go index 0ed668e8a4c..bf3b294dd1b 100644 --- a/internal/service/elbv2/service_endpoints_gen_test.go +++ b/internal/service/elbv2/service_endpoints_gen_test.go @@ -19,6 +19,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -95,7 +96,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -356,6 +357,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/events/service_endpoints_gen_test.go b/internal/service/events/service_endpoints_gen_test.go index 05e07af7586..ff3c08e04f0 100644 --- a/internal/service/events/service_endpoints_gen_test.go +++ b/internal/service/events/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -104,7 +105,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -153,7 +154,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -388,6 +389,16 @@ func withAliasName1EndpointInConfig(setup *caseSetup) { endpoints[aliasName1] = aliasName1ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/evidently/service_endpoints_gen_test.go b/internal/service/evidently/service_endpoints_gen_test.go index bd01fcbab84..ea83fc1063e 100644 --- a/internal/service/evidently/service_endpoints_gen_test.go +++ b/internal/service/evidently/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/grafana/service_endpoints_gen_test.go b/internal/service/grafana/service_endpoints_gen_test.go index 60c4a41b6ea..b7f2038d8c3 100644 --- a/internal/service/grafana/service_endpoints_gen_test.go +++ b/internal/service/grafana/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -104,7 +105,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -153,7 +154,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -388,6 +389,16 @@ func withAliasName1EndpointInConfig(setup *caseSetup) { endpoints[aliasName1] = aliasName1ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/inspector2/service_endpoints_gen_test.go b/internal/service/inspector2/service_endpoints_gen_test.go index f20ed492eb0..5a6166f7163 100644 --- a/internal/service/inspector2/service_endpoints_gen_test.go +++ b/internal/service/inspector2/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/kafka/service_endpoints_gen_test.go b/internal/service/kafka/service_endpoints_gen_test.go index 5ffe034ad41..42beb5403a9 100644 --- a/internal/service/kafka/service_endpoints_gen_test.go +++ b/internal/service/kafka/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/lexmodels/service_endpoints_gen_test.go b/internal/service/lexmodels/service_endpoints_gen_test.go index dff0aa2d0cf..0b3874a6752 100644 --- a/internal/service/lexmodels/service_endpoints_gen_test.go +++ b/internal/service/lexmodels/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -98,7 +99,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -106,7 +107,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 2 config": { @@ -114,7 +115,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName2EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -163,7 +164,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides alias name 2 config": { @@ -171,7 +172,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName2EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -220,7 +221,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName1EndpointInConfig, withAliasName2EndpointInConfig, }, - expected: expectAliasName1ConfigEndpoint(), + expected: conflictsWith(expectAliasName1ConfigEndpoint()), }, "alias name 1 endpoint config overrides aws service envvar": { @@ -465,6 +466,17 @@ func withAliasName2EndpointInConfig(setup *caseSetup) { endpoints[aliasName2] = aliasName2ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + aliasName2, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/lexv2models/service_endpoints_gen_test.go b/internal/service/lexv2models/service_endpoints_gen_test.go index 6c64017921b..2f48c1aa82f 100644 --- a/internal/service/lexv2models/service_endpoints_gen_test.go +++ b/internal/service/lexv2models/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/location/service_endpoints_gen_test.go b/internal/service/location/service_endpoints_gen_test.go index ea2b3d2f63e..e6f3945b584 100644 --- a/internal/service/location/service_endpoints_gen_test.go +++ b/internal/service/location/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/logs/service_endpoints_gen_test.go b/internal/service/logs/service_endpoints_gen_test.go index b292d3650cc..a44d09f23aa 100644 --- a/internal/service/logs/service_endpoints_gen_test.go +++ b/internal/service/logs/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -104,7 +105,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -153,7 +154,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -398,6 +399,16 @@ func withAliasName1EndpointInConfig(setup *caseSetup) { endpoints[aliasName1] = aliasName1ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/oam/service_endpoints_gen_test.go b/internal/service/oam/service_endpoints_gen_test.go index 30871e193d6..e0f2937fd7e 100644 --- a/internal/service/oam/service_endpoints_gen_test.go +++ b/internal/service/oam/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/opensearch/service_endpoints_gen_test.go b/internal/service/opensearch/service_endpoints_gen_test.go index 7b02c20b97f..42acbb1c23c 100644 --- a/internal/service/opensearch/service_endpoints_gen_test.go +++ b/internal/service/opensearch/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/osis/service_endpoints_gen_test.go b/internal/service/osis/service_endpoints_gen_test.go index 2ead9d805d0..bd64fefeff3 100644 --- a/internal/service/osis/service_endpoints_gen_test.go +++ b/internal/service/osis/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/rbin/service_endpoints_gen_test.go b/internal/service/rbin/service_endpoints_gen_test.go index 138bc6e2595..a088c44598a 100644 --- a/internal/service/rbin/service_endpoints_gen_test.go +++ b/internal/service/rbin/service_endpoints_gen_test.go @@ -19,6 +19,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -95,7 +96,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -332,6 +333,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/redshiftdata/service_endpoints_gen_test.go b/internal/service/redshiftdata/service_endpoints_gen_test.go index 22eefab8f27..5ebaf492d91 100644 --- a/internal/service/redshiftdata/service_endpoints_gen_test.go +++ b/internal/service/redshiftdata/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -331,6 +332,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/resourcegroupstaggingapi/service_endpoints_gen_test.go b/internal/service/resourcegroupstaggingapi/service_endpoints_gen_test.go index f6bec1f4e95..f41ab6ef241 100644 --- a/internal/service/resourcegroupstaggingapi/service_endpoints_gen_test.go +++ b/internal/service/resourcegroupstaggingapi/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/rum/service_endpoints_gen_test.go b/internal/service/rum/service_endpoints_gen_test.go index d6826d33b3f..7f31be1de94 100644 --- a/internal/service/rum/service_endpoints_gen_test.go +++ b/internal/service/rum/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/s3/service_endpoints_gen_test.go b/internal/service/s3/service_endpoints_gen_test.go index 7b2f144e359..46b97af4805 100644 --- a/internal/service/s3/service_endpoints_gen_test.go +++ b/internal/service/s3/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -453,6 +454,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/serverlessrepo/service_endpoints_gen_test.go b/internal/service/serverlessrepo/service_endpoints_gen_test.go index fc560f384e9..f65a160dfd5 100644 --- a/internal/service/serverlessrepo/service_endpoints_gen_test.go +++ b/internal/service/serverlessrepo/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -96,7 +97,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides alias name 1 config": { @@ -104,7 +105,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -153,7 +154,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withAliasName0EndpointInConfig, withAliasName1EndpointInConfig, }, - expected: expectAliasName0ConfigEndpoint(), + expected: conflictsWith(expectAliasName0ConfigEndpoint()), }, "alias name 0 endpoint config overrides aws service envvar": { @@ -388,6 +389,16 @@ func withAliasName1EndpointInConfig(setup *caseSetup) { endpoints[aliasName1] = aliasName1ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + aliasName1, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/servicecatalogappregistry/service_endpoints_gen_test.go b/internal/service/servicecatalogappregistry/service_endpoints_gen_test.go index 61db3f7fad0..8a415e84acc 100644 --- a/internal/service/servicecatalogappregistry/service_endpoints_gen_test.go +++ b/internal/service/servicecatalogappregistry/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/sfn/service_endpoints_gen_test.go b/internal/service/sfn/service_endpoints_gen_test.go index 2efaf2fb681..2b3aee2c8bc 100644 --- a/internal/service/sfn/service_endpoints_gen_test.go +++ b/internal/service/sfn/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/simpledb/service_endpoints_gen_test.go b/internal/service/simpledb/service_endpoints_gen_test.go index db4ad4da404..af83226b7e7 100644 --- a/internal/service/simpledb/service_endpoints_gen_test.go +++ b/internal/service/simpledb/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -319,6 +320,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint } diff --git a/internal/service/transcribe/service_endpoints_gen_test.go b/internal/service/transcribe/service_endpoints_gen_test.go index 5ebe78a6663..424dc5543db 100644 --- a/internal/service/transcribe/service_endpoints_gen_test.go +++ b/internal/service/transcribe/service_endpoints_gen_test.go @@ -18,6 +18,7 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" + "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -94,7 +95,7 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S withPackageNameEndpointInConfig, withAliasName0EndpointInConfig, }, - expected: expectPackageNameConfigEndpoint(), + expected: conflictsWith(expectPackageNameConfigEndpoint()), }, "package name endpoint config overrides aws service envvar": { @@ -329,6 +330,15 @@ func withAliasName0EndpointInConfig(setup *caseSetup) { endpoints[aliasName0] = aliasName0ConfigEndpoint } +func conflictsWith(e caseExpectations) caseExpectations { + e.diags = append(e.diags, provider.ConflictingEndpointsWarningDiag( + cty.GetAttrPath("endpoints").IndexInt(0), + packageName, + aliasName0, + )) + return e +} + func withAwsEnvVar(setup *caseSetup) { setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint }