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

s3: Add option to bypass CreateBucket #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 12 additions & 7 deletions s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ type Options struct {
// and some work only with the path style (especially self-hosted services like a Minio server running on localhost).
// Optional (false by default).
UsePathStyleAddressing bool
// Call createBucket
// Optional (false by default)
BypassCreateBucket bool
// Encoding format.
// Optional (encoding.JSON by default).
Codec encoding.Codec
Expand Down Expand Up @@ -221,13 +224,15 @@ func NewClient(options Options) (Client, error) {
svc := awss3.New(session)

// Create the bucket if it doesn't exist yet.
createBucketInput := awss3.CreateBucketInput{
Bucket: aws.String(options.BucketName),
}
origS3 := options.CustomEndpoint == ""
err = createBucket(origS3, svc, createBucketInput, options.BucketName)
if err != nil {
return result, err
if !options.BypassCreateBucket {
createBucketInput := awss3.CreateBucketInput{
Bucket: aws.String(options.BucketName),
}
origS3 := options.CustomEndpoint == ""
err = createBucket(origS3, svc, createBucketInput, options.BucketName)
if err != nil {
return result, err
}
}

result.c = svc
Expand Down