forked from TrueCloudLab/rclone
Switch to using the dep tool and update all the dependencies
This commit is contained in:
parent
5135ff73cb
commit
98c2d2c41b
5321 changed files with 4483201 additions and 5922 deletions
46
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go
generated
vendored
46
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go
generated
vendored
|
@ -4,6 +4,7 @@ package rest
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -82,8 +83,12 @@ func buildLocationElements(r *request.Request, v reflect.Value, buildGETQuery bo
|
|||
if name == "" {
|
||||
name = field.Name
|
||||
}
|
||||
if m.Kind() == reflect.Ptr {
|
||||
if kind := m.Kind(); kind == reflect.Ptr {
|
||||
m = m.Elem()
|
||||
} else if kind == reflect.Interface {
|
||||
if !m.Elem().IsValid() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if !m.IsValid() {
|
||||
continue
|
||||
|
@ -95,16 +100,16 @@ func buildLocationElements(r *request.Request, v reflect.Value, buildGETQuery bo
|
|||
var err error
|
||||
switch field.Tag.Get("location") {
|
||||
case "headers": // header maps
|
||||
err = buildHeaderMap(&r.HTTPRequest.Header, m, field.Tag.Get("locationName"))
|
||||
err = buildHeaderMap(&r.HTTPRequest.Header, m, field.Tag)
|
||||
case "header":
|
||||
err = buildHeader(&r.HTTPRequest.Header, m, name)
|
||||
err = buildHeader(&r.HTTPRequest.Header, m, name, field.Tag)
|
||||
case "uri":
|
||||
err = buildURI(r.HTTPRequest.URL, m, name)
|
||||
err = buildURI(r.HTTPRequest.URL, m, name, field.Tag)
|
||||
case "querystring":
|
||||
err = buildQueryString(query, m, name)
|
||||
err = buildQueryString(query, m, name, field.Tag)
|
||||
default:
|
||||
if buildGETQuery {
|
||||
err = buildQueryString(query, m, name)
|
||||
err = buildQueryString(query, m, name, field.Tag)
|
||||
}
|
||||
}
|
||||
r.Error = err
|
||||
|
@ -145,8 +150,8 @@ func buildBody(r *request.Request, v reflect.Value) {
|
|||
}
|
||||
}
|
||||
|
||||
func buildHeader(header *http.Header, v reflect.Value, name string) error {
|
||||
str, err := convertType(v)
|
||||
func buildHeader(header *http.Header, v reflect.Value, name string, tag reflect.StructTag) error {
|
||||
str, err := convertType(v, tag)
|
||||
if err == errValueNotSet {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
|
@ -158,9 +163,10 @@ func buildHeader(header *http.Header, v reflect.Value, name string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func buildHeaderMap(header *http.Header, v reflect.Value, prefix string) error {
|
||||
func buildHeaderMap(header *http.Header, v reflect.Value, tag reflect.StructTag) error {
|
||||
prefix := tag.Get("locationName")
|
||||
for _, key := range v.MapKeys() {
|
||||
str, err := convertType(v.MapIndex(key))
|
||||
str, err := convertType(v.MapIndex(key), tag)
|
||||
if err == errValueNotSet {
|
||||
continue
|
||||
} else if err != nil {
|
||||
|
@ -173,8 +179,8 @@ func buildHeaderMap(header *http.Header, v reflect.Value, prefix string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func buildURI(u *url.URL, v reflect.Value, name string) error {
|
||||
value, err := convertType(v)
|
||||
func buildURI(u *url.URL, v reflect.Value, name string, tag reflect.StructTag) error {
|
||||
value, err := convertType(v, tag)
|
||||
if err == errValueNotSet {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
|
@ -190,7 +196,7 @@ func buildURI(u *url.URL, v reflect.Value, name string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func buildQueryString(query url.Values, v reflect.Value, name string) error {
|
||||
func buildQueryString(query url.Values, v reflect.Value, name string, tag reflect.StructTag) error {
|
||||
switch value := v.Interface().(type) {
|
||||
case []*string:
|
||||
for _, item := range value {
|
||||
|
@ -207,7 +213,7 @@ func buildQueryString(query url.Values, v reflect.Value, name string) error {
|
|||
}
|
||||
}
|
||||
default:
|
||||
str, err := convertType(v)
|
||||
str, err := convertType(v, tag)
|
||||
if err == errValueNotSet {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
|
@ -246,7 +252,7 @@ func EscapePath(path string, encodeSep bool) string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
func convertType(v reflect.Value) (string, error) {
|
||||
func convertType(v reflect.Value, tag reflect.StructTag) (string, error) {
|
||||
v = reflect.Indirect(v)
|
||||
if !v.IsValid() {
|
||||
return "", errValueNotSet
|
||||
|
@ -266,6 +272,16 @@ func convertType(v reflect.Value) (string, error) {
|
|||
str = strconv.FormatFloat(value, 'f', -1, 64)
|
||||
case time.Time:
|
||||
str = value.UTC().Format(RFC822)
|
||||
case aws.JSONValue:
|
||||
b, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if tag.Get("location") == "header" {
|
||||
str = base64.StdEncoding.EncodeToString(b)
|
||||
} else {
|
||||
str = string(b)
|
||||
}
|
||||
default:
|
||||
err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type())
|
||||
return "", err
|
||||
|
|
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build_test.go
generated
vendored
Normal file
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build_test.go
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
)
|
||||
|
||||
func TestCleanPath(t *testing.T) {
|
||||
uri := &url.URL{
|
||||
Path: "//foo//bar",
|
||||
Scheme: "https",
|
||||
Host: "host",
|
||||
}
|
||||
cleanPath(uri)
|
||||
|
||||
expected := "https://host/foo/bar"
|
||||
if a, e := uri.String(), expected; a != e {
|
||||
t.Errorf("expect %q URI, got %q", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalPath(t *testing.T) {
|
||||
in := struct {
|
||||
Bucket *string `location:"uri" locationName:"bucket"`
|
||||
Key *string `location:"uri" locationName:"key"`
|
||||
}{
|
||||
Bucket: aws.String("mybucket"),
|
||||
Key: aws.String("my/cool+thing space/object世界"),
|
||||
}
|
||||
|
||||
expectURL := `/mybucket/my/cool+thing space/object世界`
|
||||
expectEscapedURL := `/mybucket/my/cool%2Bthing%20space/object%E4%B8%96%E7%95%8C`
|
||||
|
||||
req := &request.Request{
|
||||
HTTPRequest: &http.Request{
|
||||
URL: &url.URL{Scheme: "https", Host: "exmaple.com", Path: "/{bucket}/{key+}"},
|
||||
},
|
||||
Params: &in,
|
||||
}
|
||||
|
||||
Build(req)
|
||||
|
||||
if req.Error != nil {
|
||||
t.Fatalf("unexpected error, %v", req.Error)
|
||||
}
|
||||
|
||||
if a, e := req.HTTPRequest.URL.Path, expectURL; a != e {
|
||||
t.Errorf("expect %q URI, got %q", e, a)
|
||||
}
|
||||
|
||||
if a, e := req.HTTPRequest.URL.RawPath, expectEscapedURL; a != e {
|
||||
t.Errorf("expect %q escaped URI, got %q", e, a)
|
||||
}
|
||||
|
||||
if a, e := req.HTTPRequest.URL.EscapedPath(), expectEscapedURL; a != e {
|
||||
t.Errorf("expect %q escaped URI, got %q", e, a)
|
||||
}
|
||||
|
||||
}
|
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/rest_test.go
generated
vendored
Normal file
63
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/rest_test.go
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
package rest_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/signer/v4"
|
||||
"github.com/aws/aws-sdk-go/awstesting/unit"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/rest"
|
||||
)
|
||||
|
||||
func TestUnsetHeaders(t *testing.T) {
|
||||
cfg := &aws.Config{Region: aws.String("us-west-2")}
|
||||
c := unit.Session.ClientConfig("testService", cfg)
|
||||
svc := client.New(
|
||||
*cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: "testService",
|
||||
SigningName: c.SigningName,
|
||||
SigningRegion: c.SigningRegion,
|
||||
Endpoint: c.Endpoint,
|
||||
APIVersion: "",
|
||||
},
|
||||
c.Handlers,
|
||||
)
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(rest.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(rest.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(rest.UnmarshalMetaHandler)
|
||||
op := &request.Operation{
|
||||
Name: "test-operation",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
input := &struct {
|
||||
Foo aws.JSONValue `location:"header" locationName:"x-amz-foo" type:"jsonvalue"`
|
||||
Bar aws.JSONValue `location:"header" locationName:"x-amz-bar" type:"jsonvalue"`
|
||||
}{}
|
||||
|
||||
output := &struct {
|
||||
Foo aws.JSONValue `location:"header" locationName:"x-amz-foo" type:"jsonvalue"`
|
||||
Bar aws.JSONValue `location:"header" locationName:"x-amz-bar" type:"jsonvalue"`
|
||||
}{}
|
||||
|
||||
req := svc.NewRequest(op, input, output)
|
||||
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(bytes.NewBuffer(nil)), Header: http.Header{}}
|
||||
req.HTTPResponse.Header.Set("X-Amz-Foo", "e30=")
|
||||
|
||||
// unmarshal response
|
||||
rest.UnmarshalMeta(req)
|
||||
rest.Unmarshal(req)
|
||||
if req.Error != nil {
|
||||
t.Fatal(req.Error)
|
||||
}
|
||||
}
|
29
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go
generated
vendored
29
vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go
generated
vendored
|
@ -3,6 +3,7 @@ package rest
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -12,6 +13,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
)
|
||||
|
@ -111,7 +113,7 @@ func unmarshalLocationElements(r *request.Request, v reflect.Value) {
|
|||
case "statusCode":
|
||||
unmarshalStatusCode(m, r.HTTPResponse.StatusCode)
|
||||
case "header":
|
||||
err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name))
|
||||
err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name), field.Tag)
|
||||
if err != nil {
|
||||
r.Error = awserr.New("SerializationError", "failed to decode REST response", err)
|
||||
break
|
||||
|
@ -158,8 +160,13 @@ func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) err
|
|||
return nil
|
||||
}
|
||||
|
||||
func unmarshalHeader(v reflect.Value, header string) error {
|
||||
if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) {
|
||||
func unmarshalHeader(v reflect.Value, header string, tag reflect.StructTag) error {
|
||||
isJSONValue := tag.Get("type") == "jsonvalue"
|
||||
if isJSONValue {
|
||||
if len(header) == 0 {
|
||||
return nil
|
||||
}
|
||||
} else if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -196,6 +203,22 @@ func unmarshalHeader(v reflect.Value, header string) error {
|
|||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(&t))
|
||||
case aws.JSONValue:
|
||||
b := []byte(header)
|
||||
var err error
|
||||
if tag.Get("location") == "header" {
|
||||
b, err = base64.StdEncoding.DecodeString(header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
m := aws.JSONValue{}
|
||||
err = json.Unmarshal(b, &m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(m))
|
||||
default:
|
||||
err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type())
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue