Skip to content

Commit 674f414

Browse files
authored
all: remove duplicate imports (#3516)
1 parent 9e81e8d commit 674f414

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

aws/aws.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/aws/aws-sdk-go-v2/aws/ratelimit"
2626
"github.com/aws/aws-sdk-go-v2/aws/retry"
2727
"github.com/aws/aws-sdk-go-v2/config"
28-
awsv2cfg "github.com/aws/aws-sdk-go-v2/config"
2928
"github.com/aws/aws-sdk-go/aws"
3029
"github.com/aws/aws-sdk-go/aws/client"
3130
"github.com/aws/aws-sdk-go/aws/credentials"
@@ -180,7 +179,7 @@ func UseV2(q url.Values) bool {
180179

181180
// NewDefaultV2Config returns a aws.Config for AWS SDK v2, using the default options.
182181
func NewDefaultV2Config(ctx context.Context) (awsv2.Config, error) {
183-
return awsv2cfg.LoadDefaultConfig(ctx)
182+
return config.LoadDefaultConfig(ctx)
184183
}
185184

186185
// V2ConfigFromURLParams returns an aws.Config for AWS SDK v2 initialized based on the URL
@@ -208,7 +207,7 @@ func V2ConfigFromURLParams(ctx context.Context, q url.Values) (awsv2.Config, err
208207
var endpoint string
209208
var hostnameImmutable bool
210209
var rateLimitCapacity int64
211-
var opts []func(*awsv2cfg.LoadOptions) error
210+
var opts []func(*config.LoadOptions) error
212211
for param, values := range q {
213212
value := values[0]
214213
switch param {
@@ -219,26 +218,26 @@ func V2ConfigFromURLParams(ctx context.Context, q url.Values) (awsv2.Config, err
219218
return awsv2.Config{}, fmt.Errorf("invalid value for hostname_immutable: %w", err)
220219
}
221220
case "region":
222-
opts = append(opts, awsv2cfg.WithRegion(value))
221+
opts = append(opts, config.WithRegion(value))
223222
case "endpoint":
224223
endpoint = value
225224
case "profile":
226-
opts = append(opts, awsv2cfg.WithSharedConfigProfile(value))
225+
opts = append(opts, config.WithSharedConfigProfile(value))
227226
case "dualstack":
228227
dualStack, err := strconv.ParseBool(value)
229228
if err != nil {
230229
return awsv2.Config{}, fmt.Errorf("invalid value for dualstack: %w", err)
231230
}
232231
if dualStack {
233-
opts = append(opts, awsv2cfg.WithUseDualStackEndpoint(awsv2.DualStackEndpointStateEnabled))
232+
opts = append(opts, config.WithUseDualStackEndpoint(awsv2.DualStackEndpointStateEnabled))
234233
}
235234
case "fips":
236235
fips, err := strconv.ParseBool(value)
237236
if err != nil {
238237
return awsv2.Config{}, fmt.Errorf("invalid value for fips: %w", err)
239238
}
240239
if fips {
241-
opts = append(opts, awsv2cfg.WithUseFIPSEndpoint(awsv2.FIPSEndpointStateEnabled))
240+
opts = append(opts, config.WithUseFIPSEndpoint(awsv2.FIPSEndpointStateEnabled))
242241
}
243242
case "rate_limiter_capacity":
244243
var err error
@@ -252,7 +251,7 @@ func V2ConfigFromURLParams(ctx context.Context, q url.Values) (awsv2.Config, err
252251
return awsv2.Config{}, fmt.Errorf("invalid value for anonymous: %w", err)
253252
}
254253
if anon {
255-
opts = append(opts, awsv2cfg.WithCredentialsProvider(awsv2.AnonymousCredentials{}))
254+
opts = append(opts, config.WithCredentialsProvider(awsv2.AnonymousCredentials{}))
256255
}
257256
case "awssdk":
258257
// ignore, should be handled before this
@@ -270,7 +269,7 @@ func V2ConfigFromURLParams(ctx context.Context, q url.Values) (awsv2.Config, err
270269
HostnameImmutable: hostnameImmutable,
271270
}, nil
272271
})
273-
opts = append(opts, awsv2cfg.WithEndpointResolverWithOptions(customResolver))
272+
opts = append(opts, config.WithEndpointResolverWithOptions(customResolver))
274273
}
275274

276275
var rateLimiter retry.RateLimiter
@@ -284,5 +283,5 @@ func V2ConfigFromURLParams(ctx context.Context, q url.Values) (awsv2.Config, err
284283
})
285284
}))
286285

