remote/s3: Add support for ACL

This commit is contained in:
Radek Simko 2015-09-14 10:38:29 +01:00
parent 57bea9f26c
commit 3d77d158f7
1 changed files with 14 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"log"
"os"
"strconv"
@ -45,6 +46,11 @@ func s3Factory(conf map[string]string) (Client, error) {
serverSideEncryption = v
}
acl := ""
if raw, ok := conf["acl"]; ok {
acl = raw
}
accessKeyId := conf["access_key"]
secretAccessKey := conf["secret_key"]
@ -77,6 +83,7 @@ func s3Factory(conf map[string]string) (Client, error) {
bucketName: bucketName,
keyName: keyName,
serverSideEncryption: serverSideEncryption,
acl: acl,
}, nil
}
@ -85,6 +92,7 @@ type S3Client struct {
bucketName string
keyName string
serverSideEncryption bool
acl string
}
func (c *S3Client) Get() (*Payload, error) {
@ -140,6 +148,12 @@ func (c *S3Client) Put(data []byte) error {
i.ServerSideEncryption = aws.String("AES256")
}
if c.acl != "" {
i.ACL = aws.String(c.acl)
}
log.Printf("[DEBUG] Uploading remote state to S3: %#v", i)
if _, err := c.nativeClient.PutObject(i); err == nil {
return nil
} else {