mirror of
https://github.com/distribution/distribution.git
synced 2025-09-02 23:45:53 +00:00
Add forcepathstyle parameter for s3
Signed-off-by: duanhongyi <duanhongyi@doopai.com>
This commit is contained in:
@@ -88,6 +88,7 @@ type DriverParameters struct {
|
||||
Bucket string
|
||||
Region string
|
||||
RegionEndpoint string
|
||||
ForcePathStyle bool
|
||||
Encrypt bool
|
||||
KeyID string
|
||||
Secure bool
|
||||
@@ -189,6 +190,23 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||
regionEndpoint = ""
|
||||
}
|
||||
|
||||
forcePathStyleBool := true
|
||||
forcePathStyle := parameters["forcepathstyle"]
|
||||
switch forcePathStyle := forcePathStyle.(type) {
|
||||
case string:
|
||||
b, err := strconv.ParseBool(forcePathStyle)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the forcePathStyle parameter should be a boolean")
|
||||
}
|
||||
forcePathStyleBool = b
|
||||
case bool:
|
||||
forcePathStyleBool = forcePathStyle
|
||||
case nil:
|
||||
// do nothing
|
||||
default:
|
||||
return nil, fmt.Errorf("the forcePathStyle parameter should be a boolean")
|
||||
}
|
||||
|
||||
regionName := parameters["region"]
|
||||
if regionName == nil || fmt.Sprint(regionName) == "" {
|
||||
return nil, fmt.Errorf("no region parameter provided")
|
||||
@@ -401,6 +419,7 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||
fmt.Sprint(bucket),
|
||||
region,
|
||||
fmt.Sprint(regionEndpoint),
|
||||
forcePathStyleBool,
|
||||
encryptBool,
|
||||
fmt.Sprint(keyID),
|
||||
secureBool,
|
||||
@@ -473,8 +492,8 @@ func New(params DriverParameters) (*Driver, error) {
|
||||
}
|
||||
|
||||
if params.RegionEndpoint != "" {
|
||||
awsConfig.WithS3ForcePathStyle(true)
|
||||
awsConfig.WithEndpoint(params.RegionEndpoint)
|
||||
awsConfig.WithS3ForcePathStyle(params.ForcePathStyle)
|
||||
}
|
||||
|
||||
awsConfig.WithS3UseAccelerate(params.Accelerate)
|
||||
|
Reference in New Issue
Block a user