mirror of
https://github.com/thegeeklab/wp-s3-action.git
synced 2024-11-25 10:20:39 +00:00
refactor: rename parameter access to acl (#18)
BREAKING CHANGE: The parameter `access` was renamed to `acl` and the environment variable `PLUGIN_ACCESS` was removed.
This commit is contained in:
parent
9e053ce454
commit
df7cc521d1
@ -48,8 +48,8 @@ properties:
|
|||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
access:
|
acl:
|
||||||
description: Access control settings.
|
description: Access control list.
|
||||||
type: map
|
type: map
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
@ -78,9 +78,9 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
|||||||
Category: category,
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.GenericFlag{
|
&cli.GenericFlag{
|
||||||
Name: "access",
|
Name: "acl",
|
||||||
Usage: "access control settings",
|
Usage: "access control list",
|
||||||
EnvVars: []string{"PLUGIN_ACCESS", "PLUGIN_ACL"},
|
EnvVars: []string{"PLUGIN_ACL"},
|
||||||
Value: &StringMapFlag{},
|
Value: &StringMapFlag{},
|
||||||
Category: category,
|
Category: category,
|
||||||
},
|
},
|
||||||
|
@ -44,7 +44,7 @@ func run(settings *plugin.Settings) cli.ActionFunc {
|
|||||||
return func(ctx *cli.Context) error {
|
return func(ctx *cli.Context) error {
|
||||||
urfave.LoggingFromContext(ctx)
|
urfave.LoggingFromContext(ctx)
|
||||||
|
|
||||||
settings.Access = ctx.Generic("access").(*StringMapFlag).Get()
|
settings.ACL = ctx.Generic("acl").(*StringMapFlag).Get()
|
||||||
settings.CacheControl = ctx.Generic("cache-control").(*StringMapFlag).Get()
|
settings.CacheControl = ctx.Generic("cache-control").(*StringMapFlag).Get()
|
||||||
settings.ContentType = ctx.Generic("content-type").(*StringMapFlag).Get()
|
settings.ContentType = ctx.Generic("content-type").(*StringMapFlag).Get()
|
||||||
settings.ContentEncoding = ctx.Generic("content-encoding").(*StringMapFlag).Get()
|
settings.ContentEncoding = ctx.Generic("content-encoding").(*StringMapFlag).Get()
|
||||||
|
@ -67,16 +67,16 @@ func (a *AWS) Upload(local, remote string) error {
|
|||||||
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
var access string
|
var acl string
|
||||||
for pattern := range p.settings.Access {
|
for pattern := range p.settings.ACL {
|
||||||
if match := glob.Glob(pattern, local); match {
|
if match := glob.Glob(pattern, local); match {
|
||||||
access = p.settings.Access[pattern]
|
acl = p.settings.ACL[pattern]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if access == "" {
|
if acl == "" {
|
||||||
access = "private"
|
acl = "private"
|
||||||
}
|
}
|
||||||
|
|
||||||
fileExt := filepath.Ext(local)
|
fileExt := filepath.Ext(local)
|
||||||
@ -128,13 +128,13 @@ func (a *AWS) Upload(local, remote string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("'%s' not found in bucket, uploading with content-type '%s' and permissions '%s'", local, contentType, access)
|
logrus.Debugf("'%s' not found in bucket, uploading with content-type '%s' and permissions '%s'", local, contentType, acl)
|
||||||
putObject := &s3.PutObjectInput{
|
putObject := &s3.PutObjectInput{
|
||||||
Bucket: aws.String(p.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
Body: file,
|
Body: file,
|
||||||
ContentType: aws.String(contentType),
|
ContentType: aws.String(contentType),
|
||||||
ACL: aws.String(access),
|
ACL: aws.String(acl),
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,27 +218,27 @@ func (a *AWS) Upload(local, remote string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
previousAccess := "private"
|
previousACL := "private"
|
||||||
for _, g := range grant.Grants {
|
for _, g := range grant.Grants {
|
||||||
gt := *g.Grantee
|
gt := *g.Grantee
|
||||||
if gt.URI != nil {
|
if gt.URI != nil {
|
||||||
if *gt.URI == "http://acs.amazonaws.com/groups/global/AllUsers" {
|
if *gt.URI == "http://acs.amazonaws.com/groups/global/AllUsers" {
|
||||||
if *g.Permission == "READ" {
|
if *g.Permission == "READ" {
|
||||||
previousAccess = "public-read"
|
previousACL = "public-read"
|
||||||
} else if *g.Permission == "WRITE" {
|
} else if *g.Permission == "WRITE" {
|
||||||
previousAccess = "public-read-write"
|
previousACL = "public-read-write"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if *gt.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" {
|
if *gt.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" {
|
||||||
if *g.Permission == "READ" {
|
if *g.Permission == "READ" {
|
||||||
previousAccess = "authenticated-read"
|
previousACL = "authenticated-read"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if previousAccess != access {
|
if previousACL != acl {
|
||||||
logrus.Debugf("permissions for '%s' have changed from '%s' to '%s'", remote, previousAccess, access)
|
logrus.Debugf("permissions for '%s' have changed from '%s' to '%s'", remote, previousACL, acl)
|
||||||
shouldCopy = true
|
shouldCopy = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,12 +248,12 @@ func (a *AWS) Upload(local, remote string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("updating metadata for '%s' content-type: '%s', ACL: '%s'", local, contentType, access)
|
logrus.Debugf("updating metadata for '%s' content-type: '%s', ACL: '%s'", local, contentType, acl)
|
||||||
copyObject := &s3.CopyObjectInput{
|
copyObject := &s3.CopyObjectInput{
|
||||||
Bucket: aws.String(p.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
CopySource: aws.String(fmt.Sprintf("%s/%s", p.settings.Bucket, remote)),
|
CopySource: aws.String(fmt.Sprintf("%s/%s", p.settings.Bucket, remote)),
|
||||||
ACL: aws.String(access),
|
ACL: aws.String(acl),
|
||||||
ContentType: aws.String(contentType),
|
ContentType: aws.String(contentType),
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
MetadataDirective: aws.String("REPLACE"),
|
MetadataDirective: aws.String("REPLACE"),
|
||||||
@ -281,13 +281,13 @@ func (a *AWS) Upload(local, remote string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("uploading '%s' with content-type '%s' and permissions '%s'", local, contentType, access)
|
logrus.Debugf("uploading '%s' with content-type '%s' and permissions '%s'", local, contentType, acl)
|
||||||
putObject := &s3.PutObjectInput{
|
putObject := &s3.PutObjectInput{
|
||||||
Bucket: aws.String(p.settings.Bucket),
|
Bucket: aws.String(p.settings.Bucket),
|
||||||
Key: aws.String(remote),
|
Key: aws.String(remote),
|
||||||
Body: file,
|
Body: file,
|
||||||
ContentType: aws.String(contentType),
|
ContentType: aws.String(contentType),
|
||||||
ACL: aws.String(access),
|
ACL: aws.String(acl),
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ type Settings struct {
|
|||||||
Source string
|
Source string
|
||||||
Target string
|
Target string
|
||||||
Delete bool
|
Delete bool
|
||||||
Access map[string]string
|
ACL map[string]string
|
||||||
CacheControl map[string]string
|
CacheControl map[string]string
|
||||||
ContentType map[string]string
|
ContentType map[string]string
|
||||||
ContentEncoding map[string]string
|
ContentEncoding map[string]string
|
||||||
|
Loading…
Reference in New Issue
Block a user