mirror of
https://github.com/thegeeklab/wp-s3-action.git
synced 2024-11-25 00:10:39 +00:00
Add flag for custom endpoint
This commit is contained in:
parent
b061579827
commit
5001f2ffa0
8
aws.go
8
aws.go
@ -7,6 +7,7 @@ import (
|
||||
"mime"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
@ -28,8 +29,11 @@ type AWS struct {
|
||||
|
||||
func NewAWS(p *Plugin) AWS {
|
||||
sess := session.New(&aws.Config{
|
||||
Credentials: credentials.NewStaticCredentials(p.Key, p.Secret, ""),
|
||||
Region: aws.String(p.Region),
|
||||
Endpoint: &p.Endpoint,
|
||||
DisableSSL: aws.Bool(strings.HasPrefix(p.Endpoint, "http://")),
|
||||
Credentials: credentials.NewStaticCredentials(p.Key, p.Secret, ""),
|
||||
S3ForcePathStyle: aws.Bool(p.PathStyle),
|
||||
Region: aws.String(p.Region),
|
||||
})
|
||||
c := s3.New(sess)
|
||||
cf := cloudfront.New(sess)
|
||||
|
13
main.go
13
main.go
@ -18,6 +18,11 @@ func main() {
|
||||
app.Action = run
|
||||
app.Version = fmt.Sprintf("1.1.0+%s", build)
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "endpoint",
|
||||
Usage: "endpoint for the s3 connection",
|
||||
EnvVar: "PLUGIN_ENDPOINT,S3_ENDPOINT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "access-key",
|
||||
Usage: "aws access key",
|
||||
@ -28,6 +33,11 @@ func main() {
|
||||
Usage: "aws secret key",
|
||||
EnvVar: "PLUGIN_SECRET_KEY,AWS_SECRET_ACCESS_KEY",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "path-style",
|
||||
Usage: "use path style for bucket paths",
|
||||
EnvVar: "PLUGIN_PATH_STYLE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "bucket",
|
||||
Usage: "name of bucket",
|
||||
@ -117,8 +127,9 @@ func run(c *cli.Context) error {
|
||||
if c.String("env-file") != "" {
|
||||
_ = godotenv.Load(c.String("env-file"))
|
||||
}
|
||||
|
||||
plugin := Plugin{
|
||||
Endpoint: c.String("endpoint"),
|
||||
PathStyle: c.Bool("path-style"),
|
||||
Key: c.String("access-key"),
|
||||
Secret: c.String("secret-key"),
|
||||
Bucket: c.String("bucket"),
|
||||
|
Loading…
Reference in New Issue
Block a user