Skip to content

Commit

Permalink
fix(dynamodb): remove deprecated function
Browse files Browse the repository at this point in the history
Signed-off-by: Petu Eusebiu <[email protected]>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Jan 17, 2025
1 parent d6b38c0 commit 1fc8532
Showing 1 changed file with 12 additions and 13 deletions.
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 @@ func NewDynamoDBCache(parameters interface{}, log zlog.Logger) (*DynamoDBDriver,
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

0 comments on commit 1fc8532

Please sign in to comment.