mirror of
https://github.com/thegeeklab/drone-s3-sync.git
synced 2024-11-22 11:10:39 +00:00
Merge pull request #38 from fbcbarbosa/master
Rm aws keys verification to allow for iam roles
This commit is contained in:
commit
2942dd301f
8
aws.go
8
aws.go
@ -28,8 +28,8 @@ type AWS struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAWS(p *Plugin) AWS {
|
func NewAWS(p *Plugin) AWS {
|
||||||
|
|
||||||
sessCfg := &aws.Config{
|
sessCfg := &aws.Config{
|
||||||
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),
|
||||||
}
|
}
|
||||||
@ -38,6 +38,12 @@ func NewAWS(p *Plugin) AWS {
|
|||||||
sessCfg.Endpoint = &p.Endpoint
|
sessCfg.Endpoint = &p.Endpoint
|
||||||
sessCfg.DisableSSL = aws.Bool(strings.HasPrefix(p.Endpoint, "http://"))
|
sessCfg.DisableSSL = aws.Bool(strings.HasPrefix(p.Endpoint, "http://"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allowing to use the instance role or provide a key and secret
|
||||||
|
if p.Key != "" && p.Secret != "" {
|
||||||
|
sessCfg.Credentials = credentials.NewStaticCredentials(p.Key, p.Secret, "")
|
||||||
|
}
|
||||||
|
|
||||||
sess := session.New(sessCfg)
|
sess := session.New(sessCfg)
|
||||||
|
|
||||||
c := s3.New(sess)
|
c := s3.New(sess)
|
||||||
|
@ -42,7 +42,7 @@ type result struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
var MissingAwsValuesMessage = "Must set access_key, secret_key, and bucket"
|
var MissingAwsValuesMessage = "Must set 'bucket'"
|
||||||
|
|
||||||
func (p *Plugin) Exec() error {
|
func (p *Plugin) Exec() error {
|
||||||
err := p.sanitizeInputs()
|
err := p.sanitizeInputs()
|
||||||
@ -61,7 +61,7 @@ func (p *Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) sanitizeInputs() error {
|
func (p *Plugin) sanitizeInputs() error {
|
||||||
if len(p.Key) == 0 || len(p.Secret) == 0 || len(p.Bucket) == 0 {
|
if len(p.Bucket) == 0 {
|
||||||
return errors.New(MissingAwsValuesMessage)
|
return errors.New(MissingAwsValuesMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user