File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,28 +6,15 @@ import (
66 "github.com/aws/aws-sdk-go/service/s3"
77)
88
9+ const (
10+ bucketAlreadyExistsCode = "BucketAlreadyExists"
11+ )
12+
913var (
1014 // ACLPublicRead default ACL for objects in the S3 API compatible storage
1115 ACLPublicRead = aws .String ("public-read" )
1216)
1317
14- // BucketExists returns if a bucket exists in the S3 API compatible storage
15- func BucketExists (svc * s3.S3 , bucketName string ) (bool , error ) {
16- _ , err := svc .HeadBucket (& s3.HeadBucketInput {
17- Bucket : aws .String (bucketName ),
18- })
19- if err != nil {
20- if awsErr , ok := err .(awserr.Error ); ok {
21- if awsErr .Code () == "404" {
22- return false , nil
23- }
24- }
25-
26- return false , err
27- }
28- return true , nil
29- }
30-
3118// CreateBucket creates a new bucket in the S3 API compatible storage or
3219// return an error in case the bucket already exists
3320func CreateBucket (svc * s3.S3 , bucketName string ) error {
@@ -38,7 +25,7 @@ func CreateBucket(svc *s3.S3, bucketName string) error {
3825
3926 if err != nil {
4027 if awsErr , ok := err .(awserr.Error ); ok {
41- if awsErr .Code () == "409" {
28+ if awsErr .Code () == bucketAlreadyExistsCode {
4229 return nil
4330 }
4431 }
You can’t perform that action at this time.
0 commit comments