0
0
mirror of https://github.com/thegeeklab/wp-s3-action.git synced 2024-11-24 14:00:40 +00:00

Endpoint for aws.Config is optional

This commit is contained in:
hdhog 2017-10-28 12:00:06 +04:00
parent 5001f2ffa0
commit be22fc0596

14
aws.go
View File

@ -28,13 +28,19 @@ type AWS struct {
} }
func NewAWS(p *Plugin) AWS { func NewAWS(p *Plugin) AWS {
sess := session.New(&aws.Config{ sessCfg := &aws.Config{
Endpoint: &p.Endpoint,
DisableSSL: aws.Bool(strings.HasPrefix(p.Endpoint, "http://")),
Credentials: credentials.NewStaticCredentials(p.Key, p.Secret, ""), Credentials: credentials.NewStaticCredentials(p.Key, p.Secret, ""),
S3ForcePathStyle: aws.Bool(p.PathStyle), S3ForcePathStyle: aws.Bool(p.PathStyle),
Region: aws.String(p.Region), Region: aws.String(p.Region),
}) }
fmt.Println(p.Endpoint)
if p.Endpoint != "" {
sessCfg.Endpoint = &p.Endpoint
sessCfg.DisableSSL = aws.Bool(strings.HasPrefix(p.Endpoint, "http://"))
}
sess := session.New(sessCfg)
c := s3.New(sess) c := s3.New(sess)
cf := cloudfront.New(sess) cf := cloudfront.New(sess)
r := make([]string, 1, 1) r := make([]string, 1, 1)