From f4983de475a161bff8fd6dfea517b863c2545595 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 13 May 2015 20:02:54 -0700 Subject: [PATCH] Do not add region for mc, since mc treats with URLs not regions --- Godeps/Godeps.json | 2 +- .../github.com/minio/objectstorage-go/api.go | 21 +++++++++++++------ pkg/client/s3/s3.go | 1 - 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4b650c52..00032a44 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -36,7 +36,7 @@ }, { "ImportPath": "github.com/minio/objectstorage-go", - "Rev": "a6e37582197d43a87e152326d4d683878b97a969" + "Rev": "ee88d26b8cc8a588556e3111827d35bd1f2a7169" }, { "ImportPath": "github.com/shiena/ansicolor", diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go index ce346433..363c59e3 100644 --- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go +++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go @@ -131,17 +131,26 @@ type Config struct { // MustGetEndpoint makes sure that a valid endpoint is provided all the time, even with false regions it will fall // back to default, for no regions specified it chooses to default to "milkyway" and use endpoint as is func (c *Config) MustGetEndpoint() string { - // for custom domains, there are no regions default to 'milkyway' - if strings.TrimSpace(c.Region) == "" && strings.TrimSpace(c.Endpoint) != "" { + if strings.TrimSpace(c.Endpoint) != "" { + if strings.Contains(strings.TrimSpace(c.Endpoint), "s3.amazonaws.com") { + c.Region = "us-east-1" + return getEndpoint(c.Region) + } + // for custom domains, there are no regions default to 'milkyway' c.Region = "milkyway" return c.Endpoint } // if valid region provided override user provided endpoint - if endpoint := getEndpoint(strings.TrimSpace(c.Region)); endpoint != "" { - c.Endpoint = endpoint - return c.Endpoint + if strings.TrimSpace(c.Region) != "" { + if endpoint := getEndpoint(strings.TrimSpace(c.Region)); endpoint != "" { + c.Endpoint = endpoint + return c.Endpoint + } + // fall back if region is set and not found, go through US-standard + c.Region = "us-east-1" + return getEndpoint(c.Region) } - // fall back if region is set and not found, go through US-standard + // if not endpoint or region sepcified default to us-east-1 c.Region = "us-east-1" return getEndpoint(c.Region) } diff --git a/pkg/client/s3/s3.go b/pkg/client/s3/s3.go index 83405e83..448cef4d 100644 --- a/pkg/client/s3/s3.go +++ b/pkg/client/s3/s3.go @@ -70,7 +70,6 @@ func New(config *Config) client.Client { objectstorageConf.AccessKeyID = config.AccessKeyID objectstorageConf.SecretAccessKey = config.SecretAccessKey objectstorageConf.UserAgent = config.UserAgent - objectstorageConf.Region = "us-east-1" objectstorageConf.Transport = transport objectstorageConf.Endpoint = u.Scheme + "://" + u.Host api := objectstorage.New(objectstorageConf)