1
0
Fork 0
mirror of https://github.com/Luzifer/mondash.git synced 2024-11-10 08:30:02 +00:00
mondash/vendor/github.com/aws/aws-sdk-go/service/s3/bucket_location.go

44 lines
1.1 KiB
Go
Raw Normal View History

2016-01-23 12:07:07 +00:00
package s3
import (
"io/ioutil"
"regexp"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/awsutil"
2016-03-27 18:46:08 +00:00
"github.com/aws/aws-sdk-go/aws/request"
2016-01-23 12:07:07 +00:00
)
var reBucketLocation = regexp.MustCompile(`>([^<>]+)<\/Location`)
2016-03-27 18:46:08 +00:00
func buildGetBucketLocation(r *request.Request) {
2016-01-23 12:07:07 +00:00
if r.DataFilled() {
out := r.Data.(*GetBucketLocationOutput)
b, err := ioutil.ReadAll(r.HTTPResponse.Body)
if err != nil {
r.Error = awserr.New("SerializationError", "failed reading response body", err)
return
}
match := reBucketLocation.FindSubmatch(b)
if len(match) > 1 {
loc := string(match[1])
out.LocationConstraint = &loc
}
}
}
2016-03-27 18:46:08 +00:00
func populateLocationConstraint(r *request.Request) {
if r.ParamsFilled() && aws.StringValue(r.Service.Config.Region) != "us-east-1" {
2016-01-23 12:07:07 +00:00
in := r.Params.(*CreateBucketInput)
if in.CreateBucketConfiguration == nil {
r.Params = awsutil.CopyOf(r.Params)
in = r.Params.(*CreateBucketInput)
in.CreateBucketConfiguration = &CreateBucketConfiguration{
2016-03-27 18:46:08 +00:00
LocationConstraint: r.Service.Config.Region,
2016-01-23 12:07:07 +00:00
}
}
}
}