mirror of
https://github.com/distribution/distribution.git
synced 2025-09-06 01:10:55 +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)
|
||||
|
@@ -41,6 +41,7 @@ func init() {
|
||||
objectACL := os.Getenv("S3_OBJECT_ACL")
|
||||
root, err := ioutil.TempDir("", "driver-")
|
||||
regionEndpoint := os.Getenv("REGION_ENDPOINT")
|
||||
forcePathStyle := os.Getenv("AWS_S3_FORCE_PATH_STYLE")
|
||||
sessionToken := os.Getenv("AWS_SESSION_TOKEN")
|
||||
useDualStack := os.Getenv("S3_USE_DUALSTACK")
|
||||
combineSmallPart := os.Getenv("MULTIPART_COMBINE_SMALL_PART")
|
||||
@@ -82,6 +83,13 @@ func init() {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
forcePathStyleBool := true
|
||||
if forcePathStyle != "" {
|
||||
forcePathStyleBool, err = strconv.ParseBool(forcePathStyle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
useDualStackBool := false
|
||||
if useDualStack != "" {
|
||||
@@ -110,6 +118,7 @@ func init() {
|
||||
bucket,
|
||||
region,
|
||||
regionEndpoint,
|
||||
forcePathStyleBool,
|
||||
encryptBool,
|
||||
keyID,
|
||||
secureBool,
|
||||
|
Reference in New Issue
Block a user