Skip to content

Commit

Permalink
Merge pull request #301 from k1LoW/fix-s3
Browse files Browse the repository at this point in the history
Identify the region of the bucket
  • Loading branch information
k1LoW authored Nov 3, 2023
2 parents 97b70e5 + e26937a commit 027fba6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (

"cloud.google.com/go/bigquery"
"cloud.google.com/go/storage"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/k1LoW/octocov/datastore/artifact"
"github.com/k1LoW/octocov/datastore/bq"
"github.com/k1LoW/octocov/datastore/gcs"
Expand Down Expand Up @@ -97,7 +99,18 @@ func New(ctx context.Context, u string, hints ...HintFunc) (Datastore, error) {
case S3:
bucket := args[0]
prefix := args[1]
sess, err := session.NewSession()
region, err := s3manager.GetBucketRegion(
ctx,
session.Must(session.NewSession()),
bucket,
"us-east-1",
)
if err != nil {
return nil, err
}
sess, err := session.NewSession(&aws.Config{
Region: aws.String(region),
})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 027fba6

Please sign in to comment.