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

added -s3-force-path-style flag #614

Merged
merged 1 commit into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions docs/s3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The following flags are supported by `selenoid` command when compiled with S3 su
S3 endpoint URL
-s3-exclude-files string
Pattern used to match and exclude files
-s3-force-path-style
Force path-style addressing for file upload
-s3-include-files string
Pattern used to match and include files
-s3-keep-files
Expand Down
9 changes: 6 additions & 3 deletions upload/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func init() {
flag.BoolVar(&(s3.KeepFiles), "s3-keep-files", false, "Do not remove uploaded files")
flag.StringVar(&(s3.IncludeFiles), "s3-include-files", "", "Pattern used to match and include files")
flag.StringVar(&(s3.ExcludeFiles), "s3-exclude-files", "", "Pattern used to match and exclude files")
flag.BoolVar(&(s3.ForcePathStyle), "s3-force-path-style", false, "Force path-style addressing for file upload")
AddUploader(s3)
}

Expand All @@ -44,15 +45,17 @@ type S3Uploader struct {
KeepFiles bool
IncludeFiles string
ExcludeFiles string
ForcePathStyle bool

manager *s3manager.Uploader
}

func (s3 *S3Uploader) Init() {
if s3.Endpoint != "" {
config := &aws.Config{
Endpoint: aws.String(s3.Endpoint),
Region: aws.String(s3.Region),
Endpoint: aws.String(s3.Endpoint),
Region: aws.String(s3.Region),
S3ForcePathStyle: aws.Bool(s3.ForcePathStyle),
}
if s3.AccessKey != "" && s3.SecretKey != "" {
config.Credentials = credentials.NewStaticCredentials(s3.AccessKey, s3.SecretKey, "")
Expand All @@ -61,7 +64,7 @@ func (s3 *S3Uploader) Init() {
if err != nil {
log.Fatalf("[-] [INIT] [Failed to initialize S3 support: %v]", err)
}
log.Printf("[-] [INIT] [Initialized S3 support: endpoint = %s, region = %s, bucketName = %s, accessKey = %s, keyPattern = %s, includeFiles = %s, excludeFiles = %s]", s3.Endpoint, s3.Region, s3.BucketName, s3.AccessKey, s3.KeyPattern, s3.IncludeFiles, s3.ExcludeFiles)
log.Printf("[-] [INIT] [Initialized S3 support: endpoint = %s, region = %s, bucketName = %s, accessKey = %s, keyPattern = %s, includeFiles = %s, excludeFiles = %s, forcePathStyle = %s]", s3.Endpoint, s3.Region, s3.BucketName, s3.AccessKey, s3.KeyPattern, s3.IncludeFiles, s3.ExcludeFiles, s3.ForcePathStyle)
s3.manager = s3manager.NewUploader(sess)
}
}
Expand Down