Skip to content

Commit 5b04f35

Browse files
authored
Merge pull request hashicorp#45127 from hashicorp/td-enforce-inttypes-alias
linting: enforce `inttypes` alias for `github.com/hashicorp/terraform-provider-aws/internal/types`
2 parents 281ae5d + 92597e5 commit 5b04f35

File tree

107 files changed

+261
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+261
-255
lines changed

.ci/.golangci3.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ linters:
55
- goconst
66
- gocritic
77
- govet
8+
- importas
89
- ineffassign
910
- makezero
1011
- misspell
@@ -25,6 +26,11 @@ linters:
2526
- opinionated
2627
- performance
2728
- style
29+
importas:
30+
no-unaliased: true
31+
alias:
32+
- pkg: github.com/hashicorp/terraform-provider-aws/internal/types
33+
alias: inttypes
2834
mnd:
2935
checks:
3036
- argument

internal/acctest/statecheck/full_tags.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/hashicorp/terraform-provider-aws/internal/conns"
1515
tfmaps "github.com/hashicorp/terraform-provider-aws/internal/maps"
1616
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
17-
"github.com/hashicorp/terraform-provider-aws/internal/types"
17+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
1818
tfunique "github.com/hashicorp/terraform-provider-aws/internal/unique"
1919
)
2020

@@ -117,7 +117,7 @@ func ExpectFullResourceTags(servicePackage conns.ServicePackage, resourceAddress
117117
}
118118
}
119119

