Merge pull request #1604 from ArdaXi/custom-s3-skip-region-check

Only check validity of S3 region if not using custom endpoint
This commit is contained in:
Richard Scothern 2016-04-08 15:38:24 -07:00
commit 406d03bdb0

View file

@ -136,26 +136,28 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
secretKey = ""
}
regionEndpoint := parameters["regionendpoint"]
if regionEndpoint == nil {
regionEndpoint = ""
}
regionName, ok := parameters["region"]
if regionName == nil || fmt.Sprint(regionName) == "" {
return nil, fmt.Errorf("No region parameter provided")
}
region := fmt.Sprint(regionName)
_, ok = validRegions[region]
if !ok {
// Don't check the region value if a custom endpoint is provided.
if regionEndpoint == "" {
if _, ok = validRegions[region]; !ok {
return nil, fmt.Errorf("Invalid region provided: %v", region)
}
}
bucket := parameters["bucket"]
if bucket == nil || fmt.Sprint(bucket) == "" {
return nil, fmt.Errorf("No bucket parameter provided")
}
regionEndpoint := parameters["regionendpoint"]
if regionEndpoint == nil {
regionEndpoint = ""
}
encryptBool := false
encrypt := parameters["encrypt"]
switch encrypt := encrypt.(type) {