Map S3 regions to Google (multi)regions

master
Remco Verhoef 8 years ago committed by Harshavardhana
parent bf55591c64
commit de5374f74c
  1. 20
      cmd/gateway-gcs-layer.go
  2. 11
      cmd/gateway-main.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 {

@ -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.

Loading…
Cancel
Save