forked from TrueCloudLab/distribution
Merge pull request #3181 from pimuzzo/s3-transfer-accelerate
Add new parameter accelerate to S3 storage driver.
This commit is contained in:
commit
cd51f38d53
3 changed files with 33 additions and 0 deletions
|
@ -118,6 +118,7 @@ storage:
|
||||||
secretkey: awssecretkey
|
secretkey: awssecretkey
|
||||||
region: us-west-1
|
region: us-west-1
|
||||||
regionendpoint: http://myobjects.local
|
regionendpoint: http://myobjects.local
|
||||||
|
accelerate: false
|
||||||
bucket: bucketname
|
bucket: bucketname
|
||||||
encrypt: true
|
encrypt: true
|
||||||
keyid: mykeyid
|
keyid: mykeyid
|
||||||
|
@ -422,6 +423,7 @@ storage:
|
||||||
secretkey: awssecretkey
|
secretkey: awssecretkey
|
||||||
region: us-west-1
|
region: us-west-1
|
||||||
regionendpoint: http://myobjects.local
|
regionendpoint: http://myobjects.local
|
||||||
|
accelerate: false
|
||||||
bucket: bucketname
|
bucket: bucketname
|
||||||
encrypt: true
|
encrypt: true
|
||||||
keyid: mykeyid
|
keyid: mykeyid
|
||||||
|
|
|
@ -104,6 +104,7 @@ type DriverParameters struct {
|
||||||
ObjectACL string
|
ObjectACL string
|
||||||
SessionToken string
|
SessionToken string
|
||||||
UseDualStack bool
|
UseDualStack bool
|
||||||
|
Accelerate bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -377,6 +378,23 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||||
|
|
||||||
sessionToken := ""
|
sessionToken := ""
|
||||||
|
|
||||||
|
accelerateBool := false
|
||||||
|
accelerate := parameters["accelerate"]
|
||||||
|
switch accelerate := accelerate.(type) {
|
||||||
|
case string:
|
||||||
|
b, err := strconv.ParseBool(accelerate)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("the accelerate parameter should be a boolean")
|
||||||
|
}
|
||||||
|
accelerateBool = b
|
||||||
|
case bool:
|
||||||
|
accelerateBool = accelerate
|
||||||
|
case nil:
|
||||||
|
// do nothing
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("the accelerate parameter should be a boolean")
|
||||||
|
}
|
||||||
|
|
||||||
params := DriverParameters{
|
params := DriverParameters{
|
||||||
fmt.Sprint(accessKey),
|
fmt.Sprint(accessKey),
|
||||||
fmt.Sprint(secretKey),
|
fmt.Sprint(secretKey),
|
||||||
|
@ -399,6 +417,7 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||||
objectACL,
|
objectACL,
|
||||||
fmt.Sprint(sessionToken),
|
fmt.Sprint(sessionToken),
|
||||||
useDualStackBool,
|
useDualStackBool,
|
||||||
|
accelerateBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
return New(params)
|
return New(params)
|
||||||
|
@ -458,6 +477,7 @@ func New(params DriverParameters) (*Driver, error) {
|
||||||
awsConfig.WithEndpoint(params.RegionEndpoint)
|
awsConfig.WithEndpoint(params.RegionEndpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
awsConfig.WithS3UseAccelerate(params.Accelerate)
|
||||||
awsConfig.WithRegion(params.Region)
|
awsConfig.WithRegion(params.Region)
|
||||||
awsConfig.WithDisableSSL(!params.Secure)
|
awsConfig.WithDisableSSL(!params.Secure)
|
||||||
if params.UseDualStack {
|
if params.UseDualStack {
|
||||||
|
|
|
@ -44,6 +44,7 @@ func init() {
|
||||||
sessionToken := os.Getenv("AWS_SESSION_TOKEN")
|
sessionToken := os.Getenv("AWS_SESSION_TOKEN")
|
||||||
useDualStack := os.Getenv("S3_USE_DUALSTACK")
|
useDualStack := os.Getenv("S3_USE_DUALSTACK")
|
||||||
combineSmallPart := os.Getenv("MULTIPART_COMBINE_SMALL_PART")
|
combineSmallPart := os.Getenv("MULTIPART_COMBINE_SMALL_PART")
|
||||||
|
accelerate := os.Getenv("S3_ACCELERATE")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -86,6 +87,7 @@ func init() {
|
||||||
if useDualStack != "" {
|
if useDualStack != "" {
|
||||||
useDualStackBool, err = strconv.ParseBool(useDualStack)
|
useDualStackBool, err = strconv.ParseBool(useDualStack)
|
||||||
}
|
}
|
||||||
|
|
||||||
multipartCombineSmallPart := true
|
multipartCombineSmallPart := true
|
||||||
if combineSmallPart != "" {
|
if combineSmallPart != "" {
|
||||||
multipartCombineSmallPart, err = strconv.ParseBool(combineSmallPart)
|
multipartCombineSmallPart, err = strconv.ParseBool(combineSmallPart)
|
||||||
|
@ -94,6 +96,14 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accelerateBool := true
|
||||||
|
if accelerate != "" {
|
||||||
|
accelerateBool, err = strconv.ParseBool(accelerate)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parameters := DriverParameters{
|
parameters := DriverParameters{
|
||||||
accessKey,
|
accessKey,
|
||||||
secretKey,
|
secretKey,
|
||||||
|
@ -116,6 +126,7 @@ func init() {
|
||||||
objectACL,
|
objectACL,
|
||||||
sessionToken,
|
sessionToken,
|
||||||
useDualStackBool,
|
useDualStackBool,
|
||||||
|
accelerateBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
return New(parameters)
|
return New(parameters)
|
||||||
|
|
Loading…
Reference in a new issue