Skip to content

Commit

Permalink
Merge pull request #6 from alexbarta/master
Browse files Browse the repository at this point in the history
Add s3 minio support
  • Loading branch information
maorfr authored Dec 25, 2018
2 parents 2a81cc4 + 71375d8 commit de7094e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ skbn cp \
* `f` is the in-memory buffer size (in MB) to use for files copy. This flag should be used with caution when used in conjunction with `--parallel`
* The default value for `buffer-size` is 6.75 MB, and was decided based on benchmark

### Minio S3 support

Skbn supports file copy from and to a Minio S3 endpoint. To let skbn know how your minio is configured, you can set the following environment variables:

```
AWS_ACCESS_KEY_ID=<your username>
AWS_SECRET_ACCESS_KEY=<your password>
AWS_S3_ENDPOINT=http(s)://<host>:<port>
AWS_S3_NO_SSL=true # disables SSL
AWS_S3_FORCE_PATH_STYLE=true # enforce path style bucket access
```

## Added bonus section

### Copy files from S3 to Azure Blob Storage
Expand Down
32 changes: 26 additions & 6 deletions pkg/skbn/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/nuvo/skbn/pkg/utils"
Expand Down Expand Up @@ -171,13 +172,32 @@ func UploadToS3(iClient interface{}, toPath, fromPath string, reader io.Reader)
}

func getNewSession() (*session.Session, error) {
region := os.Getenv("AWS_REGION")
if region == "" {
region = "eu-central-1"

awsConfig := &aws.Config{}

region := "eu-central-1"

if rg := os.Getenv("AWS_REGION"); rg != "" {
region = rg
}
s, err := session.NewSession(&aws.Config{
Region: aws.String(region),
})

awsConfig.Region = aws.String(region)

if endpoint := os.Getenv("AWS_S3_ENDPOINT"); endpoint != "" {
awsConfig.Endpoint = aws.String(endpoint)
}

if disSSL := os.Getenv("AWS_S3_NO_SSL"); disSSL != "" {
disableSSL, _ := strconv.ParseBool(disSSL)
awsConfig.DisableSSL = aws.Bool(disableSSL)
}

if fps := os.Getenv("AWS_S3_FORCE_PATH_STYLE"); fps != "" {
forcePathStyle, _ := strconv.ParseBool(fps)
awsConfig.S3ForcePathStyle = aws.Bool(forcePathStyle)
}

s, err := session.NewSession(awsConfig)

return s, err
}
Expand Down

0 comments on commit de7094e

Please sign in to comment.