Updates goamz dependency from crowdmob->AdRoll

Also includes goamz PR #331 for s3 v4 auth + IAM role support
This commit is contained in:
Brian Bland 2015-02-02 11:03:20 -08:00
parent c41141fbd3
commit fb71af75c8
32 changed files with 123 additions and 45 deletions

24
Godeps/Godeps.json generated
View file

@ -10,6 +10,18 @@
"Comment": "null-12", "Comment": "null-12",
"Rev": "7dda39b2e7d5e265014674c5af696ba4186679e9" "Rev": "7dda39b2e7d5e265014674c5af696ba4186679e9"
}, },
{
"ImportPath": "github.com/AdRoll/goamz/aws",
"Rev": "d3664b76d90508cdda5a6c92042f26eab5db3103"
},
{
"ImportPath": "github.com/AdRoll/goamz/cloudfront",
"Rev": "d3664b76d90508cdda5a6c92042f26eab5db3103"
},
{
"ImportPath": "github.com/AdRoll/goamz/s3",
"Rev": "d3664b76d90508cdda5a6c92042f26eab5db3103"
},
{ {
"ImportPath": "github.com/Sirupsen/logrus", "ImportPath": "github.com/Sirupsen/logrus",
"Comment": "v0.6.1-8-gcc09837", "Comment": "v0.6.1-8-gcc09837",
@ -28,18 +40,6 @@
"ImportPath": "github.com/bugsnag/panicwrap", "ImportPath": "github.com/bugsnag/panicwrap",
"Rev": "e5f9854865b9778a45169fc249e99e338d4d6f27" "Rev": "e5f9854865b9778a45169fc249e99e338d4d6f27"
}, },
{
"ImportPath": "github.com/crowdmob/goamz/aws",
"Rev": "962cedbbde5e1af59fb0b4ab681c848e61676941"
},
{
"ImportPath": "github.com/crowdmob/goamz/cloudfront",
"Rev": "962cedbbde5e1af59fb0b4ab681c848e61676941"
},
{
"ImportPath": "github.com/crowdmob/goamz/s3",
"Rev": "962cedbbde5e1af59fb0b4ab681c848e61676941"
},
{ {
"ImportPath": "github.com/docker/docker/pkg/tarsum", "ImportPath": "github.com/docker/docker/pkg/tarsum",
"Comment": "v1.4.1-330-g3fbf723", "Comment": "v1.4.1-330-g3fbf723",

View file

@ -1,7 +1,7 @@
package aws_test package aws_test
import ( import (
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"gopkg.in/check.v1" "gopkg.in/check.v1"
"time" "time"
) )

View file

@ -1,7 +1,7 @@
package aws_test package aws_test
import ( import (
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"gopkg.in/check.v1" "gopkg.in/check.v1"
"io/ioutil" "io/ioutil"
"os" "os"

View file

@ -63,7 +63,7 @@ var USWest = Region{
ServiceInfo{"https://monitoring.us-west-1.amazonaws.com", V2Signature}, ServiceInfo{"https://monitoring.us-west-1.amazonaws.com", V2Signature},
"https://autoscaling.us-west-1.amazonaws.com", "https://autoscaling.us-west-1.amazonaws.com",
ServiceInfo{"https://rds.us-west-1.amazonaws.com", V2Signature}, ServiceInfo{"https://rds.us-west-1.amazonaws.com", V2Signature},
"", "https://kinesis.us-west-1.amazonaws.com",
"https://sts.amazonaws.com", "https://sts.amazonaws.com",
"https://cloudformation.us-west-1.amazonaws.com", "https://cloudformation.us-west-1.amazonaws.com",
"https://elasticache.us-west-1.amazonaws.com", "https://elasticache.us-west-1.amazonaws.com",

View file

@ -2,7 +2,7 @@ package aws_test
import ( import (
"fmt" "fmt"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"gopkg.in/check.v1" "gopkg.in/check.v1"
"net/http" "net/http"
"strings" "strings"

View file

@ -7,7 +7,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"

View file

@ -1,7 +1,7 @@
package s3 package s3
import ( import (
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
) )
var originalStrategy = attempts var originalStrategy = attempts

View file

@ -2,7 +2,7 @@ package s3_test
import ( import (
"encoding/xml" "encoding/xml"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"gopkg.in/check.v1" "gopkg.in/check.v1"
"io/ioutil" "io/ioutil"
"net/http" "net/http"

View file

@ -2,7 +2,7 @@ package s3_test
import ( import (
"encoding/xml" "encoding/xml"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"gopkg.in/check.v1" "gopkg.in/check.v1"
"io" "io"
"io/ioutil" "io/ioutil"
@ -21,7 +21,7 @@ func (s *S) TestInitMulti(c *check.C) {
Meta: metadata, Meta: metadata,
ContentEncoding: "text/utf8", ContentEncoding: "text/utf8",
CacheControl: "no-cache", CacheControl: "no-cache",
RedirectLocation: "http://github.com/crowdmob/goamz", RedirectLocation: "http://github.com/AdRoll/goamz",
ContentMD5: "0000000000000000", ContentMD5: "0000000000000000",
} }
@ -39,7 +39,7 @@ func (s *S) TestInitMulti(c *check.C) {
c.Assert(req.Header["Content-Encoding"], check.DeepEquals, []string{"text/utf8"}) c.Assert(req.Header["Content-Encoding"], check.DeepEquals, []string{"text/utf8"})
c.Assert(req.Header["Cache-Control"], check.DeepEquals, []string{"no-cache"}) c.Assert(req.Header["Cache-Control"], check.DeepEquals, []string{"no-cache"})
c.Assert(req.Header["Content-Md5"], check.DeepEquals, []string{"0000000000000000"}) c.Assert(req.Header["Content-Md5"], check.DeepEquals, []string{"0000000000000000"})
c.Assert(req.Header["X-Amz-Website-Redirect-Location"], check.DeepEquals, []string{"http://github.com/crowdmob/goamz"}) c.Assert(req.Header["X-Amz-Website-Redirect-Location"], check.DeepEquals, []string{"http://github.com/AdRoll/goamz"})
c.Assert(req.Header["X-Amz-Meta-Key1"], check.DeepEquals, []string{"value1"}) c.Assert(req.Header["X-Amz-Meta-Key1"], check.DeepEquals, []string{"value1"})
c.Assert(req.Header["X-Amz-Meta-Key2"], check.DeepEquals, []string{"value2"}) c.Assert(req.Header["X-Amz-Meta-Key2"], check.DeepEquals, []string{"value2"})

View file

@ -29,7 +29,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
) )
const debug = false const debug = false
@ -806,7 +806,7 @@ func (b *Bucket) SignedURLWithMethod(method, path string, expires time.Time, par
if err != nil { if err != nil {
panic(err) panic(err)
} }
if b.S3.Auth.Token() != "" { if b.S3.Auth.Token() != "" && b.S3.Signature == aws.V2Signature {
return u.String() + "&x-amz-security-token=" + url.QueryEscape(req.headers["X-Amz-Security-Token"][0]) return u.String() + "&x-amz-security-token=" + url.QueryEscape(req.headers["X-Amz-Security-Token"][0])
} else { } else {
return u.String() return u.String()
@ -1041,8 +1041,10 @@ func (s3 *S3) prepare(req *request) error {
} }
} }
if s3.Auth.Token() != "" { if s3.Signature == aws.V2Signature && s3.Auth.Token() != "" {
req.headers["X-Amz-Security-Token"] = []string{s3.Auth.Token()} req.headers["X-Amz-Security-Token"] = []string{s3.Auth.Token()}
} else if s3.Auth.Token() != "" {
req.params.Set("X-Amz-Security-Token", s3.Auth.Token())
} }
if s3.Signature == aws.V2Signature { if s3.Signature == aws.V2Signature {
@ -1233,6 +1235,19 @@ func shouldRetry(err error) bool {
case "read", "write": case "read", "write":
return true return true
} }
case *url.Error:
// url.Error can be returned either by net/url if a URL cannot be
// parsed, or by net/http if the response is closed before the headers
// are received or parsed correctly. In that later case, e.Op is set to
// the HTTP method name with the first letter uppercased. We don't want
// to retry on POST operations, since those are not idempotent, all the
// other ones should be safe to retry.
switch e.Op {
case "Get", "Put", "Delete", "Head":
return shouldRetry(e.Err)
default:
return false
}
case *Error: case *Error:
switch e.Code { switch e.Code {
case "InternalError", "NoSuchUpload", "NoSuchBucket": case "InternalError", "NoSuchUpload", "NoSuchBucket":

View file

@ -7,9 +7,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"github.com/crowdmob/goamz/testutil" "github.com/AdRoll/goamz/testutil"
"gopkg.in/check.v1" "gopkg.in/check.v1"
) )

View file

@ -4,9 +4,9 @@ import (
"bytes" "bytes"
"crypto/md5" "crypto/md5"
"fmt" "fmt"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"github.com/crowdmob/goamz/testutil" "github.com/AdRoll/goamz/testutil"
"gopkg.in/check.v1" "gopkg.in/check.v1"
"io/ioutil" "io/ioutil"
"net" "net"

View file

@ -1,9 +1,9 @@
package s3_test package s3_test
import ( import (
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"github.com/crowdmob/goamz/s3/s3test" "github.com/AdRoll/goamz/s3/s3test"
"gopkg.in/check.v1" "gopkg.in/check.v1"
) )

View file

@ -7,7 +7,7 @@ import (
"encoding/hex" "encoding/hex"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"io" "io"
"io/ioutil" "io/ioutil"
"log" "log"
@ -432,11 +432,74 @@ func (r bucketResource) put(a *action) interface{} {
return nil return nil
} }
func (bucketResource) post(a *action) interface{} { func (r bucketResource) post(a *action) interface{} {
fatalf(400, "Method", "bucket POST method not available") if _, multiDel := a.req.URL.Query()["delete"]; multiDel {
return r.multiDel(a)
}
fatalf(400, "Method", "bucket operation not supported")
return nil return nil
} }
func (b bucketResource) multiDel(a *action) interface{} {
type multiDelRequestObject struct {
Key string
VersionId string
}
type multiDelRequest struct {
Quiet bool
Object []*multiDelRequestObject
}
type multiDelDelete struct {
XMLName struct{} `xml:"Deleted"`
Key string
}
type multiDelError struct {
XMLName struct{} `xml:"Error"`
Key string
Code string
Message string
}
type multiDelResult struct {
XMLName struct{} `xml:"DeleteResult"`
Deleted []*multiDelDelete
Error []*multiDelError
}
req := &multiDelRequest{}
if err := xml.NewDecoder(a.req.Body).Decode(req); err != nil {
fatalf(400, "InvalidRequest", err.Error())
}
res := &multiDelResult{
Deleted: []*multiDelDelete{},
Error: []*multiDelError{},
}
for _, o := range req.Object {
if _, exists := b.bucket.objects[o.Key]; exists {
delete(b.bucket.objects, o.Key)
res.Deleted = append(res.Deleted, &multiDelDelete{
Key: o.Key,
})
} else {
res.Error = append(res.Error, &multiDelError{
Key: o.Key,
Code: "AccessDenied",
Message: "Access Denied",
})
}
}
return res
}
// validBucketName returns whether name is a valid bucket name. // validBucketName returns whether name is a valid bucket name.
// Here are the rules, from: // Here are the rules, from:
// http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/BucketRestrictions.html // http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/BucketRestrictions.html

View file

@ -4,7 +4,7 @@ import (
"crypto/hmac" "crypto/hmac"
"crypto/sha1" "crypto/sha1"
"encoding/base64" "encoding/base64"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"log" "log"
"sort" "sort"
"strings" "strings"

View file

@ -1,8 +1,8 @@
package s3_test package s3_test
import ( import (
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"gopkg.in/check.v1" "gopkg.in/check.v1"
) )

View file

@ -9,7 +9,7 @@ import (
"net/url" "net/url"
"time" "time"
"github.com/crowdmob/goamz/cloudfront" "github.com/AdRoll/goamz/cloudfront"
"github.com/docker/distribution/storagedriver" "github.com/docker/distribution/storagedriver"
) )

View file

@ -1,7 +1,7 @@
// Package s3 provides a storagedriver.StorageDriver implementation to // Package s3 provides a storagedriver.StorageDriver implementation to
// store blobs in Amazon S3 cloud storage. // store blobs in Amazon S3 cloud storage.
// //
// This package leverages the crowdmob/goamz client library for interfacing with // This package leverages the AdRoll/goamz client library for interfacing with
// s3. // s3.
// //
// Because s3 is a key, value store the Stat call does not support last modification // Because s3 is a key, value store the Stat call does not support last modification
@ -24,8 +24,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"github.com/crowdmob/goamz/s3" "github.com/AdRoll/goamz/s3"
"github.com/docker/distribution/storagedriver" "github.com/docker/distribution/storagedriver"
"github.com/docker/distribution/storagedriver/factory" "github.com/docker/distribution/storagedriver/factory"
) )

View file

@ -6,7 +6,7 @@ import (
"strconv" "strconv"
"testing" "testing"
"github.com/crowdmob/goamz/aws" "github.com/AdRoll/goamz/aws"
"github.com/docker/distribution/storagedriver" "github.com/docker/distribution/storagedriver"
"github.com/docker/distribution/storagedriver/testsuites" "github.com/docker/distribution/storagedriver/testsuites"