Provide pathstyle for S3 log storage
This commit is contained in:
parent
7c1f21d872
commit
876645a1b0
3 changed files with 16 additions and 5 deletions
|
@ -330,9 +330,10 @@ type (
|
|||
|
||||
// S3 provides the storage configuration.
|
||||
S3 struct {
|
||||
Bucket string `envconfig:"DRONE_S3_BUCKET"`
|
||||
Prefix string `envconfig:"DRONE_S3_PREFIX"`
|
||||
Endpoint string `envconfig:"DRONE_S3_ENDPOINT"`
|
||||
Bucket string `envconfig:"DRONE_S3_BUCKET"`
|
||||
Prefix string `envconfig:"DRONE_S3_PREFIX"`
|
||||
Endpoint string `envconfig:"DRONE_S3_ENDPOINT"`
|
||||
PathStyle bool `envconfig:"DRONE_S3_PATH_STYLE"`
|
||||
}
|
||||
|
||||
// HTTP provides http configuration.
|
||||
|
|
|
@ -86,6 +86,7 @@ func provideLogStore(db *db.DB, config config.Config) core.LogStore {
|
|||
config.S3.Bucket,
|
||||
config.S3.Prefix,
|
||||
config.S3.Endpoint,
|
||||
config.S3.PathStyle,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
|
@ -22,13 +23,21 @@ import (
|
|||
// s3gof3r as an alternate. github.com/rlmcpherson/s3gof3r
|
||||
|
||||
// NewS3Env returns a new S3 log store.
|
||||
func NewS3Env(bucket, prefix, endpoint string) core.LogStore {
|
||||
func NewS3Env(bucket, prefix, endpoint string, pathStyle bool) core.LogStore {
|
||||
disableSSL := false
|
||||
|
||||
if endpoint != "" {
|
||||
disableSSL = !strings.HasPrefix(endpoint, "https://")
|
||||
}
|
||||
|
||||
return &s3store{
|
||||
bucket: bucket,
|
||||
prefix: prefix,
|
||||
session: session.Must(
|
||||
session.NewSession(&aws.Config{
|
||||
Endpoint: aws.String(endpoint),
|
||||
Endpoint: aws.String(endpoint),
|
||||
DisableSSL: aws.Bool(disableSSL),
|
||||
S3ForcePathStyle: aws.Bool(pathStyle),
|
||||
}),
|
||||
),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue