Skip to content

Commit

Permalink
S3 custom endpoint (#499)
Browse files Browse the repository at this point in the history
Former-commit-id: b64bf7a3c3fde2c0bbfec3e0f1c783691e6cb439
  • Loading branch information
nopcoder authored Aug 17, 2020
1 parent 08c66b5 commit de3b9f7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"strings"
"time"

"github.com/treeverse/lakefs/block/gcs"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
Expand All @@ -21,6 +19,7 @@ import (
"github.com/spf13/viper"
"github.com/treeverse/lakefs/auth"
"github.com/treeverse/lakefs/block"
"github.com/treeverse/lakefs/block/gcs"
"github.com/treeverse/lakefs/block/local"
"github.com/treeverse/lakefs/block/mem"
s3a "github.com/treeverse/lakefs/block/s3"
Expand Down Expand Up @@ -234,7 +233,18 @@ func (c *Config) buildS3Adapter() (block.Adapter, error) {
return nil, err
}
sess.ClientConfig(s3.ServiceName)
svc := s3.New(sess)

awsConfig := aws.NewConfig()
s3Endpoint := viper.GetString("blockstore.s3.endpoint")
if len(s3Endpoint) > 0 {
awsConfig = awsConfig.WithEndpoint(s3Endpoint)
}
s3ForcePathStyle := viper.GetBool("blockstore.s3.force_path_style")
if s3ForcePathStyle {
awsConfig = awsConfig.WithS3ForcePathStyle(true)
}

svc := s3.New(sess, awsConfig)
adapter := s3a.NewAdapter(svc,
s3a.WithStreamingChunkSize(viper.GetInt("blockstore.s3.streaming_chunk_size")),
s3a.WithStreamingChunkTimeout(viper.GetDuration("blockstore.s3.streaming_chunk_timeout")))
Expand Down

0 comments on commit de3b9f7

Please sign in to comment.