287-
return awsv2cfg.LoadDefaultConfig(ctx, opts...)
286+
return config.LoadDefaultConfig(ctx, opts...)
288287
}

docstore/awsdynamodb/query_test.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/aws/aws-sdk-go/aws"
2626
"github.com/aws/aws-sdk-go/service/dynamodb"
27-
dyn "github.com/aws/aws-sdk-go/service/dynamodb"
2827
"github.com/google/go-cmp/cmp"
2928
"github.com/google/go-cmp/cmp/cmpopts"
3029
"gocloud.dev/docstore/driver"
@@ -583,12 +582,12 @@ func TestCopyTopLevel(t *testing.T) {
583582
func Test_documentIterator_Next(t *testing.T) {
584583
type fields struct {
585584
qr *queryRunner
586-
items []map[string]*dyn.AttributeValue
585+
items []map[string]*dynamodb.AttributeValue
587586
curr int
588587
offset int
589588
limit int
590589
count int
591-
last map[string]*dyn.AttributeValue
590+
last map[string]*dynamodb.AttributeValue
592591
asFunc func(i interface{}) bool
593592
}
594593
type args struct {
@@ -605,14 +604,14 @@ func Test_documentIterator_Next(t *testing.T) {
605604
name: "nextWithNoDecodeError",
606605
fields: fields{
607606
qr: &queryRunner{},
608-
items: []map[string]*dyn.AttributeValue{
609-
{"key": {M: map[string]*dyn.AttributeValue{"key": {S: aws.String("value")}}}},
607+
items: []map[string]*dynamodb.AttributeValue{
608+
{"key": {M: map[string]*dynamodb.AttributeValue{"key": {S: aws.String("value")}}}},
610609
},
611610
curr: 0,
612611
offset: 0,
613612
limit: 0,
614613
count: 0,
615-
last: map[string]*dyn.AttributeValue{},
614+
last: map[string]*dynamodb.AttributeValue{},
616615
},
617616
args: args{
618617
ctx: context.Background(),
@@ -624,14 +623,14 @@ func Test_documentIterator_Next(t *testing.T) {
624623
name: "nextWithDecodeError",
625624
fields: fields{
626625
qr: &queryRunner{},
627-
items: []map[string]*dyn.AttributeValue{
626+
items: []map[string]*dynamodb.AttributeValue{
628627
{"key": {M: nil}}, // set M to nil to trigger decode error
629628
},
630629
curr: 0,
631630
offset: 0,
632631
limit: 0,
633632
count: 0,
634-
last: map[string]*dyn.AttributeValue{},
633+
last: map[string]*dynamodb.AttributeValue{},
635634
},
636635
args: args{
637636
ctx: context.Background(),
@@ -643,16 +642,16 @@ func Test_documentIterator_Next(t *testing.T) {
643642
name: "nextWhereCurrIsGreaterThanOrEqualToItemsAndLastIsNotNil",
644643
fields: fields{
645644
qr: &queryRunner{
646-
scanIn: &dyn.ScanInput{},
645+
scanIn: &dynamodb.ScanInput{},
647646
// hack to return error from run
648647
beforeRun: func(asFunc func(i interface{}) bool) error { return errors.New("invalid") },
649648
},
650-
items: []map[string]*dyn.AttributeValue{{"key": {M: map[string]*dyn.AttributeValue{"key": {S: aws.String("value"), M: nil}}}}},
649+
items: []map[string]*dynamodb.AttributeValue{{"key": {M: map[string]*dynamodb.AttributeValue{"key": {S: aws.String("value"), M: nil}}}}},
651650
curr: 1,
652651
offset: 0,
653652
limit: 0,
654653
count: 0,
655-
last: map[string]*dyn.AttributeValue{"key": {S: aws.String("value")}},
654+
last: map[string]*dynamodb.AttributeValue{"key": {S: aws.String("value")}},
656655
},
657656
args: args{
658657
ctx: context.Background(),

0 commit comments

Comments
 (0)