summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/minio-go/v7/api-put-bucket.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/api-put-bucket.go')
-rw-r--r--vendor/github.com/minio/minio-go/v7/api-put-bucket.go33
1 files changed, 20 insertions, 13 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/api-put-bucket.go b/vendor/github.com/minio/minio-go/v7/api-put-bucket.go
index 737666937..447d0c796 100644
--- a/vendor/github.com/minio/minio-go/v7/api-put-bucket.go
+++ b/vendor/github.com/minio/minio-go/v7/api-put-bucket.go
@@ -33,48 +33,52 @@ func (c *Client) makeBucket(ctx context.Context, bucketName string, opts MakeBuc
return err
}
- err = c.doMakeBucket(ctx, bucketName, opts.Region, opts.ObjectLocking)
+ err = c.doMakeBucket(ctx, bucketName, opts)
if err != nil && (opts.Region == "" || opts.Region == "us-east-1") {
if resp, ok := err.(ErrorResponse); ok && resp.Code == "AuthorizationHeaderMalformed" && resp.Region != "" {
- err = c.doMakeBucket(ctx, bucketName, resp.Region, opts.ObjectLocking)
+ opts.Region = resp.Region
+ err = c.doMakeBucket(ctx, bucketName, opts)
}
}
return err
}
-func (c *Client) doMakeBucket(ctx context.Context, bucketName, location string, objectLockEnabled bool) (err error) {
+func (c *Client) doMakeBucket(ctx context.Context, bucketName string, opts MakeBucketOptions) (err error) {
defer func() {
// Save the location into cache on a successful makeBucket response.
if err == nil {
- c.bucketLocCache.Set(bucketName, location)
+ c.bucketLocCache.Set(bucketName, opts.Region)
}
}()
// If location is empty, treat is a default region 'us-east-1'.
- if location == "" {
- location = "us-east-1"
+ if opts.Region == "" {
+ opts.Region = "us-east-1"
// For custom region clients, default
// to custom region instead not 'us-east-1'.
if c.region != "" {
- location = c.region
+ opts.Region = c.region
}
}
// PUT bucket request metadata.
reqMetadata := requestMetadata{
bucketName: bucketName,
- bucketLocation: location,
+ bucketLocation: opts.Region,
}
- if objectLockEnabled {
- headers := make(http.Header)
+ headers := make(http.Header)
+ if opts.ObjectLocking {
headers.Add("x-amz-bucket-object-lock-enabled", "true")
- reqMetadata.customHeader = headers
}
+ if opts.ForceCreate {
+ headers.Add("x-minio-force-create", "true")
+ }
+ reqMetadata.customHeader = headers
// If location is not 'us-east-1' create bucket location config.
- if location != "us-east-1" && location != "" {
+ if opts.Region != "us-east-1" && opts.Region != "" {
createBucketConfig := createBucketConfiguration{}
- createBucketConfig.Location = location
+ createBucketConfig.Location = opts.Region
var createBucketConfigBytes []byte
createBucketConfigBytes, err = xml.Marshal(createBucketConfig)
if err != nil {
@@ -109,6 +113,9 @@ type MakeBucketOptions struct {
Region string
// Enable object locking
ObjectLocking bool
+
+ // ForceCreate - this is a MinIO specific extension.
+ ForceCreate bool
}
// MakeBucket creates a new bucket with bucketName with a context to control cancellations and timeouts.