120-
func ExpectFullResourceTagsSpecTags(servicePackage conns.ServicePackage, resourceAddress string, tagsSpec unique.Handle[types.ServicePackageResourceTags], knownValue knownvalue.Check) expectFullTagsCheck {
120+
func ExpectFullResourceTagsSpecTags(servicePackage conns.ServicePackage, resourceAddress string, tagsSpec unique.Handle[inttypes.ServicePackageResourceTags], knownValue knownvalue.Check) expectFullTagsCheck {
121121
return expectFullTagsCheck{
122122
base: NewBase(resourceAddress),
123123
knownValue: knownValue,
@@ -137,7 +137,7 @@ func ExpectFullDataSourceTags(servicePackage conns.ServicePackage, resourceAddre
137137
}
138138
}
139139

140-
func ExpectFullDataSourceTagsSpecTags(servicePackage conns.ServicePackage, resourceAddress string, tagsSpec unique.Handle[types.ServicePackageResourceTags], knownValue knownvalue.Check) expectFullTagsCheck {
140+
func ExpectFullDataSourceTagsSpecTags(servicePackage conns.ServicePackage, resourceAddress string, tagsSpec unique.Handle[inttypes.ServicePackageResourceTags], knownValue knownvalue.Check) expectFullTagsCheck {
141141
return expectFullTagsCheck{
142142
base: NewBase(resourceAddress),
143143
knownValue: knownValue,
@@ -147,9 +147,9 @@ func ExpectFullDataSourceTagsSpecTags(servicePackage conns.ServicePackage, resou
147147
}
148148
}
149149

150-
type tagSpecFinder func(context.Context, conns.ServicePackage, string) unique.Handle[types.ServicePackageResourceTags]
150+
type tagSpecFinder func(context.Context, conns.ServicePackage, string) unique.Handle[inttypes.ServicePackageResourceTags]
151151

152-
func findResourceTagSpec(ctx context.Context, sp conns.ServicePackage, typeName string) (tagsSpec unique.Handle[types.ServicePackageResourceTags]) {
152+
func findResourceTagSpec(ctx context.Context, sp conns.ServicePackage, typeName string) (tagsSpec unique.Handle[inttypes.ServicePackageResourceTags]) {
153153
for _, r := range sp.FrameworkResources(ctx) {
154154
if r.TypeName == typeName {
155155
tagsSpec = r.Tags
@@ -167,7 +167,7 @@ func findResourceTagSpec(ctx context.Context, sp conns.ServicePackage, typeName
167167
return tagsSpec
168168
}
169169

170-
func findDataSourceTagSpec(ctx context.Context, sp conns.ServicePackage, typeName string) (tagsSpec unique.Handle[types.ServicePackageResourceTags]) {
170+
func findDataSourceTagSpec(ctx context.Context, sp conns.ServicePackage, typeName string) (tagsSpec unique.Handle[inttypes.ServicePackageResourceTags]) {
171171
for _, r := range sp.FrameworkDataSources(ctx) {
172172
if r.TypeName == typeName {
173173
tagsSpec = r.Tags
@@ -185,8 +185,8 @@ func findDataSourceTagSpec(ctx context.Context, sp conns.ServicePackage, typeNam
185185
return tagsSpec
186186
}
187187

188-
func identityTagSpec(tagsSpec unique.Handle[types.ServicePackageResourceTags]) tagSpecFinder {
189-
return func(ctx context.Context, sp conns.ServicePackage, typeName string) unique.Handle[types.ServicePackageResourceTags] {
188+
func identityTagSpec(tagsSpec unique.Handle[inttypes.ServicePackageResourceTags]) tagSpecFinder {
189+
return func(ctx context.Context, sp conns.ServicePackage, typeName string) unique.Handle[inttypes.ServicePackageResourceTags] {
190190
return tagsSpec
191191
}
192192
}

internal/conns/conns.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ import (
77
"context"
88
"iter"
99

10-
"github.com/hashicorp/terraform-provider-aws/internal/types"
10+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
1111
"github.com/hashicorp/terraform-provider-aws/internal/vcr"
1212
)
1313

1414
// ServicePackage is the minimal interface exported from each AWS service package.
1515
// Its methods return the Plugin SDK and Framework resources and data sources implemented in the package.
1616
type ServicePackage interface {
17-
FrameworkDataSources(context.Context) []*types.ServicePackageFrameworkDataSource
18-
FrameworkResources(context.Context) []*types.ServicePackageFrameworkResource
19-
SDKDataSources(context.Context) []*types.ServicePackageSDKDataSource
20-
SDKResources(context.Context) []*types.ServicePackageSDKResource
17+
FrameworkDataSources(context.Context) []*inttypes.ServicePackageFrameworkDataSource
18+
FrameworkResources(context.Context) []*inttypes.ServicePackageFrameworkResource
19+
SDKDataSources(context.Context) []*inttypes.ServicePackageSDKDataSource
20+
SDKResources(context.Context) []*inttypes.ServicePackageSDKResource
2121
ServicePackageName() string
2222
}
2323

2424
// ServicePackageWithActions is an interface that extends ServicePackage with actions.
2525
// Actions are imperative operations that can be invoked to perform Day-2 operations.
2626
type ServicePackageWithActions interface {
2727
ServicePackage
28-
Actions(context.Context) []*types.ServicePackageAction
28+
Actions(context.Context) []*inttypes.ServicePackageAction
2929
}
3030

3131
// ServicePackageWithEphemeralResources is an interface that extends ServicePackage with ephemeral resources.
3232
// Ephemeral resources are resources that are not part of the Terraform state, but are used to create other resources.
3333
type ServicePackageWithEphemeralResources interface {
3434
ServicePackage
35-
EphemeralResources(context.Context) []*types.ServicePackageEphemeralResource
35+
EphemeralResources(context.Context) []*inttypes.ServicePackageEphemeralResource
3636
}
3737

3838
type ServicePackageWithFrameworkListResources interface {
3939
ServicePackage
40-
FrameworkListResources(context.Context) iter.Seq[*types.ServicePackageFrameworkListResource]
40+
FrameworkListResources(context.Context) iter.Seq[*inttypes.ServicePackageFrameworkListResource]
4141
}
4242

4343
type ServicePackageWithSDKListResources interface {
4444
ServicePackage
45-
SDKListResources(ctx context.Context) iter.Seq[*types.ServicePackageSDKListResource]
45+
SDKListResources(ctx context.Context) iter.Seq[*inttypes.ServicePackageSDKListResource]
4646
}
4747

4848
type (

internal/flex/flex.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
tfmaps "github.com/hashicorp/terraform-provider-aws/internal/maps"
1717
"github.com/hashicorp/terraform-provider-aws/internal/sdkv2"
1818
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
19-
itypes "github.com/hashicorp/terraform-provider-aws/internal/types"
19+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
2020
"github.com/shopspring/decimal"
2121
)
2222

@@ -389,7 +389,7 @@ func StringToInt32Value(v *string) int32 {
389389

390390
// StringValueToBase64String converts a string to a Go base64 string pointer.
391391
func StringValueToBase64String(v string) *string {
392-
return aws.String(itypes.Base64EncodeOnce([]byte(v)))
392+
return aws.String(inttypes.Base64EncodeOnce([]byte(v)))
393393
}
394394

395395
// StringValueToInt64 converts a string to a Go int32 pointer.

internal/framework/flex/set_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import (
1111
"github.com/hashicorp/terraform-plugin-framework/attr"
1212
"github.com/hashicorp/terraform-plugin-framework/types"
1313
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
14-
itypes "github.com/hashicorp/terraform-provider-aws/internal/types"
14+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
1515
)
1616

1717
func TestExpandFrameworkStringValueSet(t *testing.T) {
1818
t.Parallel()
1919

2020
type testCase struct {
2121
input types.Set
22-
expected itypes.Set[string]
22+
expected inttypes.Set[string]
2323
}
2424
tests := map[string]testCase{
2525
"null": {

internal/framework/types/cidr_block.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/hashicorp/terraform-plugin-framework/types"
1414
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1515
"github.com/hashicorp/terraform-plugin-go/tftypes"
16-
itypes "github.com/hashicorp/terraform-provider-aws/internal/types"
16+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
1717
)
1818

1919
var (
@@ -53,7 +53,7 @@ func (t cidrBlockType) ValueFromString(_ context.Context, in types.String) (base
5353
}
5454

5555
valueString := in.ValueString()
56-
if err := itypes.ValidateCIDRBlock(valueString); err != nil {
56+
if err := inttypes.ValidateCIDRBlock(valueString); err != nil {
5757
return CIDRBlockUnknown(), diags // Must not return validation errors
5858
}
5959

@@ -126,7 +126,7 @@ func (v CIDRBlock) ValidateAttribute(ctx context.Context, req xattr.ValidateAttr
126126
return
127127
}
128128

129-
if err := itypes.ValidateCIDRBlock(v.ValueString()); err != nil {
129+
if err := inttypes.ValidateCIDRBlock(v.ValueString()); err != nil {
130130
resp.Diagnostics.AddAttributeError(
131131
req.Path,
132132
"Invalid CIDR Block Value",

internal/framework/validators/aws_account_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag"
1010
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
11-
itypes "github.com/hashicorp/terraform-provider-aws/internal/types"
11+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
1212
)
1313

1414
// awsAccountIDValidator validates that a string Attribute's value is a valid AWS account ID.
@@ -31,7 +31,7 @@ func (validator awsAccountIDValidator) ValidateString(ctx context.Context, reque
3131
}
3232

3333
// https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-identifiers.html.
34-
if !itypes.IsAWSAccountID(request.ConfigValue.ValueString()) {
34+
if !inttypes.IsAWSAccountID(request.ConfigValue.ValueString()) {
3535
response.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic(
3636
request.Path,
3737
validator.Description(ctx),

internal/generate/tagstests/data_source_test.go.gtpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import (
4343
{{- if .OverrideIdentifier }}
4444
tfstatecheck "github.com/hashicorp/terraform-provider-aws/internal/acctest/statecheck"
4545
tf{{ .ProviderPackage }} "github.com/hashicorp/terraform-provider-aws/internal/service/{{ .ProviderPackage }}"
46-
"github.com/hashicorp/terraform-provider-aws/internal/types"
46+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
4747
{{- end }}
4848
{{ range .GoImports -}}
4949
{{ if .Alias }}{{ .Alias }} {{ end }}"{{ .Path }}"
@@ -263,7 +263,7 @@ func {{ template "testname" . }}_tags_IgnoreTags_Overlap_ResourceTag(t *testing.
263263

264264
{{ if .OverrideIdentifier }}
265265
func {{ template "expectFullDataSourceTags" . }}(ctx context.Context, resourceAddress string, knownValue knownvalue.Check) statecheck.StateCheck {
266-
return tfstatecheck.ExpectFullDataSourceTagsSpecTags(tf{{ .ProviderPackage }}.ServicePackage(ctx), resourceAddress, unique.Make(types.ServicePackageResourceTags{
266+
return tfstatecheck.ExpectFullDataSourceTagsSpecTags(tf{{ .ProviderPackage }}.ServicePackage(ctx), resourceAddress, unique.Make(inttypes.ServicePackageResourceTags{
267267
IdentifierAttribute: {{ .OverrideIdentifierAttribute }},
268268
{{ if ne .OverrideResourceType "" -}}
269269
ResourceType: "{{ .OverrideResourceType }}",

internal/generate/tagstests/resource_test.go.gtpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ import (
103103
{{- if .OverrideIdentifier }}
104104
tfstatecheck "github.com/hashicorp/terraform-provider-aws/internal/acctest/statecheck"
105105
tf{{ .ProviderPackage }} "github.com/hashicorp/terraform-provider-aws/internal/service/{{ .ProviderPackage }}"
106-
"github.com/hashicorp/terraform-provider-aws/internal/types"
106+
inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
107107
{{- end }}
108108
{{ range .GoImports -}}
109109
{{ if .Alias }}{{ .Alias }} {{ end }}"{{ .Path }}"
@@ -3037,7 +3037,7 @@ func testAcc{{ .ResourceProviderNameUpper }}{{ .Name }}_removingTagNotSupported(
30373037

30383038
{{ if .OverrideIdentifier }}
30393039
func {{ template "expectFullResourceTags" . }}(ctx context.Context, resourceAddress string, knownValue knownvalue.Check) statecheck.StateCheck {
3040-
return tfstatecheck.ExpectFullResourceTagsSpecTags(tf{{ .ProviderPackage }}.ServicePackage(ctx), resourceAddress, unique.Make(types.ServicePackageResourceTags{
3040+
return tfstatecheck.ExpectFullResourceTagsSpecTags(tf{{ .ProviderPackage }}.ServicePackage(ctx), resourceAddress, unique.Make(inttypes.ServicePackageResourceTags{
30413041
IdentifierAttribute: {{ .OverrideIdentifierAttribute }},
30423042
{{ if ne .OverrideResourceType "" -}}
30433043
ResourceType: "{{ .OverrideResourceType }}",

internal/service/amp/workspace_data_source_tags_gen_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)