Skip to content

Commit

Permalink
Add configuration parameter to force path layout
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbischof committed Sep 9, 2020
1 parent b95e0c2 commit 36b05ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions cache/s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The s3cache config supports the following properties:
- `access_control_list` (string): the S3 access control to set on the file when putting the file. defaults to ''.
- `cache_control` (string): the HTTP cache control header to set on the file when putting the file. defaults to ''.
- `content_type` (string): the http MIME-type set on the file when putting the file. defaults to 'application/vnd.mapbox-vector-tile'.
- `force_path_style` (boolean): [Optional] enable path style to support object stores with different path layouts like minio . defaults to 'false'


## Credential chain
Expand Down
23 changes: 17 additions & 6 deletions cache/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ const (
ConfigKeyACL = "access_control_list" // defaults to ""
ConfigKeyCacheControl = "cache_control" // defaults to ""
ConfigKeyContentType = "content_type" // defaults to "application/vnd.mapbox-vector-tile"
ConfigKeyForcePathStyle = "force_path_style" // defaults to "false"
)

const (
DefaultBasepath = ""
DefaultRegion = "us-east-1"
DefaultAccessKey = ""
DefaultSecretKey = ""
DefaultContentType = mvt.MimeType
DefaultEndpoint = ""
DefaultBasepath = ""
DefaultRegion = "us-east-1"
DefaultAccessKey = ""
DefaultSecretKey = ""
DefaultContentType = mvt.MimeType
DefaultEndpoint = ""
DefaultForcePathStyle = false
)

// testData is used during New() to confirm the ability to write, read and purge the cache
Expand Down Expand Up @@ -139,6 +141,15 @@ func New(config dict.Dicter) (cache.Interface, error) {
return nil, err
}

// support for different path layouts than aws-s3
// necessary for e.g. minio object store
forcePathStyle := DefaultForcePathStyle
forcePathStyle, err = config.Bool(ConfigKeyForcePathStyle, &forcePathStyle)
if err != nil {
return nil, err
}
awsConfig.S3ForcePathStyle = aws.Bool(forcePathStyle)

// support for static credentials, this is not recommended by AWS but
// necessary for some environments
if accessKey != "" && secretKey != "" {
Expand Down

0 comments on commit 36b05ba

Please sign in to comment.