Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(dynamodb): remove deprecated function #2888

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions pkg/storage/cache/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,27 @@
return nil, zerr.ErrTypeAssertionFailed
}

// custom endpoint resolver to point to localhost
customResolver := aws.EndpointResolverWithOptionsFunc( //nolint: staticcheck
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{ //nolint: staticcheck
PartitionID: "aws",
URL: properParameters.Endpoint,
SigningRegion: region,
}, nil
})

// Using the SDK's default configuration, loading additional config
// and credentials values from the environment variables, shared
// credentials, and shared configuration files
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(properParameters.Region),
config.WithEndpointResolverWithOptions(customResolver)) //nolint: staticcheck
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(properParameters.Region))
if err != nil {
log.Error().Err(err).Msg("failed to load AWS SDK config for dynamodb")

return nil, err
}

driver := &DynamoDBDriver{client: dynamodb.NewFromConfig(cfg), tableName: properParameters.TableName, log: log}
var client *dynamodb.Client

if properParameters.Endpoint == "" {
client = dynamodb.NewFromConfig(cfg)

Check warning on line 86 in pkg/storage/cache/dynamodb.go

View check run for this annotation

Codecov / codecov/patch

pkg/storage/cache/dynamodb.go#L86

Added line #L86 was not covered by tests
} else {
client = dynamodb.NewFromConfig(cfg, func(o *dynamodb.Options) {
o.BaseEndpoint = aws.String(properParameters.Endpoint)
})
}

driver := &DynamoDBDriver{client: client, tableName: properParameters.TableName, log: log}

err = driver.NewTable(driver.tableName)
if err != nil {
Expand Down
Loading