diff --git a/cmd/gateway-gcs-layer.go b/cmd/gateway-gcs-layer.go index 1591bc928..859937ecd 100644 --- a/cmd/gateway-gcs-layer.go +++ b/cmd/gateway-gcs-layer.go @@ -218,6 +218,26 @@ func (l *gcsGateway) MakeBucket(bucket string) error { func (l *gcsGateway) MakeBucketWithLocation(bucket, location string) error { bkt := l.client.Bucket(bucket) + // this will map s3 regions to google multi regions + if v, ok := map[string]string{ + "ap-northeast-1": "asia", + "ap-northeast-2": "asia", + "ap-south-1": "asia", + "ap-southeast-1": "asia", + "ap-southeast-2": "asia", + "eu-central-1": "eu", + "eu-west-1": "eu", + "eu-west-2": "eu", + "ca-central-1": "us", + "sa-east-1": "us", + "us-east-1": "us", + "us-east-2": "us", + "us-west-1": "us", + "us-west-2": "us", + }[location]; ok { + location = v + } + if err := bkt.Create(l.ctx, l.projectID, &storage.BucketAttrs{ Location: location, }); err != nil { diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index 9b4c09bc8..03523bdec 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -179,6 +179,17 @@ const ( // Add more backends here. ) +// GatewayFn returns the GatewayLayer for the backend +type GatewayFn func([]string) (GatewayLayer, error) + +var ( + backends = map[gatewayBackend]GatewayFn{ + azureBackend: newAzureLayer, + s3Backend: newS3Gateway, + gcsBackend: newGCSGateway, + } +) + // Returns access and secretkey set from environment variables. func mustGetGatewayConfigFromEnv() (string, string, string) { // Fetch access keys from environment variables.