├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── circle.yml ├── main.go └── vendor ├── github.com ├── aws │ └── aws-sdk-go │ │ ├── CHANGELOG.md │ │ ├── CHANGELOG_PENDING.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE.txt │ │ ├── Makefile │ │ ├── NOTICE.txt │ │ ├── README.md │ │ ├── aws │ │ ├── awserr │ │ │ ├── error.go │ │ │ └── types.go │ │ ├── awsutil │ │ │ ├── copy.go │ │ │ ├── copy_test.go │ │ │ ├── equal.go │ │ │ ├── equal_test.go │ │ │ ├── path_value.go │ │ │ ├── path_value_test.go │ │ │ ├── prettify.go │ │ │ └── string_value.go │ │ ├── client │ │ │ ├── client.go │ │ │ ├── default_retryer.go │ │ │ └── metadata │ │ │ │ └── client_info.go │ │ ├── config.go │ │ ├── config_test.go │ │ ├── context.go │ │ ├── context_1_6.go │ │ ├── context_1_7.go │ │ ├── context_test.go │ │ ├── convert_types.go │ │ ├── convert_types_test.go │ │ ├── corehandlers │ │ │ ├── handlers.go │ │ │ ├── handlers_test.go │ │ │ ├── param_validator.go │ │ │ └── param_validator_test.go │ │ ├── credentials │ │ │ ├── chain_provider.go │ │ │ ├── chain_provider_test.go │ │ │ ├── credentials.go │ │ │ ├── credentials_test.go │ │ │ ├── ec2rolecreds │ │ │ │ ├── ec2_role_provider.go │ │ │ │ └── ec2_role_provider_test.go │ │ │ ├── endpointcreds │ │ │ │ ├── provider.go │ │ │ │ └── provider_test.go │ │ │ ├── env_provider.go │ │ │ ├── env_provider_test.go │ │ │ ├── example.ini │ │ │ ├── shared_credentials_provider.go │ │ │ ├── shared_credentials_provider_test.go │ │ │ ├── static_provider.go │ │ │ ├── static_provider_test.go │ │ │ └── stscreds │ │ │ │ ├── assume_role_provider.go │ │ │ │ └── assume_role_provider_test.go │ │ ├── defaults │ │ │ ├── defaults.go │ │ │ └── defaults_test.go │ │ ├── ec2metadata │ │ │ ├── api.go │ │ │ ├── api_test.go │ │ │ ├── service.go │ │ │ └── service_test.go │ │ ├── endpoints │ │ │ ├── decode.go │ │ │ ├── decode_test.go │ │ │ ├── defaults.go │ │ │ ├── doc.go │ │ │ ├── endpoints.go │ │ │ ├── endpoints_test.go │ │ │ ├── example_test.go │ │ │ ├── v3model.go │ │ │ ├── v3model_codegen.go │ │ │ └── v3model_test.go │ │ ├── errors.go │ │ ├── jsonvalue.go │ │ ├── logger.go │ │ ├── request │ │ │ ├── handlers.go │ │ │ ├── handlers_test.go │ │ │ ├── http_request.go │ │ │ ├── http_request_copy_test.go │ │ │ ├── http_request_retry_test.go │ │ │ ├── offset_reader.go │ │ │ ├── offset_reader_test.go │ │ │ ├── request.go │ │ │ ├── request_1_5_test.go │ │ │ ├── request_1_6_test.go │ │ │ ├── request_1_7.go │ │ │ ├── request_1_7_test.go │ │ │ ├── request_1_8.go │ │ │ ├── request_1_8_test.go │ │ │ ├── request_context.go │ │ │ ├── request_context_1_6.go │ │ │ ├── request_context_test.go │ │ │ ├── request_internal_test.go │ │ │ ├── request_pagination.go │ │ │ ├── request_pagination_test.go │ │ │ ├── request_resetbody_test.go │ │ │ ├── request_test.go │ │ │ ├── retryer.go │ │ │ ├── retryer_test.go │ │ │ ├── validation.go │ │ │ ├── waiter.go │ │ │ └── waiter_test.go │ │ ├── session │ │ │ ├── custom_ca_bundle_test.go │ │ │ ├── doc.go │ │ │ ├── env_config.go │ │ │ ├── env_config_test.go │ │ │ ├── session.go │ │ │ ├── session_test.go │ │ │ ├── shared_config.go │ │ │ ├── shared_config_test.go │ │ │ └── testdata │ │ │ │ ├── shared_config │ │ │ │ ├── shared_config_invalid_ini │ │ │ │ └── shared_config_other │ │ ├── signer │ │ │ └── v4 │ │ │ │ ├── functional_1_5_test.go │ │ │ │ ├── functional_test.go │ │ │ │ ├── header_rules.go │ │ │ │ ├── header_rules_test.go │ │ │ │ ├── options.go │ │ │ │ ├── uri_path.go │ │ │ │ ├── v4.go │ │ │ │ └── v4_test.go │ │ ├── types.go │ │ ├── types_test.go │ │ └── version.go │ │ ├── awstesting │ │ ├── assert.go │ │ ├── assert_test.go │ │ ├── client.go │ │ ├── mock │ │ │ └── mock.go │ │ ├── unit │ │ │ └── unit.go │ │ ├── util.go │ │ └── util_test.go │ │ ├── private │ │ ├── protocol │ │ │ ├── ec2query │ │ │ │ ├── build.go │ │ │ │ ├── build_bench_test.go │ │ │ │ ├── build_test.go │ │ │ │ ├── unmarshal.go │ │ │ │ └── unmarshal_test.go │ │ │ ├── idempotency.go │ │ │ ├── idempotency_test.go │ │ │ ├── json │ │ │ │ └── jsonutil │ │ │ │ │ ├── build.go │ │ │ │ │ ├── build_test.go │ │ │ │ │ └── unmarshal.go │ │ │ ├── jsonrpc │ │ │ │ ├── build_bench_test.go │ │ │ │ ├── build_test.go │ │ │ │ ├── jsonrpc.go │ │ │ │ └── unmarshal_test.go │ │ │ ├── protocol_test.go │ │ │ ├── query │ │ │ │ ├── build.go │ │ │ │ ├── build_test.go │ │ │ │ ├── queryutil │ │ │ │ │ └── queryutil.go │ │ │ │ ├── unmarshal.go │ │ │ │ ├── unmarshal_error.go │ │ │ │ └── unmarshal_test.go │ │ │ ├── rest │ │ │ │ ├── build.go │ │ │ │ ├── build_test.go │ │ │ │ ├── payload.go │ │ │ │ ├── rest_test.go │ │ │ │ └── unmarshal.go │ │ │ ├── restjson │ │ │ │ ├── build_bench_test.go │ │ │ │ ├── build_test.go │ │ │ │ ├── restjson.go │ │ │ │ └── unmarshal_test.go │ │ │ ├── restxml │ │ │ │ ├── build_bench_test.go │ │ │ │ ├── build_test.go │ │ │ │ ├── restxml.go │ │ │ │ └── unmarshal_test.go │ │ │ ├── unmarshal.go │ │ │ ├── unmarshal_test.go │ │ │ └── xml │ │ │ │ └── xmlutil │ │ │ │ ├── build.go │ │ │ │ ├── unmarshal.go │ │ │ │ ├── xml_to_struct.go │ │ │ │ └── xml_to_struct_test.go │ │ └── util │ │ │ ├── sort_keys.go │ │ │ └── util.go │ │ ├── sdk.go │ │ └── service │ │ ├── cloudfront │ │ ├── api.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ ├── service.go │ │ └── waiters.go │ │ ├── dynamodb │ │ ├── api.go │ │ ├── customizations.go │ │ ├── customizations_test.go │ │ ├── dynamodbattribute │ │ │ ├── converter.go │ │ │ ├── converter_examples_test.go │ │ │ ├── converter_test.go │ │ │ ├── decode.go │ │ │ ├── decode_test.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── encode_test.go │ │ │ ├── field.go │ │ │ ├── field_test.go │ │ │ ├── marshaler_examples_test.go │ │ │ ├── marshaler_test.go │ │ │ ├── shared_test.go │ │ │ ├── tag.go │ │ │ └── tag_test.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ ├── service.go │ │ └── waiters.go │ │ ├── ec2 │ │ ├── api.go │ │ ├── customizations.go │ │ ├── customizations_test.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ ├── service.go │ │ └── waiters.go │ │ ├── elastictranscoder │ │ ├── api.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ ├── service.go │ │ └── waiters.go │ │ ├── kinesis │ │ ├── api.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ ├── service.go │ │ └── waiters.go │ │ ├── route53 │ │ ├── api.go │ │ ├── customizations.go │ │ ├── customizations_test.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ ├── service.go │ │ ├── unmarshal_error.go │ │ ├── unmarshal_error_leak_test.go │ │ ├── unmarshal_error_test.go │ │ └── waiters.go │ │ ├── s3 │ │ ├── api.go │ │ ├── bucket_location.go │ │ ├── bucket_location_test.go │ │ ├── content_md5.go │ │ ├── customizations.go │ │ ├── customizations_test.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ ├── host_style_bucket.go │ │ ├── host_style_bucket_test.go │ │ ├── platform_handlers.go │ │ ├── platform_handlers_go1.6.go │ │ ├── platform_handlers_go1.6_test.go │ │ ├── service.go │ │ ├── sse.go │ │ ├── sse_test.go │ │ ├── statusok_error.go │ │ ├── statusok_error_test.go │ │ ├── unmarshal_error.go │ │ ├── unmarshal_error_leak_test.go │ │ ├── unmarshal_error_test.go │ │ └── waiters.go │ │ ├── sqs │ │ ├── api.go │ │ ├── api_test.go │ │ ├── checksums.go │ │ ├── checksums_test.go │ │ ├── customizations.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ └── service.go │ │ └── sts │ │ ├── api.go │ │ ├── customizations.go │ │ ├── customizations_test.go │ │ ├── errors.go │ │ ├── examples_test.go │ │ └── service.go ├── davecgh │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ ├── bypass.go │ │ ├── bypasssafe.go │ │ ├── common.go │ │ ├── config.go │ │ ├── doc.go │ │ ├── dump.go │ │ ├── format.go │ │ └── spew.go ├── go-ini │ └── ini │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── README_ZH.md │ │ ├── error.go │ │ ├── ini.go │ │ ├── ini_test.go │ │ ├── key.go │ │ ├── key_test.go │ │ ├── parser.go │ │ ├── parser_test.go │ │ ├── section.go │ │ ├── section_test.go │ │ ├── struct.go │ │ ├── struct_test.go │ │ └── testdata │ │ ├── UTF-16-BE-BOM.ini │ │ ├── UTF-16-LE-BOM.ini │ │ ├── UTF-8-BOM.ini │ │ ├── aicc.ini │ │ └── conf.ini ├── jmespath │ └── go-jmespath │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── api.go │ │ ├── api_test.go │ │ ├── astnodetype_string.go │ │ ├── compliance_test.go │ │ ├── functions.go │ │ ├── interpreter.go │ │ ├── interpreter_test.go │ │ ├── lexer.go │ │ ├── lexer_test.go │ │ ├── parser.go │ │ ├── parser_test.go │ │ ├── toktype_string.go │ │ ├── util.go │ │ └── util_test.go ├── pmezard │ └── go-difflib │ │ ├── LICENSE │ │ └── difflib │ │ └── difflib.go └── stretchr │ └── testify │ ├── LICENSE │ ├── assert │ ├── assertion_forward.go │ ├── assertion_forward.go.tmpl │ ├── assertions.go │ ├── assertions_test.go │ ├── doc.go │ ├── errors.go │ ├── forward_assertions.go │ ├── forward_assertions_test.go │ ├── http_assertions.go │ └── http_assertions_test.go │ └── require │ ├── doc.go │ ├── forward_requirements.go │ ├── forward_requirements_test.go │ ├── require.go │ ├── require.go.tmpl │ ├── require_forward.go │ ├── require_forward.go.tmpl │ ├── requirements.go │ └── requirements_test.go ├── gopkg.in └── yaml.v2 │ ├── LICENSE │ ├── LICENSE.libyaml │ ├── README.md │ ├── apic.go │ ├── decode.go │ ├── decode_test.go │ ├── emitterc.go │ ├── encode.go │ ├── encode_test.go │ ├── parserc.go │ ├── readerc.go │ ├── resolve.go │ ├── scannerc.go │ ├── sorter.go │ ├── suite_test.go │ ├── writerc.go │ ├── yaml.go │ ├── yamlh.go │ └── yamlprivateh.go └── vendor.json /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Remind101, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: test clean bin 2 | 3 | bin/assume-role: *.go 4 | go build -o $@ . 5 | 6 | bin: bin/assume-role-Linux bin/assume-role-Darwin bin/assume-role-Windows.exe 7 | 8 | bin/assume-role-Linux: *.go 9 | env GOOS=linux go build -o $@ . 10 | bin/assume-role-Darwin: *.go 11 | env GOOS=darwin go build -o $@ . 12 | bin/assume-role-Windows.exe: *.go 13 | env GOOS=windows go build -o $@ . 14 | 15 | clean: 16 | rm -rf bin/* 17 | 18 | test: 19 | go test -race $(shell go list ./... | grep -v /vendor/) 20 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | environment: 3 | GODIST: "go1.7.linux-amd64.tar.gz" 4 | post: 5 | - mkdir -p download 6 | - test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST 7 | - sudo rm -rf /usr/local/go 8 | - sudo tar -C /usr/local -xzf download/$GODIST 9 | - sudo ln -s /usr/local/go/bin/go /usr/bin/go 10 | - sudo go install -a -race std 11 | 12 | test: 13 | override: 14 | - make test 15 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/CHANGELOG_PENDING.md: -------------------------------------------------------------------------------- 1 | ### SDK Features 2 | 3 | ### SDK Enhancements 4 | 5 | ### SDK Bugs 6 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/NOTICE.txt: -------------------------------------------------------------------------------- 1 | AWS SDK for Go 2 | Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | Copyright 2014-2015 Stripe, Inc. 4 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "reflect" 5 | ) 6 | 7 | // DeepEqual returns if the two values are deeply equal like reflect.DeepEqual. 8 | // In addition to this, this method will also dereference the input values if 9 | // possible so the DeepEqual performed will not fail if one parameter is a 10 | // pointer and the other is not. 11 | // 12 | // DeepEqual will not perform indirection of nested values of the input parameters. 13 | func DeepEqual(a, b interface{}) bool { 14 | ra := reflect.Indirect(reflect.ValueOf(a)) 15 | rb := reflect.Indirect(reflect.ValueOf(b)) 16 | 17 | if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid { 18 | // If the elements are both nil, and of the same type the are equal 19 | // If they are of different types they are not equal 20 | return reflect.TypeOf(a) == reflect.TypeOf(b) 21 | } else if raValid != rbValid { 22 | // Both values must be valid to be equal 23 | return false 24 | } 25 | 26 | return reflect.DeepEqual(ra.Interface(), rb.Interface()) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal_test.go: -------------------------------------------------------------------------------- 1 | package awsutil_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/awsutil" 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestDeepEqual(t *testing.T) { 12 | cases := []struct { 13 | a, b interface{} 14 | equal bool 15 | }{ 16 | {"a", "a", true}, 17 | {"a", "b", false}, 18 | {"a", aws.String(""), false}, 19 | {"a", nil, false}, 20 | {"a", aws.String("a"), true}, 21 | {(*bool)(nil), (*bool)(nil), true}, 22 | {(*bool)(nil), (*string)(nil), false}, 23 | {nil, nil, true}, 24 | } 25 | 26 | for i, c := range cases { 27 | assert.Equal(t, c.equal, awsutil.DeepEqual(c.a, c.b), "%d, a:%v b:%v, %t", i, c.a, c.b, c.equal) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "reflect" 8 | "strings" 9 | ) 10 | 11 | // Prettify returns the string representation of a value. 12 | func Prettify(i interface{}) string { 13 | var buf bytes.Buffer 14 | prettify(reflect.ValueOf(i), 0, &buf) 15 | return buf.String() 16 | } 17 | 18 | // prettify will recursively walk value v to build a textual 19 | // representation of the value. 20 | func prettify(v reflect.Value, indent int, buf *bytes.Buffer) { 21 | for v.Kind() == reflect.Ptr { 22 | v = v.Elem() 23 | } 24 | 25 | switch v.Kind() { 26 | case reflect.Struct: 27 | strtype := v.Type().String() 28 | if strtype == "time.Time" { 29 | fmt.Fprintf(buf, "%s", v.Interface()) 30 | break 31 | } else if strings.HasPrefix(strtype, "io.") { 32 | buf.WriteString("") 33 | break 34 | } 35 | 36 | buf.WriteString("{\n") 37 | 38 | names := []string{} 39 | for i := 0; i < v.Type().NumField(); i++ { 40 | name := v.Type().Field(i).Name 41 | f := v.Field(i) 42 | if name[0:1] == strings.ToLower(name[0:1]) { 43 | continue // ignore unexported fields 44 | } 45 | if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() { 46 | continue // ignore unset fields 47 | } 48 | names = append(names, name) 49 | } 50 | 51 | for i, n := range names { 52 | val := v.FieldByName(n) 53 | buf.WriteString(strings.Repeat(" ", indent+2)) 54 | buf.WriteString(n + ": ") 55 | prettify(val, indent+2, buf) 56 | 57 | if i < len(names)-1 { 58 | buf.WriteString(",\n") 59 | } 60 | } 61 | 62 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 63 | case reflect.Slice: 64 | strtype := v.Type().String() 65 | if strtype == "[]uint8" { 66 | fmt.Fprintf(buf, " len %d", v.Len()) 67 | break 68 | } 69 | 70 | nl, id, id2 := "", "", "" 71 | if v.Len() > 3 { 72 | nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) 73 | } 74 | buf.WriteString("[" + nl) 75 | for i := 0; i < v.Len(); i++ { 76 | buf.WriteString(id2) 77 | prettify(v.Index(i), indent+2, buf) 78 | 79 | if i < v.Len()-1 { 80 | buf.WriteString("," + nl) 81 | } 82 | } 83 | 84 | buf.WriteString(nl + id + "]") 85 | case reflect.Map: 86 | buf.WriteString("{\n") 87 | 88 | for i, k := range v.MapKeys() { 89 | buf.WriteString(strings.Repeat(" ", indent+2)) 90 | buf.WriteString(k.String() + ": ") 91 | prettify(v.MapIndex(k), indent+2, buf) 92 | 93 | if i < v.Len()-1 { 94 | buf.WriteString(",\n") 95 | } 96 | } 97 | 98 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 99 | default: 100 | if !v.IsValid() { 101 | fmt.Fprint(buf, "") 102 | return 103 | } 104 | format := "%v" 105 | switch v.Interface().(type) { 106 | case string: 107 | format = "%q" 108 | case io.ReadSeeker, io.Reader: 109 | format = "buffer(%p)" 110 | } 111 | fmt.Fprintf(buf, format, v.Interface()) 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "reflect" 7 | "strings" 8 | ) 9 | 10 | // StringValue returns the string representation of a value. 11 | func StringValue(i interface{}) string { 12 | var buf bytes.Buffer 13 | stringValue(reflect.ValueOf(i), 0, &buf) 14 | return buf.String() 15 | } 16 | 17 | func stringValue(v reflect.Value, indent int, buf *bytes.Buffer) { 18 | for v.Kind() == reflect.Ptr { 19 | v = v.Elem() 20 | } 21 | 22 | switch v.Kind() { 23 | case reflect.Struct: 24 | buf.WriteString("{\n") 25 | 26 | names := []string{} 27 | for i := 0; i < v.Type().NumField(); i++ { 28 | name := v.Type().Field(i).Name 29 | f := v.Field(i) 30 | if name[0:1] == strings.ToLower(name[0:1]) { 31 | continue // ignore unexported fields 32 | } 33 | if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice) && f.IsNil() { 34 | continue // ignore unset fields 35 | } 36 | names = append(names, name) 37 | } 38 | 39 | for i, n := range names { 40 | val := v.FieldByName(n) 41 | buf.WriteString(strings.Repeat(" ", indent+2)) 42 | buf.WriteString(n + ": ") 43 | stringValue(val, indent+2, buf) 44 | 45 | if i < len(names)-1 { 46 | buf.WriteString(",\n") 47 | } 48 | } 49 | 50 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 51 | case reflect.Slice: 52 | nl, id, id2 := "", "", "" 53 | if v.Len() > 3 { 54 | nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) 55 | } 56 | buf.WriteString("[" + nl) 57 | for i := 0; i < v.Len(); i++ { 58 | buf.WriteString(id2) 59 | stringValue(v.Index(i), indent+2, buf) 60 | 61 | if i < v.Len()-1 { 62 | buf.WriteString("," + nl) 63 | } 64 | } 65 | 66 | buf.WriteString(nl + id + "]") 67 | case reflect.Map: 68 | buf.WriteString("{\n") 69 | 70 | for i, k := range v.MapKeys() { 71 | buf.WriteString(strings.Repeat(" ", indent+2)) 72 | buf.WriteString(k.String() + ": ") 73 | stringValue(v.MapIndex(k), indent+2, buf) 74 | 75 | if i < v.Len()-1 { 76 | buf.WriteString(",\n") 77 | } 78 | } 79 | 80 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 81 | default: 82 | format := "%v" 83 | switch v.Interface().(type) { 84 | case string: 85 | format = "%q" 86 | } 87 | fmt.Fprintf(buf, format, v.Interface()) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "math/rand" 5 | "sync" 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | ) 10 | 11 | // DefaultRetryer implements basic retry logic using exponential backoff for 12 | // most services. If you want to implement custom retry logic, implement the 13 | // request.Retryer interface or create a structure type that composes this 14 | // struct and override the specific methods. For example, to override only 15 | // the MaxRetries method: 16 | // 17 | // type retryer struct { 18 | // service.DefaultRetryer 19 | // } 20 | // 21 | // // This implementation always has 100 max retries 22 | // func (d retryer) MaxRetries() uint { return 100 } 23 | type DefaultRetryer struct { 24 | NumMaxRetries int 25 | } 26 | 27 | // MaxRetries returns the number of maximum returns the service will use to make 28 | // an individual API request. 29 | func (d DefaultRetryer) MaxRetries() int { 30 | return d.NumMaxRetries 31 | } 32 | 33 | var seededRand = rand.New(&lockedSource{src: rand.NewSource(time.Now().UnixNano())}) 34 | 35 | // RetryRules returns the delay duration before retrying this request again 36 | func (d DefaultRetryer) RetryRules(r *request.Request) time.Duration { 37 | // Set the upper limit of delay in retrying at ~five minutes 38 | minTime := 30 39 | throttle := d.shouldThrottle(r) 40 | if throttle { 41 | minTime = 500 42 | } 43 | 44 | retryCount := r.RetryCount 45 | if retryCount > 13 { 46 | retryCount = 13 47 | } else if throttle && retryCount > 8 { 48 | retryCount = 8 49 | } 50 | 51 | delay := (1 << uint(retryCount)) * (seededRand.Intn(minTime) + minTime) 52 | return time.Duration(delay) * time.Millisecond 53 | } 54 | 55 | // ShouldRetry returns true if the request should be retried. 56 | func (d DefaultRetryer) ShouldRetry(r *request.Request) bool { 57 | if r.HTTPResponse.StatusCode >= 500 { 58 | return true 59 | } 60 | return r.IsErrorRetryable() || d.shouldThrottle(r) 61 | } 62 | 63 | // ShouldThrottle returns true if the request should be throttled. 64 | func (d DefaultRetryer) shouldThrottle(r *request.Request) bool { 65 | if r.HTTPResponse.StatusCode == 502 || 66 | r.HTTPResponse.StatusCode == 503 || 67 | r.HTTPResponse.StatusCode == 504 { 68 | return true 69 | } 70 | return r.IsErrorThrottle() 71 | } 72 | 73 | // lockedSource is a thread-safe implementation of rand.Source 74 | type lockedSource struct { 75 | lk sync.Mutex 76 | src rand.Source 77 | } 78 | 79 | func (r *lockedSource) Int63() (n int64) { 80 | r.lk.Lock() 81 | n = r.src.Int63() 82 | r.lk.Unlock() 83 | return 84 | } 85 | 86 | func (r *lockedSource) Seed(seed int64) { 87 | r.lk.Lock() 88 | r.src.Seed(seed) 89 | r.lk.Unlock() 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | // ClientInfo wraps immutable data from the client.Client structure. 4 | type ClientInfo struct { 5 | ServiceName string 6 | APIVersion string 7 | Endpoint string 8 | SigningName string 9 | SigningRegion string 10 | JSONVersion string 11 | TargetPrefix string 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/config_test.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "net/http" 5 | "reflect" 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws/credentials" 9 | ) 10 | 11 | var testCredentials = credentials.NewStaticCredentials("AKID", "SECRET", "SESSION") 12 | 13 | var copyTestConfig = Config{ 14 | Credentials: testCredentials, 15 | Endpoint: String("CopyTestEndpoint"), 16 | Region: String("COPY_TEST_AWS_REGION"), 17 | DisableSSL: Bool(true), 18 | HTTPClient: http.DefaultClient, 19 | LogLevel: LogLevel(LogDebug), 20 | Logger: NewDefaultLogger(), 21 | MaxRetries: Int(3), 22 | DisableParamValidation: Bool(true), 23 | DisableComputeChecksums: Bool(true), 24 | S3ForcePathStyle: Bool(true), 25 | } 26 | 27 | func TestCopy(t *testing.T) { 28 | want := copyTestConfig 29 | got := copyTestConfig.Copy() 30 | if !reflect.DeepEqual(*got, want) { 31 | t.Errorf("Copy() = %+v", got) 32 | t.Errorf(" want %+v", want) 33 | } 34 | 35 | got.Region = String("other") 36 | if got.Region == want.Region { 37 | t.Errorf("Expect setting copy values not not reflect in source") 38 | } 39 | } 40 | 41 | func TestCopyReturnsNewInstance(t *testing.T) { 42 | want := copyTestConfig 43 | got := copyTestConfig.Copy() 44 | if got == &want { 45 | t.Errorf("Copy() = %p; want different instance as source %p", got, &want) 46 | } 47 | } 48 | 49 | var mergeTestZeroValueConfig = Config{} 50 | 51 | var mergeTestConfig = Config{ 52 | Credentials: testCredentials, 53 | Endpoint: String("MergeTestEndpoint"), 54 | Region: String("MERGE_TEST_AWS_REGION"), 55 | DisableSSL: Bool(true), 56 | HTTPClient: http.DefaultClient, 57 | LogLevel: LogLevel(LogDebug), 58 | Logger: NewDefaultLogger(), 59 | MaxRetries: Int(10), 60 | DisableParamValidation: Bool(true), 61 | DisableComputeChecksums: Bool(true), 62 | S3ForcePathStyle: Bool(true), 63 | } 64 | 65 | var mergeTests = []struct { 66 | cfg *Config 67 | in *Config 68 | want *Config 69 | }{ 70 | {&Config{}, nil, &Config{}}, 71 | {&Config{}, &mergeTestZeroValueConfig, &Config{}}, 72 | {&Config{}, &mergeTestConfig, &mergeTestConfig}, 73 | } 74 | 75 | func TestMerge(t *testing.T) { 76 | for i, tt := range mergeTests { 77 | got := tt.cfg.Copy() 78 | got.MergeIn(tt.in) 79 | if !reflect.DeepEqual(got, tt.want) { 80 | t.Errorf("Config %d %+v", i, tt.cfg) 81 | t.Errorf(" Merge(%+v)", tt.in) 82 | t.Errorf(" got %+v", got) 83 | t.Errorf(" want %+v", tt.want) 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // Context is an copy of the Go v1.7 stdlib's context.Context interface. 8 | // It is represented as a SDK interface to enable you to use the "WithContext" 9 | // API methods with Go v1.6 and a Context type such as golang.org/x/net/context. 10 | // 11 | // See https://golang.org/pkg/context on how to use contexts. 12 | type Context interface { 13 | // Deadline returns the time when work done on behalf of this context 14 | // should be canceled. Deadline returns ok==false when no deadline is 15 | // set. Successive calls to Deadline return the same results. 16 | Deadline() (deadline time.Time, ok bool) 17 | 18 | // Done returns a channel that's closed when work done on behalf of this 19 | // context should be canceled. Done may return nil if this context can 20 | // never be canceled. Successive calls to Done return the same value. 21 | Done() <-chan struct{} 22 | 23 | // Err returns a non-nil error value after Done is closed. Err returns 24 | // Canceled if the context was canceled or DeadlineExceeded if the 25 | // context's deadline passed. No other values for Err are defined. 26 | // After Done is closed, successive calls to Err return the same value. 27 | Err() error 28 | 29 | // Value returns the value associated with this context for key, or nil 30 | // if no value is associated with key. Successive calls to Value with 31 | // the same key returns the same result. 32 | // 33 | // Use context values only for request-scoped data that transits 34 | // processes and API boundaries, not for passing optional parameters to 35 | // functions. 36 | Value(key interface{}) interface{} 37 | } 38 | 39 | // BackgroundContext returns a context that will never be canceled, has no 40 | // values, and no deadline. This context is used by the SDK to provide 41 | // backwards compatibility with non-context API operations and functionality. 42 | // 43 | // Go 1.6 and before: 44 | // This context function is equivalent to context.Background in the Go stdlib. 45 | // 46 | // Go 1.7 and later: 47 | // The context returned will be the value returned by context.Background() 48 | // 49 | // See https://golang.org/pkg/context for more information on Contexts. 50 | func BackgroundContext() Context { 51 | return backgroundCtx 52 | } 53 | 54 | // SleepWithContext will wait for the timer duration to expire, or the context 55 | // is canceled. Which ever happens first. If the context is canceled the Context's 56 | // error will be returned. 57 | // 58 | // Expects Context to always return a non-nil error if the Done channel is closed. 59 | func SleepWithContext(ctx Context, dur time.Duration) error { 60 | t := time.NewTimer(dur) 61 | defer t.Stop() 62 | 63 | select { 64 | case <-t.C: 65 | break 66 | case <-ctx.Done(): 67 | return ctx.Err() 68 | } 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_1_6.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package aws 4 | 5 | import "time" 6 | 7 | // An emptyCtx is a copy of the the Go 1.7 context.emptyCtx type. This 8 | // is copied to provide a 1.6 and 1.5 safe version of context that is compatible 9 | // with Go 1.7's Context. 10 | // 11 | // An emptyCtx is never canceled, has no values, and has no deadline. It is not 12 | // struct{}, since vars of this type must have distinct addresses. 13 | type emptyCtx int 14 | 15 | func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { 16 | return 17 | } 18 | 19 | func (*emptyCtx) Done() <-chan struct{} { 20 | return nil 21 | } 22 | 23 | func (*emptyCtx) Err() error { 24 | return nil 25 | } 26 | 27 | func (*emptyCtx) Value(key interface{}) interface{} { 28 | return nil 29 | } 30 | 31 | func (e *emptyCtx) String() string { 32 | switch e { 33 | case backgroundCtx: 34 | return "aws.BackgroundContext" 35 | } 36 | return "unknown empty Context" 37 | } 38 | 39 | var ( 40 | backgroundCtx = new(emptyCtx) 41 | ) 42 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_1_7.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package aws 4 | 5 | import "context" 6 | 7 | var ( 8 | backgroundCtx = context.Background() 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_test.go: -------------------------------------------------------------------------------- 1 | package aws_test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/awstesting" 10 | ) 11 | 12 | func TestSleepWithContext(t *testing.T) { 13 | ctx := &awstesting.FakeContext{DoneCh: make(chan struct{})} 14 | 15 | err := aws.SleepWithContext(ctx, 1*time.Millisecond) 16 | if err != nil { 17 | t.Errorf("expect context to not be canceled, got %v", err) 18 | } 19 | } 20 | 21 | func TestSleepWithContext_Canceled(t *testing.T) { 22 | ctx := &awstesting.FakeContext{DoneCh: make(chan struct{})} 23 | 24 | expectErr := fmt.Errorf("context canceled") 25 | 26 | ctx.Error = expectErr 27 | close(ctx.DoneCh) 28 | 29 | err := aws.SleepWithContext(ctx, 1*time.Millisecond) 30 | if err == nil { 31 | t.Fatalf("expect error, did not get one") 32 | } 33 | 34 | if e, a := expectErr, err; e != a { 35 | t.Errorf("expect %v error, got %v", e, a) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/corehandlers/param_validator.go: -------------------------------------------------------------------------------- 1 | package corehandlers 2 | 3 | import "github.com/aws/aws-sdk-go/aws/request" 4 | 5 | // ValidateParametersHandler is a request handler to validate the input parameters. 6 | // Validating parameters only has meaning if done prior to the request being sent. 7 | var ValidateParametersHandler = request.NamedHandler{Name: "core.ValidateParametersHandler", Fn: func(r *request.Request) { 8 | if !r.ParamsFilled() { 9 | return 10 | } 11 | 12 | if v, ok := r.Params.(request.Validator); ok { 13 | if err := v.Validate(); err != nil { 14 | r.Error = err 15 | } 16 | } 17 | }} 18 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/credentials_test.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/aws/aws-sdk-go/aws/awserr" 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | type stubProvider struct { 11 | creds Value 12 | expired bool 13 | err error 14 | } 15 | 16 | func (s *stubProvider) Retrieve() (Value, error) { 17 | s.expired = false 18 | s.creds.ProviderName = "stubProvider" 19 | return s.creds, s.err 20 | } 21 | func (s *stubProvider) IsExpired() bool { 22 | return s.expired 23 | } 24 | 25 | func TestCredentialsGet(t *testing.T) { 26 | c := NewCredentials(&stubProvider{ 27 | creds: Value{ 28 | AccessKeyID: "AKID", 29 | SecretAccessKey: "SECRET", 30 | SessionToken: "", 31 | }, 32 | expired: true, 33 | }) 34 | 35 | creds, err := c.Get() 36 | assert.Nil(t, err, "Expected no error") 37 | assert.Equal(t, "AKID", creds.AccessKeyID, "Expect access key ID to match") 38 | assert.Equal(t, "SECRET", creds.SecretAccessKey, "Expect secret access key to match") 39 | assert.Empty(t, creds.SessionToken, "Expect session token to be empty") 40 | } 41 | 42 | func TestCredentialsGetWithError(t *testing.T) { 43 | c := NewCredentials(&stubProvider{err: awserr.New("provider error", "", nil), expired: true}) 44 | 45 | _, err := c.Get() 46 | assert.Equal(t, "provider error", err.(awserr.Error).Code(), "Expected provider error") 47 | } 48 | 49 | func TestCredentialsExpire(t *testing.T) { 50 | stub := &stubProvider{} 51 | c := NewCredentials(stub) 52 | 53 | stub.expired = false 54 | assert.True(t, c.IsExpired(), "Expected to start out expired") 55 | c.Expire() 56 | assert.True(t, c.IsExpired(), "Expected to be expired") 57 | 58 | c.forceRefresh = false 59 | assert.False(t, c.IsExpired(), "Expected not to be expired") 60 | 61 | stub.expired = true 62 | assert.True(t, c.IsExpired(), "Expected to be expired") 63 | } 64 | 65 | func TestCredentialsGetWithProviderName(t *testing.T) { 66 | stub := &stubProvider{} 67 | 68 | c := NewCredentials(stub) 69 | 70 | creds, err := c.Get() 71 | assert.Nil(t, err, "Expected no error") 72 | assert.Equal(t, creds.ProviderName, "stubProvider", "Expected provider name to match") 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/aws/aws-sdk-go/aws/awserr" 7 | ) 8 | 9 | // EnvProviderName provides a name of Env provider 10 | const EnvProviderName = "EnvProvider" 11 | 12 | var ( 13 | // ErrAccessKeyIDNotFound is returned when the AWS Access Key ID can't be 14 | // found in the process's environment. 15 | // 16 | // @readonly 17 | ErrAccessKeyIDNotFound = awserr.New("EnvAccessKeyNotFound", "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment", nil) 18 | 19 | // ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key 20 | // can't be found in the process's environment. 21 | // 22 | // @readonly 23 | ErrSecretAccessKeyNotFound = awserr.New("EnvSecretNotFound", "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment", nil) 24 | ) 25 | 26 | // A EnvProvider retrieves credentials from the environment variables of the 27 | // running process. Environment credentials never expire. 28 | // 29 | // Environment variables used: 30 | // 31 | // * Access Key ID: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY 32 | // * Secret Access Key: AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY 33 | type EnvProvider struct { 34 | retrieved bool 35 | } 36 | 37 | // NewEnvCredentials returns a pointer to a new Credentials object 38 | // wrapping the environment variable provider. 39 | func NewEnvCredentials() *Credentials { 40 | return NewCredentials(&EnvProvider{}) 41 | } 42 | 43 | // Retrieve retrieves the keys from the environment. 44 | func (e *EnvProvider) Retrieve() (Value, error) { 45 | e.retrieved = false 46 | 47 | id := os.Getenv("AWS_ACCESS_KEY_ID") 48 | if id == "" { 49 | id = os.Getenv("AWS_ACCESS_KEY") 50 | } 51 | 52 | secret := os.Getenv("AWS_SECRET_ACCESS_KEY") 53 | if secret == "" { 54 | secret = os.Getenv("AWS_SECRET_KEY") 55 | } 56 | 57 | if id == "" { 58 | return Value{ProviderName: EnvProviderName}, ErrAccessKeyIDNotFound 59 | } 60 | 61 | if secret == "" { 62 | return Value{ProviderName: EnvProviderName}, ErrSecretAccessKeyNotFound 63 | } 64 | 65 | e.retrieved = true 66 | return Value{ 67 | AccessKeyID: id, 68 | SecretAccessKey: secret, 69 | SessionToken: os.Getenv("AWS_SESSION_TOKEN"), 70 | ProviderName: EnvProviderName, 71 | }, nil 72 | } 73 | 74 | // IsExpired returns if the credentials have been retrieved. 75 | func (e *EnvProvider) IsExpired() bool { 76 | return !e.retrieved 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider_test.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "os" 6 | "testing" 7 | ) 8 | 9 | func TestEnvProviderRetrieve(t *testing.T) { 10 | os.Clearenv() 11 | os.Setenv("AWS_ACCESS_KEY_ID", "access") 12 | os.Setenv("AWS_SECRET_ACCESS_KEY", "secret") 13 | os.Setenv("AWS_SESSION_TOKEN", "token") 14 | 15 | e := EnvProvider{} 16 | creds, err := e.Retrieve() 17 | assert.Nil(t, err, "Expect no error") 18 | 19 | assert.Equal(t, "access", creds.AccessKeyID, "Expect access key ID to match") 20 | assert.Equal(t, "secret", creds.SecretAccessKey, "Expect secret access key to match") 21 | assert.Equal(t, "token", creds.SessionToken, "Expect session token to match") 22 | } 23 | 24 | func TestEnvProviderIsExpired(t *testing.T) { 25 | os.Clearenv() 26 | os.Setenv("AWS_ACCESS_KEY_ID", "access") 27 | os.Setenv("AWS_SECRET_ACCESS_KEY", "secret") 28 | os.Setenv("AWS_SESSION_TOKEN", "token") 29 | 30 | e := EnvProvider{} 31 | 32 | assert.True(t, e.IsExpired(), "Expect creds to be expired before retrieve.") 33 | 34 | _, err := e.Retrieve() 35 | assert.Nil(t, err, "Expect no error") 36 | 37 | assert.False(t, e.IsExpired(), "Expect creds to not be expired after retrieve.") 38 | } 39 | 40 | func TestEnvProviderNoAccessKeyID(t *testing.T) { 41 | os.Clearenv() 42 | os.Setenv("AWS_SECRET_ACCESS_KEY", "secret") 43 | 44 | e := EnvProvider{} 45 | creds, err := e.Retrieve() 46 | assert.Equal(t, ErrAccessKeyIDNotFound, err, "ErrAccessKeyIDNotFound expected, but was %#v error: %#v", creds, err) 47 | } 48 | 49 | func TestEnvProviderNoSecretAccessKey(t *testing.T) { 50 | os.Clearenv() 51 | os.Setenv("AWS_ACCESS_KEY_ID", "access") 52 | 53 | e := EnvProvider{} 54 | creds, err := e.Retrieve() 55 | assert.Equal(t, ErrSecretAccessKeyNotFound, err, "ErrSecretAccessKeyNotFound expected, but was %#v error: %#v", creds, err) 56 | } 57 | 58 | func TestEnvProviderAlternateNames(t *testing.T) { 59 | os.Clearenv() 60 | os.Setenv("AWS_ACCESS_KEY", "access") 61 | os.Setenv("AWS_SECRET_KEY", "secret") 62 | 63 | e := EnvProvider{} 64 | creds, err := e.Retrieve() 65 | assert.Nil(t, err, "Expect no error") 66 | 67 | assert.Equal(t, "access", creds.AccessKeyID, "Expected access key ID") 68 | assert.Equal(t, "secret", creds.SecretAccessKey, "Expected secret access key") 69 | assert.Empty(t, creds.SessionToken, "Expected no token") 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/example.ini: -------------------------------------------------------------------------------- 1 | [default] 2 | aws_access_key_id = accessKey 3 | aws_secret_access_key = secret 4 | aws_session_token = token 5 | 6 | [no_token] 7 | aws_access_key_id = accessKey 8 | aws_secret_access_key = secret 9 | 10 | [with_colon] 11 | aws_access_key_id: accessKey 12 | aws_secret_access_key: secret 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "github.com/aws/aws-sdk-go/aws/awserr" 5 | ) 6 | 7 | // StaticProviderName provides a name of Static provider 8 | const StaticProviderName = "StaticProvider" 9 | 10 | var ( 11 | // ErrStaticCredentialsEmpty is emitted when static credentials are empty. 12 | // 13 | // @readonly 14 | ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil) 15 | ) 16 | 17 | // A StaticProvider is a set of credentials which are set programmatically, 18 | // and will never expire. 19 | type StaticProvider struct { 20 | Value 21 | } 22 | 23 | // NewStaticCredentials returns a pointer to a new Credentials object 24 | // wrapping a static credentials value provider. 25 | func NewStaticCredentials(id, secret, token string) *Credentials { 26 | return NewCredentials(&StaticProvider{Value: Value{ 27 | AccessKeyID: id, 28 | SecretAccessKey: secret, 29 | SessionToken: token, 30 | }}) 31 | } 32 | 33 | // NewStaticCredentialsFromCreds returns a pointer to a new Credentials object 34 | // wrapping the static credentials value provide. Same as NewStaticCredentials 35 | // but takes the creds Value instead of individual fields 36 | func NewStaticCredentialsFromCreds(creds Value) *Credentials { 37 | return NewCredentials(&StaticProvider{Value: creds}) 38 | } 39 | 40 | // Retrieve returns the credentials or error if the credentials are invalid. 41 | func (s *StaticProvider) Retrieve() (Value, error) { 42 | if s.AccessKeyID == "" || s.SecretAccessKey == "" { 43 | return Value{ProviderName: StaticProviderName}, ErrStaticCredentialsEmpty 44 | } 45 | 46 | if len(s.Value.ProviderName) == 0 { 47 | s.Value.ProviderName = StaticProviderName 48 | } 49 | return s.Value, nil 50 | } 51 | 52 | // IsExpired returns if the credentials are expired. 53 | // 54 | // For StaticProvider, the credentials never expired. 55 | func (s *StaticProvider) IsExpired() bool { 56 | return false 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider_test.go: -------------------------------------------------------------------------------- 1 | package credentials 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestStaticProviderGet(t *testing.T) { 9 | s := StaticProvider{ 10 | Value: Value{ 11 | AccessKeyID: "AKID", 12 | SecretAccessKey: "SECRET", 13 | SessionToken: "", 14 | }, 15 | } 16 | 17 | creds, err := s.Retrieve() 18 | assert.Nil(t, err, "Expect no error") 19 | assert.Equal(t, "AKID", creds.AccessKeyID, "Expect access key ID to match") 20 | assert.Equal(t, "SECRET", creds.SecretAccessKey, "Expect secret access key to match") 21 | assert.Empty(t, creds.SessionToken, "Expect no session token") 22 | } 23 | 24 | func TestStaticProviderIsExpired(t *testing.T) { 25 | s := StaticProvider{ 26 | Value: Value{ 27 | AccessKeyID: "AKID", 28 | SecretAccessKey: "SECRET", 29 | SessionToken: "", 30 | }, 31 | } 32 | 33 | assert.False(t, s.IsExpired(), "Expect static credentials to never expire") 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/defaults/defaults_test.go: -------------------------------------------------------------------------------- 1 | package defaults 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" 10 | "github.com/aws/aws-sdk-go/aws/credentials/endpointcreds" 11 | "github.com/aws/aws-sdk-go/aws/request" 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | func TestECSCredProvider(t *testing.T) { 16 | defer os.Clearenv() 17 | os.Setenv("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI", "/abc/123") 18 | 19 | provider := RemoteCredProvider(aws.Config{}, request.Handlers{}) 20 | 21 | assert.NotNil(t, provider) 22 | 23 | ecsProvider, ok := provider.(*endpointcreds.Provider) 24 | assert.NotNil(t, ecsProvider) 25 | assert.True(t, ok) 26 | 27 | assert.Equal(t, fmt.Sprintf("http://169.254.170.2/abc/123"), 28 | ecsProvider.Client.Endpoint) 29 | } 30 | 31 | func TestDefaultEC2RoleProvider(t *testing.T) { 32 | provider := RemoteCredProvider(aws.Config{}, request.Handlers{}) 33 | 34 | assert.NotNil(t, provider) 35 | 36 | ec2Provider, ok := provider.(*ec2rolecreds.EC2RoleProvider) 37 | assert.NotNil(t, ec2Provider) 38 | assert.True(t, ok) 39 | 40 | fmt.Println(ec2Provider.Client.Endpoint) 41 | 42 | assert.Equal(t, fmt.Sprintf("http://169.254.169.254/latest"), 43 | ec2Provider.Client.Endpoint) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service_test.go: -------------------------------------------------------------------------------- 1 | package ec2metadata_test 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "sync" 7 | "testing" 8 | "time" 9 | 10 | "github.com/aws/aws-sdk-go/aws" 11 | "github.com/aws/aws-sdk-go/aws/ec2metadata" 12 | "github.com/aws/aws-sdk-go/awstesting/unit" 13 | "github.com/stretchr/testify/assert" 14 | ) 15 | 16 | func TestClientOverrideDefaultHTTPClientTimeout(t *testing.T) { 17 | svc := ec2metadata.New(unit.Session) 18 | 19 | assert.NotEqual(t, http.DefaultClient, svc.Config.HTTPClient) 20 | assert.Equal(t, 5*time.Second, svc.Config.HTTPClient.Timeout) 21 | } 22 | 23 | func TestClientNotOverrideDefaultHTTPClientTimeout(t *testing.T) { 24 | http.DefaultClient.Transport = &http.Transport{} 25 | defer func() { 26 | http.DefaultClient.Transport = nil 27 | }() 28 | 29 | svc := ec2metadata.New(unit.Session) 30 | 31 | assert.Equal(t, http.DefaultClient, svc.Config.HTTPClient) 32 | 33 | tr, ok := svc.Config.HTTPClient.Transport.(*http.Transport) 34 | assert.True(t, ok) 35 | assert.NotNil(t, tr) 36 | assert.Nil(t, tr.Dial) 37 | } 38 | 39 | func TestClientDisableOverrideDefaultHTTPClientTimeout(t *testing.T) { 40 | svc := ec2metadata.New(unit.Session, aws.NewConfig().WithEC2MetadataDisableTimeoutOverride(true)) 41 | 42 | assert.Equal(t, http.DefaultClient, svc.Config.HTTPClient) 43 | } 44 | 45 | func TestClientOverrideDefaultHTTPClientTimeoutRace(t *testing.T) { 46 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 47 | w.Write([]byte("us-east-1a")) 48 | })) 49 | 50 | cfg := aws.NewConfig().WithEndpoint(server.URL) 51 | runEC2MetadataClients(t, cfg, 100) 52 | } 53 | 54 | func TestClientOverrideDefaultHTTPClientTimeoutRaceWithTransport(t *testing.T) { 55 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 56 | w.Write([]byte("us-east-1a")) 57 | })) 58 | 59 | cfg := aws.NewConfig().WithEndpoint(server.URL).WithHTTPClient(&http.Client{ 60 | Transport: http.DefaultTransport, 61 | }) 62 | 63 | runEC2MetadataClients(t, cfg, 100) 64 | } 65 | 66 | func runEC2MetadataClients(t *testing.T, cfg *aws.Config, atOnce int) { 67 | var wg sync.WaitGroup 68 | wg.Add(atOnce) 69 | for i := 0; i < atOnce; i++ { 70 | go func() { 71 | svc := ec2metadata.New(unit.Session, cfg) 72 | _, err := svc.Region() 73 | assert.NoError(t, err) 74 | wg.Done() 75 | }() 76 | } 77 | wg.Wait() 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/endpoints/decode_test.go: -------------------------------------------------------------------------------- 1 | package endpoints 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | ) 7 | 8 | func TestDecodeEndpoints_V3(t *testing.T) { 9 | const v3Doc = ` 10 | { 11 | "version": 3, 12 | "partitions": [ 13 | { 14 | "defaults": { 15 | "hostname": "{service}.{region}.{dnsSuffix}", 16 | "protocols": [ 17 | "https" 18 | ], 19 | "signatureVersions": [ 20 | "v4" 21 | ] 22 | }, 23 | "dnsSuffix": "amazonaws.com", 24 | "partition": "aws", 25 | "partitionName": "AWS Standard", 26 | "regionRegex": "^(us|eu|ap|sa|ca)\\-\\w+\\-\\d+$", 27 | "regions": { 28 | "ap-northeast-1": { 29 | "description": "Asia Pacific (Tokyo)" 30 | } 31 | }, 32 | "services": { 33 | "acm": { 34 | "endpoints": { 35 | "ap-northeast-1": {} 36 | } 37 | }, 38 | "s3": { 39 | "endpoints": { 40 | "ap-northeast-1": {} 41 | } 42 | } 43 | } 44 | } 45 | ] 46 | }` 47 | 48 | resolver, err := DecodeModel(strings.NewReader(v3Doc)) 49 | if err != nil { 50 | t.Fatalf("expected no error, got %v", err) 51 | } 52 | 53 | endpoint, err := resolver.EndpointFor("acm", "ap-northeast-1") 54 | if err != nil { 55 | t.Fatalf("failed to resolve endpoint, %v", err) 56 | } 57 | 58 | if a, e := endpoint.URL, "https://acm.ap-northeast-1.amazonaws.com"; a != e { 59 | t.Errorf("expected %q URL got %q", e, a) 60 | } 61 | 62 | p := resolver.(partitions)[0] 63 | 64 | s3Defaults := p.Services["s3"].Defaults 65 | if a, e := s3Defaults.HasDualStack, boxedTrue; a != e { 66 | t.Errorf("expect s3 service to have dualstack enabled") 67 | } 68 | if a, e := s3Defaults.DualStackHostname, "{service}.dualstack.{region}.{dnsSuffix}"; a != e { 69 | t.Errorf("expect s3 dualstack host pattern to be %q, got %q", e, a) 70 | } 71 | 72 | ec2metaEndpoint := p.Services["ec2metadata"].Endpoints["aws-global"] 73 | if a, e := ec2metaEndpoint.Hostname, "169.254.169.254/latest"; a != e { 74 | t.Errorf("expect ec2metadata host to be %q, got %q", e, a) 75 | } 76 | } 77 | 78 | func TestDecodeEndpoints_NoPartitions(t *testing.T) { 79 | const doc = `{ "version": 3 }` 80 | 81 | resolver, err := DecodeModel(strings.NewReader(doc)) 82 | if err == nil { 83 | t.Fatalf("expected error") 84 | } 85 | 86 | if resolver != nil { 87 | t.Errorf("expect resolver to be nil") 88 | } 89 | } 90 | 91 | func TestDecodeEndpoints_UnsupportedVersion(t *testing.T) { 92 | const doc = `{ "version": 2 }` 93 | 94 | resolver, err := DecodeModel(strings.NewReader(doc)) 95 | if err == nil { 96 | t.Fatalf("expected error decoding model") 97 | } 98 | 99 | if resolver != nil { 100 | t.Errorf("expect resolver to be nil") 101 | } 102 | } 103 | 104 | func TestDecodeModelOptionsSet(t *testing.T) { 105 | var actual DecodeModelOptions 106 | actual.Set(func(o *DecodeModelOptions) { 107 | o.SkipCustomizations = true 108 | }) 109 | 110 | expect := DecodeModelOptions{ 111 | SkipCustomizations: true, 112 | } 113 | 114 | if actual != expect { 115 | t.Errorf("expect %v options got %v", expect, actual) 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/endpoints/doc.go: -------------------------------------------------------------------------------- 1 | // Package endpoints provides the types and functionality for defining regions 2 | // and endpoints, as well as querying those definitions. 3 | // 4 | // The SDK's Regions and Endpoints metadata is code generated into the endpoints 5 | // package, and is accessible via the DefaultResolver function. This function 6 | // returns a endpoint Resolver will search the metadata and build an associated 7 | // endpoint if one is found. The default resolver will search all partitions 8 | // known by the SDK. e.g AWS Standard (aws), AWS China (aws-cn), and 9 | // AWS GovCloud (US) (aws-us-gov). 10 | // . 11 | // 12 | // Enumerating Regions and Endpoint Metadata 13 | // 14 | // Casting the Resolver returned by DefaultResolver to a EnumPartitions interface 15 | // will allow you to get access to the list of underlying Partitions with the 16 | // Partitions method. This is helpful if you want to limit the SDK's endpoint 17 | // resolving to a single partition, or enumerate regions, services, and endpoints 18 | // in the partition. 19 | // 20 | // resolver := endpoints.DefaultResolver() 21 | // partitions := resolver.(endpoints.EnumPartitions).Partitions() 22 | // 23 | // for _, p := range partitions { 24 | // fmt.Println("Regions for", p.Name) 25 | // for id, _ := range p.Regions() { 26 | // fmt.Println("*", id) 27 | // } 28 | // 29 | // fmt.Println("Services for", p.Name) 30 | // for id, _ := range p.Services() { 31 | // fmt.Println("*", id) 32 | // } 33 | // } 34 | // 35 | // Using Custom Endpoints 36 | // 37 | // The endpoints package also gives you the ability to use your own logic how 38 | // endpoints are resolved. This is a great way to define a custom endpoint 39 | // for select services, without passing that logic down through your code. 40 | // 41 | // If a type implements the Resolver interface it can be used to resolve 42 | // endpoints. To use this with the SDK's Session and Config set the value 43 | // of the type to the EndpointsResolver field of aws.Config when initializing 44 | // the session, or service client. 45 | // 46 | // In addition the ResolverFunc is a wrapper for a func matching the signature 47 | // of Resolver.EndpointFor, converting it to a type that satisfies the 48 | // Resolver interface. 49 | // 50 | // 51 | // myCustomResolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) { 52 | // if service == endpoints.S3ServiceID { 53 | // return endpoints.ResolvedEndpoint{ 54 | // URL: "s3.custom.endpoint.com", 55 | // SigningRegion: "custom-signing-region", 56 | // }, nil 57 | // } 58 | // 59 | // return endpoints.DefaultResolver().EndpointFor(service, region, optFns...) 60 | // } 61 | // 62 | // sess := session.Must(session.NewSession(&aws.Config{ 63 | // Region: aws.String("us-west-2"), 64 | // EndpointResolver: endpoints.ResolverFunc(myCustomResolver), 65 | // })) 66 | package endpoints 67 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/endpoints/example_test.go: -------------------------------------------------------------------------------- 1 | package endpoints_test 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/endpoints" 8 | "github.com/aws/aws-sdk-go/aws/session" 9 | "github.com/aws/aws-sdk-go/service/s3" 10 | "github.com/aws/aws-sdk-go/service/sqs" 11 | ) 12 | 13 | func ExampleEnumPartitions() { 14 | resolver := endpoints.DefaultResolver() 15 | partitions := resolver.(endpoints.EnumPartitions).Partitions() 16 | 17 | for _, p := range partitions { 18 | fmt.Println("Regions for", p.ID()) 19 | for id := range p.Regions() { 20 | fmt.Println("*", id) 21 | } 22 | 23 | fmt.Println("Services for", p.ID()) 24 | for id := range p.Services() { 25 | fmt.Println("*", id) 26 | } 27 | } 28 | } 29 | 30 | func ExampleResolverFunc() { 31 | myCustomResolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) { 32 | if service == endpoints.S3ServiceID { 33 | return endpoints.ResolvedEndpoint{ 34 | URL: "s3.custom.endpoint.com", 35 | SigningRegion: "custom-signing-region", 36 | }, nil 37 | } 38 | 39 | return endpoints.DefaultResolver().EndpointFor(service, region, optFns...) 40 | } 41 | 42 | sess := session.Must(session.NewSession(&aws.Config{ 43 | Region: aws.String("us-west-2"), 44 | EndpointResolver: endpoints.ResolverFunc(myCustomResolver), 45 | })) 46 | 47 | // Create the S3 service client with the shared session. This will 48 | // automatically use the S3 custom endpoint configured in the custom 49 | // endpoint resolver wrapping the default endpoint resolver. 50 | s3Svc := s3.New(sess) 51 | // Operation calls will be made to the custom endpoint. 52 | s3Svc.GetObject(&s3.GetObjectInput{ 53 | Bucket: aws.String("myBucket"), 54 | Key: aws.String("myObjectKey"), 55 | }) 56 | 57 | // Create the SQS service client with the shared session. This will 58 | // fallback to the default endpoint resolver because the customization 59 | // passes any non S3 service endpoint resolve to the default resolver. 60 | sqsSvc := sqs.New(sess) 61 | // Operation calls will be made to the default endpoint for SQS for the 62 | // region configured. 63 | sqsSvc.ReceiveMessage(&sqs.ReceiveMessageInput{ 64 | QueueUrl: aws.String("my-queue-url"), 65 | }) 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/errors.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import "github.com/aws/aws-sdk-go/aws/awserr" 4 | 5 | var ( 6 | // ErrMissingRegion is an error that is returned if region configuration is 7 | // not found. 8 | // 9 | // @readonly 10 | ErrMissingRegion = awserr.New("MissingRegion", "could not find region configuration", nil) 11 | 12 | // ErrMissingEndpoint is an error that is returned if an endpoint cannot be 13 | // resolved for a service. 14 | // 15 | // @readonly 16 | ErrMissingEndpoint = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) 17 | ) 18 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/jsonvalue.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | // JSONValue is a representation of a grab bag type that will be marshaled 4 | // into a json string. This type can be used just like any other map. 5 | // 6 | // Example: 7 | // values := JSONValue{ 8 | // "Foo": "Bar", 9 | // } 10 | // values["Baz"] = "Qux" 11 | type JSONValue map[string]interface{} 12 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/http_request.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "net/url" 7 | ) 8 | 9 | func copyHTTPRequest(r *http.Request, body io.ReadCloser) *http.Request { 10 | req := new(http.Request) 11 | *req = *r 12 | req.URL = &url.URL{} 13 | *req.URL = *r.URL 14 | req.Body = body 15 | 16 | req.Header = http.Header{} 17 | for k, v := range r.Header { 18 | for _, vv := range v { 19 | req.Header.Add(k, vv) 20 | } 21 | } 22 | 23 | return req 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/http_request_copy_test.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "net/http" 7 | "net/url" 8 | "sync" 9 | "testing" 10 | ) 11 | 12 | func TestRequestCopyRace(t *testing.T) { 13 | origReq := &http.Request{URL: &url.URL{}, Header: http.Header{}} 14 | origReq.Header.Set("Header", "OrigValue") 15 | 16 | var wg sync.WaitGroup 17 | for i := 0; i < 100; i++ { 18 | wg.Add(1) 19 | go func() { 20 | req := copyHTTPRequest(origReq, ioutil.NopCloser(&bytes.Buffer{})) 21 | req.Header.Set("Header", "Value") 22 | go func() { 23 | req2 := copyHTTPRequest(req, ioutil.NopCloser(&bytes.Buffer{})) 24 | req2.Header.Add("Header", "Value2") 25 | }() 26 | _ = req.Header.Get("Header") 27 | wg.Done() 28 | }() 29 | _ = origReq.Header.Get("Header") 30 | } 31 | origReq.Header.Get("Header") 32 | 33 | wg.Wait() 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/http_request_retry_test.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | package request_test 4 | 5 | import ( 6 | "errors" 7 | "strings" 8 | "testing" 9 | 10 | "github.com/aws/aws-sdk-go/aws" 11 | "github.com/aws/aws-sdk-go/aws/request" 12 | "github.com/aws/aws-sdk-go/awstesting/mock" 13 | "github.com/stretchr/testify/assert" 14 | ) 15 | 16 | func TestRequestCancelRetry(t *testing.T) { 17 | c := make(chan struct{}) 18 | 19 | reqNum := 0 20 | s := mock.NewMockClient(aws.NewConfig().WithMaxRetries(10)) 21 | s.Handlers.Validate.Clear() 22 | s.Handlers.Unmarshal.Clear() 23 | s.Handlers.UnmarshalMeta.Clear() 24 | s.Handlers.UnmarshalError.Clear() 25 | s.Handlers.Send.PushFront(func(r *request.Request) { 26 | reqNum++ 27 | r.Error = errors.New("net/http: request canceled") 28 | }) 29 | out := &testData{} 30 | r := s.NewRequest(&request.Operation{Name: "Operation"}, nil, out) 31 | r.HTTPRequest.Cancel = c 32 | close(c) 33 | 34 | err := r.Send() 35 | assert.True(t, strings.Contains(err.Error(), "canceled")) 36 | assert.Equal(t, 1, reqNum) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/offset_reader.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "io" 5 | "sync" 6 | ) 7 | 8 | // offsetReader is a thread-safe io.ReadCloser to prevent racing 9 | // with retrying requests 10 | type offsetReader struct { 11 | buf io.ReadSeeker 12 | lock sync.Mutex 13 | closed bool 14 | } 15 | 16 | func newOffsetReader(buf io.ReadSeeker, offset int64) *offsetReader { 17 | reader := &offsetReader{} 18 | buf.Seek(offset, 0) 19 | 20 | reader.buf = buf 21 | return reader 22 | } 23 | 24 | // Close will close the instance of the offset reader's access to 25 | // the underlying io.ReadSeeker. 26 | func (o *offsetReader) Close() error { 27 | o.lock.Lock() 28 | defer o.lock.Unlock() 29 | o.closed = true 30 | return nil 31 | } 32 | 33 | // Read is a thread-safe read of the underlying io.ReadSeeker 34 | func (o *offsetReader) Read(p []byte) (int, error) { 35 | o.lock.Lock() 36 | defer o.lock.Unlock() 37 | 38 | if o.closed { 39 | return 0, io.EOF 40 | } 41 | 42 | return o.buf.Read(p) 43 | } 44 | 45 | // Seek is a thread-safe seeking operation. 46 | func (o *offsetReader) Seek(offset int64, whence int) (int64, error) { 47 | o.lock.Lock() 48 | defer o.lock.Unlock() 49 | 50 | return o.buf.Seek(offset, whence) 51 | } 52 | 53 | // CloseAndCopy will return a new offsetReader with a copy of the old buffer 54 | // and close the old buffer. 55 | func (o *offsetReader) CloseAndCopy(offset int64) *offsetReader { 56 | o.Close() 57 | return newOffsetReader(o.buf, offset) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_5_test.go: -------------------------------------------------------------------------------- 1 | // +build !go1.6 2 | 3 | package request_test 4 | 5 | import ( 6 | "errors" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | ) 10 | 11 | var errTimeout = awserr.New("foo", "bar", errors.New("net/http: request canceled Timeout")) 12 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_6_test.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package request_test 4 | 5 | import ( 6 | "errors" 7 | "testing" 8 | 9 | "github.com/stretchr/testify/assert" 10 | 11 | "github.com/aws/aws-sdk-go/aws" 12 | "github.com/aws/aws-sdk-go/aws/awserr" 13 | "github.com/aws/aws-sdk-go/aws/client" 14 | "github.com/aws/aws-sdk-go/aws/client/metadata" 15 | "github.com/aws/aws-sdk-go/aws/defaults" 16 | "github.com/aws/aws-sdk-go/aws/request" 17 | ) 18 | 19 | // go version 1.4 and 1.5 do not return an error. Version 1.5 will url encode 20 | // the uri while 1.4 will not 21 | func TestRequestInvalidEndpoint(t *testing.T) { 22 | endpoint := "http://localhost:90 " 23 | 24 | r := request.New( 25 | aws.Config{}, 26 | metadata.ClientInfo{Endpoint: endpoint}, 27 | defaults.Handlers(), 28 | client.DefaultRetryer{}, 29 | &request.Operation{}, 30 | nil, 31 | nil, 32 | ) 33 | 34 | assert.Error(t, r.Error) 35 | } 36 | 37 | type timeoutErr struct { 38 | error 39 | } 40 | 41 | var errTimeout = awserr.New("foo", "bar", &timeoutErr{ 42 | errors.New("net/http: request canceled"), 43 | }) 44 | 45 | func (e *timeoutErr) Timeout() bool { 46 | return true 47 | } 48 | 49 | func (e *timeoutErr) Temporary() bool { 50 | return true 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_7.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package request 4 | 5 | import "io" 6 | 7 | // NoBody is an io.ReadCloser with no bytes. Read always returns EOF 8 | // and Close always returns nil. It can be used in an outgoing client 9 | // request to explicitly signal that a request has zero bytes. 10 | // An alternative, however, is to simply set Request.Body to nil. 11 | // 12 | // Copy of Go 1.8 NoBody type from net/http/http.go 13 | type noBody struct{} 14 | 15 | func (noBody) Read([]byte) (int, error) { return 0, io.EOF } 16 | func (noBody) Close() error { return nil } 17 | func (noBody) WriteTo(io.Writer) (int64, error) { return 0, nil } 18 | 19 | // Is an empty reader that will trigger the Go HTTP client to not include 20 | // and body in the HTTP request. 21 | var noBodyReader = noBody{} 22 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_7_test.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package request 4 | 5 | import ( 6 | "net/http" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | func TestResetBody_WithEmptyBody(t *testing.T) { 12 | r := Request{ 13 | HTTPRequest: &http.Request{}, 14 | } 15 | 16 | reader := strings.NewReader("") 17 | r.Body = reader 18 | 19 | r.ResetBody() 20 | 21 | if a, e := r.HTTPRequest.Body, (noBody{}); a != e { 22 | t.Errorf("expected request body to be set to reader, got %#v", r.HTTPRequest.Body) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package request 4 | 5 | import "net/http" 6 | 7 | // Is a http.NoBody reader instructing Go HTTP client to not include 8 | // and body in the HTTP request. 9 | var noBodyReader = http.NoBody 10 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8_test.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package request 4 | 5 | import ( 6 | "net/http" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | func TestResetBody_WithEmptyBody(t *testing.T) { 12 | r := Request{ 13 | HTTPRequest: &http.Request{}, 14 | } 15 | 16 | reader := strings.NewReader("") 17 | r.Body = reader 18 | 19 | r.ResetBody() 20 | 21 | if a, e := r.HTTPRequest.Body, http.NoBody; a != e { 22 | t.Errorf("expected request body to be set to reader, got %#v", 23 | r.HTTPRequest.Body) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_context.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package request 4 | 5 | import "github.com/aws/aws-sdk-go/aws" 6 | 7 | // setContext updates the Request to use the passed in context for cancellation. 8 | // Context will also be used for request retry delay. 9 | // 10 | // Creates shallow copy of the http.Request with the WithContext method. 11 | func setRequestContext(r *Request, ctx aws.Context) { 12 | r.context = ctx 13 | r.HTTPRequest = r.HTTPRequest.WithContext(ctx) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_context_1_6.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package request 4 | 5 | import "github.com/aws/aws-sdk-go/aws" 6 | 7 | // setContext updates the Request to use the passed in context for cancellation. 8 | // Context will also be used for request retry delay. 9 | // 10 | // Creates shallow copy of the http.Request with the WithContext method. 11 | func setRequestContext(r *Request, ctx aws.Context) { 12 | r.context = ctx 13 | r.HTTPRequest.Cancel = ctx.Done() 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_context_test.go: -------------------------------------------------------------------------------- 1 | package request_test 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws/corehandlers" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/awstesting" 11 | ) 12 | 13 | func TestRequest_SetContext(t *testing.T) { 14 | svc := awstesting.NewClient() 15 | svc.Handlers.Clear() 16 | svc.Handlers.Send.PushBackNamed(corehandlers.SendHandler) 17 | 18 | r := svc.NewRequest(&request.Operation{Name: "Operation"}, nil, nil) 19 | ctx := &awstesting.FakeContext{DoneCh: make(chan struct{})} 20 | r.SetContext(ctx) 21 | 22 | ctx.Error = fmt.Errorf("context canceled") 23 | close(ctx.DoneCh) 24 | 25 | err := r.Send() 26 | if err == nil { 27 | t.Fatalf("expected error, got none") 28 | } 29 | 30 | // Only check against canceled because go 1.6 will not use the context's 31 | // Err(). 32 | if e, a := "canceled", err.Error(); !strings.Contains(a, e) { 33 | t.Errorf("expect %q to be in %q, but was not", e, a) 34 | } 35 | } 36 | 37 | func TestRequest_SetContextPanic(t *testing.T) { 38 | defer func() { 39 | if r := recover(); r == nil { 40 | t.Fatalf("expect SetContext to panic, did not") 41 | } 42 | }() 43 | r := &request.Request{} 44 | 45 | r.SetContext(nil) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_internal_test.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestCopy(t *testing.T) { 8 | handlers := Handlers{} 9 | op := &Operation{} 10 | op.HTTPMethod = "Foo" 11 | req := &Request{} 12 | req.Operation = op 13 | req.Handlers = handlers 14 | 15 | r := req.copy() 16 | 17 | if r == req { 18 | t.Fatal("expect request pointer copy to be different") 19 | } 20 | if r.Operation == req.Operation { 21 | t.Errorf("expect request operation pointer to be different") 22 | } 23 | 24 | if e, a := req.Operation.HTTPMethod, r.Operation.HTTPMethod; e != a { 25 | t.Errorf("expect %q http method, got %q", e, a) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_resetbody_test.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "bytes" 5 | "net/http" 6 | "strings" 7 | "testing" 8 | 9 | "github.com/aws/aws-sdk-go/aws" 10 | ) 11 | 12 | func TestResetBody_WithBodyContents(t *testing.T) { 13 | r := Request{ 14 | HTTPRequest: &http.Request{}, 15 | } 16 | 17 | reader := strings.NewReader("abc") 18 | r.Body = reader 19 | 20 | r.ResetBody() 21 | 22 | if v, ok := r.HTTPRequest.Body.(*offsetReader); !ok || v == nil { 23 | t.Errorf("expected request body to be set to reader, got %#v", 24 | r.HTTPRequest.Body) 25 | } 26 | } 27 | 28 | func TestResetBody_ExcludeUnseekableBodyByMethod(t *testing.T) { 29 | cases := []struct { 30 | Method string 31 | IsNoBody bool 32 | }{ 33 | {"GET", true}, 34 | {"HEAD", true}, 35 | {"DELETE", true}, 36 | {"PUT", false}, 37 | {"PATCH", false}, 38 | {"POST", false}, 39 | } 40 | 41 | reader := aws.ReadSeekCloser(bytes.NewBuffer([]byte("abc"))) 42 | 43 | for i, c := range cases { 44 | r := Request{ 45 | HTTPRequest: &http.Request{}, 46 | Operation: &Operation{ 47 | HTTPMethod: c.Method, 48 | }, 49 | } 50 | 51 | r.SetReaderBody(reader) 52 | 53 | if a, e := r.HTTPRequest.Body == noBodyReader, c.IsNoBody; a != e { 54 | t.Errorf("%d, expect body to be set to noBody(%t), but was %t", i, e, a) 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/retryer_test.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | ) 10 | 11 | func TestRequestThrottling(t *testing.T) { 12 | req := Request{} 13 | 14 | req.Error = awserr.New("Throttling", "", nil) 15 | assert.True(t, req.IsErrorThrottle()) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/session/testdata/shared_config: -------------------------------------------------------------------------------- 1 | [default] 2 | s3 = 3 | unsupported_key=123 4 | other_unsupported=abc 5 | 6 | region = default_region 7 | 8 | [profile alt_profile_name] 9 | region = alt_profile_name_region 10 | 11 | [short_profile_name_first] 12 | region = short_profile_name_first_short 13 | 14 | [profile short_profile_name_first] 15 | region = short_profile_name_first_alt 16 | 17 | [partial_creds] 18 | aws_access_key_id = partial_creds_akid 19 | 20 | [complete_creds] 21 | aws_access_key_id = complete_creds_akid 22 | aws_secret_access_key = complete_creds_secret 23 | 24 | [complete_creds_with_token] 25 | aws_access_key_id = complete_creds_with_token_akid 26 | aws_secret_access_key = complete_creds_with_token_secret 27 | aws_session_token = complete_creds_with_token_token 28 | 29 | [full_profile] 30 | aws_access_key_id = full_profile_akid 31 | aws_secret_access_key = full_profile_secret 32 | region = full_profile_region 33 | 34 | [config_file_load_order] 35 | region = shared_config_region 36 | aws_access_key_id = shared_config_akid 37 | aws_secret_access_key = shared_config_secret 38 | 39 | [partial_assume_role] 40 | role_arn = partial_assume_role_role_arn 41 | 42 | [assume_role] 43 | role_arn = assume_role_role_arn 44 | source_profile = complete_creds 45 | 46 | [assume_role_w_mfa] 47 | role_arn = assume_role_role_arn 48 | source_profile = complete_creds 49 | mfa_serial = 0123456789 50 | 51 | [assume_role_invalid_source_profile] 52 | role_arn = assume_role_invalid_source_profile_role_arn 53 | source_profile = profile_not_exists 54 | 55 | [assume_role_w_creds] 56 | role_arn = assume_role_w_creds_role_arn 57 | source_profile = assume_role_w_creds 58 | external_id = 1234 59 | role_session_name = assume_role_w_creds_session_name 60 | aws_access_key_id = assume_role_w_creds_akid 61 | aws_secret_access_key = assume_role_w_creds_secret 62 | 63 | [assume_role_wo_creds] 64 | role_arn = assume_role_wo_creds_role_arn 65 | source_profile = assume_role_wo_creds 66 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/session/testdata/shared_config_invalid_ini: -------------------------------------------------------------------------------- 1 | [profile_nam 2 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/session/testdata/shared_config_other: -------------------------------------------------------------------------------- 1 | [default] 2 | region = default_region 3 | 4 | [partial_creds] 5 | aws_access_key_id = AKID 6 | 7 | [profile alt_profile_name] 8 | region = alt_profile_name_region 9 | 10 | [creds_from_credentials] 11 | aws_access_key_id = creds_from_config_akid 12 | aws_secret_access_key = creds_from_config_secret 13 | 14 | [config_file_load_order] 15 | region = shared_config_other_region 16 | aws_access_key_id = shared_config_other_akid 17 | aws_secret_access_key = shared_config_other_secret 18 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/signer/v4/functional_1_5_test.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | package v4_test 4 | 5 | import ( 6 | "fmt" 7 | "net/http" 8 | "testing" 9 | "time" 10 | 11 | "github.com/aws/aws-sdk-go/aws/signer/v4" 12 | "github.com/aws/aws-sdk-go/awstesting/unit" 13 | "github.com/stretchr/testify/assert" 14 | ) 15 | 16 | func TestStandaloneSign(t *testing.T) { 17 | creds := unit.Session.Config.Credentials 18 | signer := v4.NewSigner(creds) 19 | 20 | for _, c := range standaloneSignCases { 21 | host := fmt.Sprintf("https://%s.%s.%s.amazonaws.com", 22 | c.SubDomain, c.Region, c.Service) 23 | 24 | req, err := http.NewRequest("GET", host, nil) 25 | assert.NoError(t, err) 26 | 27 | // URL.EscapedPath() will be used by the signer to get the 28 | // escaped form of the request's URI path. 29 | req.URL.Path = c.OrigURI 30 | req.URL.RawQuery = c.OrigQuery 31 | 32 | _, err = signer.Sign(req, nil, c.Service, c.Region, time.Unix(0, 0)) 33 | assert.NoError(t, err) 34 | 35 | actual := req.Header.Get("Authorization") 36 | assert.Equal(t, c.ExpSig, actual) 37 | assert.Equal(t, c.OrigURI, req.URL.Path) 38 | assert.Equal(t, c.EscapedURI, req.URL.EscapedPath()) 39 | } 40 | } 41 | 42 | func TestStandaloneSign_RawPath(t *testing.T) { 43 | creds := unit.Session.Config.Credentials 44 | signer := v4.NewSigner(creds) 45 | 46 | for _, c := range standaloneSignCases { 47 | host := fmt.Sprintf("https://%s.%s.%s.amazonaws.com", 48 | c.SubDomain, c.Region, c.Service) 49 | 50 | req, err := http.NewRequest("GET", host, nil) 51 | assert.NoError(t, err) 52 | 53 | // URL.EscapedPath() will be used by the signer to get the 54 | // escaped form of the request's URI path. 55 | req.URL.Path = c.OrigURI 56 | req.URL.RawPath = c.EscapedURI 57 | req.URL.RawQuery = c.OrigQuery 58 | 59 | _, err = signer.Sign(req, nil, c.Service, c.Region, time.Unix(0, 0)) 60 | assert.NoError(t, err) 61 | 62 | actual := req.Header.Get("Authorization") 63 | assert.Equal(t, c.ExpSig, actual) 64 | assert.Equal(t, c.OrigURI, req.URL.Path) 65 | assert.Equal(t, c.EscapedURI, req.URL.EscapedPath()) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/signer/v4/header_rules.go: -------------------------------------------------------------------------------- 1 | package v4 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | ) 7 | 8 | // validator houses a set of rule needed for validation of a 9 | // string value 10 | type rules []rule 11 | 12 | // rule interface allows for more flexible rules and just simply 13 | // checks whether or not a value adheres to that rule 14 | type rule interface { 15 | IsValid(value string) bool 16 | } 17 | 18 | // IsValid will iterate through all rules and see if any rules 19 | // apply to the value and supports nested rules 20 | func (r rules) IsValid(value string) bool { 21 | for _, rule := range r { 22 | if rule.IsValid(value) { 23 | return true 24 | } 25 | } 26 | return false 27 | } 28 | 29 | // mapRule generic rule for maps 30 | type mapRule map[string]struct{} 31 | 32 | // IsValid for the map rule satisfies whether it exists in the map 33 | func (m mapRule) IsValid(value string) bool { 34 | _, ok := m[value] 35 | return ok 36 | } 37 | 38 | // whitelist is a generic rule for whitelisting 39 | type whitelist struct { 40 | rule 41 | } 42 | 43 | // IsValid for whitelist checks if the value is within the whitelist 44 | func (w whitelist) IsValid(value string) bool { 45 | return w.rule.IsValid(value) 46 | } 47 | 48 | // blacklist is a generic rule for blacklisting 49 | type blacklist struct { 50 | rule 51 | } 52 | 53 | // IsValid for whitelist checks if the value is within the whitelist 54 | func (b blacklist) IsValid(value string) bool { 55 | return !b.rule.IsValid(value) 56 | } 57 | 58 | type patterns []string 59 | 60 | // IsValid for patterns checks each pattern and returns if a match has 61 | // been found 62 | func (p patterns) IsValid(value string) bool { 63 | for _, pattern := range p { 64 | if strings.HasPrefix(http.CanonicalHeaderKey(value), pattern) { 65 | return true 66 | } 67 | } 68 | return false 69 | } 70 | 71 | // inclusiveRules rules allow for rules to depend on one another 72 | type inclusiveRules []rule 73 | 74 | // IsValid will return true if all rules are true 75 | func (r inclusiveRules) IsValid(value string) bool { 76 | for _, rule := range r { 77 | if !rule.IsValid(value) { 78 | return false 79 | } 80 | } 81 | return true 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/signer/v4/header_rules_test.go: -------------------------------------------------------------------------------- 1 | package v4 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestRuleCheckWhitelist(t *testing.T) { 10 | w := whitelist{ 11 | mapRule{ 12 | "Cache-Control": struct{}{}, 13 | }, 14 | } 15 | 16 | assert.True(t, w.IsValid("Cache-Control")) 17 | assert.False(t, w.IsValid("Cache-")) 18 | } 19 | 20 | func TestRuleCheckBlacklist(t *testing.T) { 21 | b := blacklist{ 22 | mapRule{ 23 | "Cache-Control": struct{}{}, 24 | }, 25 | } 26 | 27 | assert.False(t, b.IsValid("Cache-Control")) 28 | assert.True(t, b.IsValid("Cache-")) 29 | } 30 | 31 | func TestRuleCheckPattern(t *testing.T) { 32 | p := patterns{"X-Amz-Meta-"} 33 | 34 | assert.True(t, p.IsValid("X-Amz-Meta-")) 35 | assert.True(t, p.IsValid("X-Amz-Meta-Star")) 36 | assert.False(t, p.IsValid("Cache-")) 37 | } 38 | 39 | func TestRuleComplexWhitelist(t *testing.T) { 40 | w := rules{ 41 | whitelist{ 42 | mapRule{ 43 | "Cache-Control": struct{}{}, 44 | }, 45 | }, 46 | patterns{"X-Amz-Meta-"}, 47 | } 48 | 49 | r := rules{ 50 | inclusiveRules{patterns{"X-Amz-"}, blacklist{w}}, 51 | } 52 | 53 | assert.True(t, r.IsValid("X-Amz-Blah")) 54 | assert.False(t, r.IsValid("X-Amz-Meta-")) 55 | assert.False(t, r.IsValid("X-Amz-Meta-Star")) 56 | assert.False(t, r.IsValid("Cache-Control")) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/signer/v4/options.go: -------------------------------------------------------------------------------- 1 | package v4 2 | 3 | // WithUnsignedPayload will enable and set the UnsignedPayload field to 4 | // true of the signer. 5 | func WithUnsignedPayload(v4 *Signer) { 6 | v4.UnsignedPayload = true 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/signer/v4/uri_path.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | package v4 4 | 5 | import ( 6 | "net/url" 7 | "strings" 8 | ) 9 | 10 | func getURIPath(u *url.URL) string { 11 | var uri string 12 | 13 | if len(u.Opaque) > 0 { 14 | uri = "/" + strings.Join(strings.Split(u.Opaque, "/")[3:], "/") 15 | } else { 16 | uri = u.EscapedPath() 17 | } 18 | 19 | if len(uri) == 0 { 20 | uri = "/" 21 | } 22 | 23 | return uri 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/types_test.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "math/rand" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestWriteAtBuffer(t *testing.T) { 11 | b := &WriteAtBuffer{} 12 | 13 | n, err := b.WriteAt([]byte{1}, 0) 14 | assert.NoError(t, err) 15 | assert.Equal(t, 1, n) 16 | 17 | n, err = b.WriteAt([]byte{1, 1, 1}, 5) 18 | assert.NoError(t, err) 19 | assert.Equal(t, 3, n) 20 | 21 | n, err = b.WriteAt([]byte{2}, 1) 22 | assert.NoError(t, err) 23 | assert.Equal(t, 1, n) 24 | 25 | n, err = b.WriteAt([]byte{3}, 2) 26 | assert.NoError(t, err) 27 | assert.Equal(t, 1, n) 28 | 29 | assert.Equal(t, []byte{1, 2, 3, 0, 0, 1, 1, 1}, b.Bytes()) 30 | } 31 | 32 | func BenchmarkWriteAtBuffer(b *testing.B) { 33 | buf := &WriteAtBuffer{} 34 | r := rand.New(rand.NewSource(1)) 35 | 36 | b.ResetTimer() 37 | for i := 0; i < b.N; i++ { 38 | to := r.Intn(10) * 4096 39 | bs := make([]byte, to) 40 | buf.WriteAt(bs, r.Int63n(10)*4096) 41 | } 42 | } 43 | 44 | func BenchmarkWriteAtBufferOrderedWrites(b *testing.B) { 45 | // test the performance of a WriteAtBuffer when written in an 46 | // ordered fashion. This is similar to the behavior of the 47 | // s3.Downloader, since downloads the first chunk of the file, then 48 | // the second, and so on. 49 | // 50 | // This test simulates a 150MB file being written in 30 ordered 5MB chunks. 51 | chunk := int64(5e6) 52 | max := chunk * 30 53 | // we'll write the same 5MB chunk every time 54 | tmp := make([]byte, chunk) 55 | for i := 0; i < b.N; i++ { 56 | buf := &WriteAtBuffer{} 57 | for i := int64(0); i < max; i += chunk { 58 | buf.WriteAt(tmp, i) 59 | } 60 | } 61 | } 62 | 63 | func BenchmarkWriteAtBufferParallel(b *testing.B) { 64 | buf := &WriteAtBuffer{} 65 | r := rand.New(rand.NewSource(1)) 66 | 67 | b.ResetTimer() 68 | b.RunParallel(func(pb *testing.PB) { 69 | for pb.Next() { 70 | to := r.Intn(10) * 4096 71 | bs := make([]byte, to) 72 | buf.WriteAt(bs, r.Int63n(10)*4096) 73 | } 74 | }) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/version.go: -------------------------------------------------------------------------------- 1 | // Package aws provides core functionality for making requests to AWS services. 2 | package aws 3 | 4 | // SDKName is the name of this AWS SDK 5 | const SDKName = "aws-sdk-go" 6 | 7 | // SDKVersion is the version of this SDK 8 | const SDKVersion = "1.8.7" 9 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/awstesting/client.go: -------------------------------------------------------------------------------- 1 | package awstesting 2 | 3 | import ( 4 | "github.com/aws/aws-sdk-go/aws" 5 | "github.com/aws/aws-sdk-go/aws/client" 6 | "github.com/aws/aws-sdk-go/aws/client/metadata" 7 | "github.com/aws/aws-sdk-go/aws/defaults" 8 | ) 9 | 10 | // NewClient creates and initializes a generic service client for testing. 11 | func NewClient(cfgs ...*aws.Config) *client.Client { 12 | info := metadata.ClientInfo{ 13 | Endpoint: "http://endpoint", 14 | SigningName: "", 15 | } 16 | def := defaults.Get() 17 | def.Config.MergeIn(cfgs...) 18 | 19 | if v := aws.StringValue(def.Config.Endpoint); len(v) > 0 { 20 | info.Endpoint = v 21 | } 22 | 23 | return client.New(*def.Config, info, def.Handlers) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/awstesting/mock/mock.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | 7 | "github.com/aws/aws-sdk-go/aws" 8 | "github.com/aws/aws-sdk-go/aws/client" 9 | "github.com/aws/aws-sdk-go/aws/client/metadata" 10 | "github.com/aws/aws-sdk-go/aws/session" 11 | ) 12 | 13 | // Session is a mock session which is used to hit the mock server 14 | var Session = func() *session.Session { 15 | // server is the mock server that simply writes a 200 status back to the client 16 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 17 | w.WriteHeader(http.StatusOK) 18 | })) 19 | 20 | return session.Must(session.NewSession(&aws.Config{ 21 | DisableSSL: aws.Bool(true), 22 | Endpoint: aws.String(server.URL), 23 | })) 24 | }() 25 | 26 | // NewMockClient creates and initializes a client that will connect to the 27 | // mock server 28 | func NewMockClient(cfgs ...*aws.Config) *client.Client { 29 | c := Session.ClientConfig("Mock", cfgs...) 30 | 31 | svc := client.New( 32 | *c.Config, 33 | metadata.ClientInfo{ 34 | ServiceName: "Mock", 35 | SigningRegion: c.SigningRegion, 36 | Endpoint: c.Endpoint, 37 | APIVersion: "2015-12-08", 38 | JSONVersion: "1.1", 39 | TargetPrefix: "MockServer", 40 | }, 41 | c.Handlers, 42 | ) 43 | 44 | return svc 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/awstesting/unit/unit.go: -------------------------------------------------------------------------------- 1 | // Package unit performs initialization and validation for unit tests 2 | package unit 3 | 4 | import ( 5 | "github.com/aws/aws-sdk-go/aws" 6 | "github.com/aws/aws-sdk-go/aws/credentials" 7 | "github.com/aws/aws-sdk-go/aws/session" 8 | ) 9 | 10 | // Session is a shared session for unit tests to use. 11 | var Session = session.Must(session.NewSession(aws.NewConfig(). 12 | WithCredentials(credentials.NewStaticCredentials("AKID", "SECRET", "SESSION")). 13 | WithRegion("mock-region"))) 14 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/awstesting/util.go: -------------------------------------------------------------------------------- 1 | package awstesting 2 | 3 | import ( 4 | "io" 5 | "time" 6 | 7 | "github.com/aws/aws-sdk-go/private/util" 8 | ) 9 | 10 | // ZeroReader is a io.Reader which will always write zeros to the byte slice provided. 11 | type ZeroReader struct{} 12 | 13 | // Read fills the provided byte slice with zeros returning the number of bytes written. 14 | func (r *ZeroReader) Read(b []byte) (int, error) { 15 | for i := 0; i < len(b); i++ { 16 | b[i] = 0 17 | } 18 | return len(b), nil 19 | } 20 | 21 | // ReadCloser is a io.ReadCloser for unit testing. 22 | // Designed to test for leaks and whether a handle has 23 | // been closed 24 | type ReadCloser struct { 25 | Size int 26 | Closed bool 27 | set bool 28 | FillData func(bool, []byte, int, int) 29 | } 30 | 31 | // Read will call FillData and fill it with whatever data needed. 32 | // Decrements the size until zero, then return io.EOF. 33 | func (r *ReadCloser) Read(b []byte) (int, error) { 34 | if r.Closed { 35 | return 0, io.EOF 36 | } 37 | 38 | delta := len(b) 39 | if delta > r.Size { 40 | delta = r.Size 41 | } 42 | r.Size -= delta 43 | 44 | for i := 0; i < delta; i++ { 45 | b[i] = 'a' 46 | } 47 | 48 | if r.FillData != nil { 49 | r.FillData(r.set, b, r.Size, delta) 50 | } 51 | r.set = true 52 | 53 | if r.Size > 0 { 54 | return delta, nil 55 | } 56 | return delta, io.EOF 57 | } 58 | 59 | // Close sets Closed to true and returns no error 60 | func (r *ReadCloser) Close() error { 61 | r.Closed = true 62 | return nil 63 | } 64 | 65 | // SortedKeys returns a sorted slice of keys of a map. 66 | func SortedKeys(m map[string]interface{}) []string { 67 | return util.SortedKeys(m) 68 | } 69 | 70 | // A FakeContext provides a simple stub implementation of a Context 71 | type FakeContext struct { 72 | Error error 73 | DoneCh chan struct{} 74 | } 75 | 76 | // Deadline always will return not set 77 | func (c *FakeContext) Deadline() (deadline time.Time, ok bool) { 78 | return time.Time{}, false 79 | } 80 | 81 | // Done returns a read channel for listening to the Done event 82 | func (c *FakeContext) Done() <-chan struct{} { 83 | return c.DoneCh 84 | } 85 | 86 | // Err returns the error, is nil if not set. 87 | func (c *FakeContext) Err() error { 88 | return c.Error 89 | } 90 | 91 | // Value ignores the Value and always returns nil 92 | func (c *FakeContext) Value(key interface{}) interface{} { 93 | return nil 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/awstesting/util_test.go: -------------------------------------------------------------------------------- 1 | package awstesting_test 2 | 3 | import ( 4 | "io" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | 9 | "github.com/aws/aws-sdk-go/awstesting" 10 | ) 11 | 12 | func TestReadCloserClose(t *testing.T) { 13 | rc := awstesting.ReadCloser{Size: 1} 14 | err := rc.Close() 15 | 16 | assert.Nil(t, err) 17 | assert.True(t, rc.Closed) 18 | assert.Equal(t, rc.Size, 1) 19 | } 20 | 21 | func TestReadCloserRead(t *testing.T) { 22 | rc := awstesting.ReadCloser{Size: 5} 23 | b := make([]byte, 2) 24 | 25 | n, err := rc.Read(b) 26 | 27 | assert.Nil(t, err) 28 | assert.Equal(t, n, 2) 29 | assert.False(t, rc.Closed) 30 | assert.Equal(t, rc.Size, 3) 31 | 32 | err = rc.Close() 33 | assert.Nil(t, err) 34 | n, err = rc.Read(b) 35 | assert.Equal(t, err, io.EOF) 36 | assert.Equal(t, n, 0) 37 | } 38 | 39 | func TestReadCloserReadAll(t *testing.T) { 40 | rc := awstesting.ReadCloser{Size: 5} 41 | b := make([]byte, 5) 42 | 43 | n, err := rc.Read(b) 44 | 45 | assert.Equal(t, err, io.EOF) 46 | assert.Equal(t, n, 5) 47 | assert.False(t, rc.Closed) 48 | assert.Equal(t, rc.Size, 0) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/build.go: -------------------------------------------------------------------------------- 1 | // Package ec2query provides serialization of AWS EC2 requests and responses. 2 | package ec2query 3 | 4 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/ec2.json build_test.go 5 | 6 | import ( 7 | "net/url" 8 | 9 | "github.com/aws/aws-sdk-go/aws/awserr" 10 | "github.com/aws/aws-sdk-go/aws/request" 11 | "github.com/aws/aws-sdk-go/private/protocol/query/queryutil" 12 | ) 13 | 14 | // BuildHandler is a named request handler for building ec2query protocol requests 15 | var BuildHandler = request.NamedHandler{Name: "awssdk.ec2query.Build", Fn: Build} 16 | 17 | // Build builds a request for the EC2 protocol. 18 | func Build(r *request.Request) { 19 | body := url.Values{ 20 | "Action": {r.Operation.Name}, 21 | "Version": {r.ClientInfo.APIVersion}, 22 | } 23 | if err := queryutil.Parse(body, r.Params, true); err != nil { 24 | r.Error = awserr.New("SerializationError", "failed encoding EC2 Query request", err) 25 | } 26 | 27 | if r.ExpireTime == 0 { 28 | r.HTTPRequest.Method = "POST" 29 | r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") 30 | r.SetBufferBody([]byte(body.Encode())) 31 | } else { // This is a pre-signed request 32 | r.HTTPRequest.Method = "GET" 33 | r.HTTPRequest.URL.RawQuery = body.Encode() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/build_bench_test.go: -------------------------------------------------------------------------------- 1 | // +build bench 2 | 3 | package ec2query_test 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/awstesting" 11 | "github.com/aws/aws-sdk-go/private/protocol/ec2query" 12 | "github.com/aws/aws-sdk-go/service/ec2" 13 | ) 14 | 15 | func BenchmarkEC2QueryBuild_Complex_ec2AuthorizeSecurityGroupEgress(b *testing.B) { 16 | params := &ec2.AuthorizeSecurityGroupEgressInput{ 17 | GroupId: aws.String("String"), // Required 18 | CidrIp: aws.String("String"), 19 | DryRun: aws.Bool(true), 20 | FromPort: aws.Int64(1), 21 | IpPermissions: []*ec2.IpPermission{ 22 | { // Required 23 | FromPort: aws.Int64(1), 24 | IpProtocol: aws.String("String"), 25 | IpRanges: []*ec2.IpRange{ 26 | { // Required 27 | CidrIp: aws.String("String"), 28 | }, 29 | // More values... 30 | }, 31 | PrefixListIds: []*ec2.PrefixListId{ 32 | { // Required 33 | PrefixListId: aws.String("String"), 34 | }, 35 | // More values... 36 | }, 37 | ToPort: aws.Int64(1), 38 | UserIdGroupPairs: []*ec2.UserIdGroupPair{ 39 | { // Required 40 | GroupId: aws.String("String"), 41 | GroupName: aws.String("String"), 42 | UserId: aws.String("String"), 43 | }, 44 | // More values... 45 | }, 46 | }, 47 | // More values... 48 | }, 49 | IpProtocol: aws.String("String"), 50 | SourceSecurityGroupName: aws.String("String"), 51 | SourceSecurityGroupOwnerId: aws.String("String"), 52 | ToPort: aws.Int64(1), 53 | } 54 | 55 | benchEC2QueryBuild(b, "AuthorizeSecurityGroupEgress", params) 56 | } 57 | 58 | func BenchmarkEC2QueryBuild_Simple_ec2AttachNetworkInterface(b *testing.B) { 59 | params := &ec2.AttachNetworkInterfaceInput{ 60 | DeviceIndex: aws.Int64(1), // Required 61 | InstanceId: aws.String("String"), // Required 62 | NetworkInterfaceId: aws.String("String"), // Required 63 | DryRun: aws.Bool(true), 64 | } 65 | 66 | benchEC2QueryBuild(b, "AttachNetworkInterface", params) 67 | } 68 | 69 | func benchEC2QueryBuild(b *testing.B, opName string, params interface{}) { 70 | svc := awstesting.NewClient() 71 | svc.ServiceName = "ec2" 72 | svc.APIVersion = "2015-04-15" 73 | 74 | for i := 0; i < b.N; i++ { 75 | r := svc.NewRequest(&request.Operation{ 76 | Name: opName, 77 | HTTPMethod: "POST", 78 | HTTPPath: "/", 79 | }, params, nil) 80 | ec2query.Build(r) 81 | if r.Error != nil { 82 | b.Fatal("Unexpected error", r.Error) 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/unmarshal.go: -------------------------------------------------------------------------------- 1 | package ec2query 2 | 3 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/ec2.json unmarshal_test.go 4 | 5 | import ( 6 | "encoding/xml" 7 | "io" 8 | 9 | "github.com/aws/aws-sdk-go/aws/awserr" 10 | "github.com/aws/aws-sdk-go/aws/request" 11 | "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" 12 | ) 13 | 14 | // UnmarshalHandler is a named request handler for unmarshaling ec2query protocol requests 15 | var UnmarshalHandler = request.NamedHandler{Name: "awssdk.ec2query.Unmarshal", Fn: Unmarshal} 16 | 17 | // UnmarshalMetaHandler is a named request handler for unmarshaling ec2query protocol request metadata 18 | var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.ec2query.UnmarshalMeta", Fn: UnmarshalMeta} 19 | 20 | // UnmarshalErrorHandler is a named request handler for unmarshaling ec2query protocol request errors 21 | var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.ec2query.UnmarshalError", Fn: UnmarshalError} 22 | 23 | // Unmarshal unmarshals a response body for the EC2 protocol. 24 | func Unmarshal(r *request.Request) { 25 | defer r.HTTPResponse.Body.Close() 26 | if r.DataFilled() { 27 | decoder := xml.NewDecoder(r.HTTPResponse.Body) 28 | err := xmlutil.UnmarshalXML(r.Data, decoder, "") 29 | if err != nil { 30 | r.Error = awserr.New("SerializationError", "failed decoding EC2 Query response", err) 31 | return 32 | } 33 | } 34 | } 35 | 36 | // UnmarshalMeta unmarshals response headers for the EC2 protocol. 37 | func UnmarshalMeta(r *request.Request) { 38 | // TODO implement unmarshaling of request IDs 39 | } 40 | 41 | type xmlErrorResponse struct { 42 | XMLName xml.Name `xml:"Response"` 43 | Code string `xml:"Errors>Error>Code"` 44 | Message string `xml:"Errors>Error>Message"` 45 | RequestID string `xml:"RequestID"` 46 | } 47 | 48 | // UnmarshalError unmarshals a response error for the EC2 protocol. 49 | func UnmarshalError(r *request.Request) { 50 | defer r.HTTPResponse.Body.Close() 51 | 52 | resp := &xmlErrorResponse{} 53 | err := xml.NewDecoder(r.HTTPResponse.Body).Decode(resp) 54 | if err != nil && err != io.EOF { 55 | r.Error = awserr.New("SerializationError", "failed decoding EC2 Query error response", err) 56 | } else { 57 | r.Error = awserr.NewRequestFailure( 58 | awserr.New(resp.Code, resp.Message, nil), 59 | r.HTTPResponse.StatusCode, 60 | resp.RequestID, 61 | ) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/idempotency.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "crypto/rand" 5 | "fmt" 6 | "reflect" 7 | ) 8 | 9 | // RandReader is the random reader the protocol package will use to read 10 | // random bytes from. This is exported for testing, and should not be used. 11 | var RandReader = rand.Reader 12 | 13 | const idempotencyTokenFillTag = `idempotencyToken` 14 | 15 | // CanSetIdempotencyToken returns true if the struct field should be 16 | // automatically populated with a Idempotency token. 17 | // 18 | // Only *string and string type fields that are tagged with idempotencyToken 19 | // which are not already set can be auto filled. 20 | func CanSetIdempotencyToken(v reflect.Value, f reflect.StructField) bool { 21 | switch u := v.Interface().(type) { 22 | // To auto fill an Idempotency token the field must be a string, 23 | // tagged for auto fill, and have a zero value. 24 | case *string: 25 | return u == nil && len(f.Tag.Get(idempotencyTokenFillTag)) != 0 26 | case string: 27 | return len(u) == 0 && len(f.Tag.Get(idempotencyTokenFillTag)) != 0 28 | } 29 | 30 | return false 31 | } 32 | 33 | // GetIdempotencyToken returns a randomly generated idempotency token. 34 | func GetIdempotencyToken() string { 35 | b := make([]byte, 16) 36 | RandReader.Read(b) 37 | 38 | return UUIDVersion4(b) 39 | } 40 | 41 | // SetIdempotencyToken will set the value provided with a Idempotency Token. 42 | // Given that the value can be set. Will panic if value is not setable. 43 | func SetIdempotencyToken(v reflect.Value) { 44 | if v.Kind() == reflect.Ptr { 45 | if v.IsNil() && v.CanSet() { 46 | v.Set(reflect.New(v.Type().Elem())) 47 | } 48 | v = v.Elem() 49 | } 50 | v = reflect.Indirect(v) 51 | 52 | if !v.CanSet() { 53 | panic(fmt.Sprintf("unable to set idempotnecy token %v", v)) 54 | } 55 | 56 | b := make([]byte, 16) 57 | _, err := rand.Read(b) 58 | if err != nil { 59 | // TODO handle error 60 | return 61 | } 62 | 63 | v.Set(reflect.ValueOf(UUIDVersion4(b))) 64 | } 65 | 66 | // UUIDVersion4 returns a Version 4 random UUID from the byte slice provided 67 | func UUIDVersion4(u []byte) string { 68 | // https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29 69 | // 13th character is "4" 70 | u[6] = (u[6] | 0x40) & 0x4F 71 | // 17th character is "8", "9", "a", or "b" 72 | u[8] = (u[8] | 0x80) & 0xBF 73 | 74 | return fmt.Sprintf(`%X-%X-%X-%X-%X`, u[0:4], u[4:6], u[6:8], u[8:10], u[10:]) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/idempotency_test.go: -------------------------------------------------------------------------------- 1 | package protocol_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | 7 | "github.com/aws/aws-sdk-go/private/protocol" 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestCanSetIdempotencyToken(t *testing.T) { 12 | cases := []struct { 13 | CanSet bool 14 | Case interface{} 15 | }{ 16 | { 17 | true, 18 | struct { 19 | Field *string `idempotencyToken:"true"` 20 | }{}, 21 | }, 22 | { 23 | true, 24 | struct { 25 | Field string `idempotencyToken:"true"` 26 | }{}, 27 | }, 28 | { 29 | false, 30 | struct { 31 | Field *string `idempotencyToken:"true"` 32 | }{Field: new(string)}, 33 | }, 34 | { 35 | false, 36 | struct { 37 | Field string `idempotencyToken:"true"` 38 | }{Field: "value"}, 39 | }, 40 | { 41 | false, 42 | struct { 43 | Field *int `idempotencyToken:"true"` 44 | }{}, 45 | }, 46 | { 47 | false, 48 | struct { 49 | Field *string 50 | }{}, 51 | }, 52 | } 53 | 54 | for i, c := range cases { 55 | v := reflect.Indirect(reflect.ValueOf(c.Case)) 56 | ty := v.Type() 57 | canSet := protocol.CanSetIdempotencyToken(v.Field(0), ty.Field(0)) 58 | assert.Equal(t, c.CanSet, canSet, "Expect case %d can set to match", i) 59 | } 60 | } 61 | 62 | func TestSetIdempotencyToken(t *testing.T) { 63 | cases := []struct { 64 | Case interface{} 65 | }{ 66 | { 67 | &struct { 68 | Field *string `idempotencyToken:"true"` 69 | }{}, 70 | }, 71 | { 72 | &struct { 73 | Field string `idempotencyToken:"true"` 74 | }{}, 75 | }, 76 | { 77 | &struct { 78 | Field *string `idempotencyToken:"true"` 79 | }{Field: new(string)}, 80 | }, 81 | { 82 | &struct { 83 | Field string `idempotencyToken:"true"` 84 | }{Field: ""}, 85 | }, 86 | } 87 | 88 | for i, c := range cases { 89 | v := reflect.Indirect(reflect.ValueOf(c.Case)) 90 | 91 | protocol.SetIdempotencyToken(v.Field(0)) 92 | assert.NotEmpty(t, v.Field(0).Interface(), "Expect case %d to be set", i) 93 | } 94 | } 95 | 96 | func TestUUIDVersion4(t *testing.T) { 97 | uuid := protocol.UUIDVersion4(make([]byte, 16)) 98 | assert.Equal(t, `00000000-0000-4000-8000-000000000000`, uuid) 99 | 100 | b := make([]byte, 16) 101 | for i := 0; i < len(b); i++ { 102 | b[i] = 1 103 | } 104 | uuid = protocol.UUIDVersion4(b) 105 | assert.Equal(t, `01010101-0101-4101-8101-010101010101`, uuid) 106 | } 107 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/json/jsonutil/build_test.go: -------------------------------------------------------------------------------- 1 | package jsonutil_test 2 | 3 | import ( 4 | "encoding/json" 5 | "testing" 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/private/protocol/json/jsonutil" 9 | "github.com/stretchr/testify/assert" 10 | ) 11 | 12 | func S(s string) *string { 13 | return &s 14 | } 15 | 16 | func D(s int64) *int64 { 17 | return &s 18 | } 19 | 20 | func F(s float64) *float64 { 21 | return &s 22 | } 23 | 24 | func T(s time.Time) *time.Time { 25 | return &s 26 | } 27 | 28 | type J struct { 29 | S *string 30 | SS []string 31 | D *int64 32 | F *float64 33 | T *time.Time 34 | } 35 | 36 | var zero = 0.0 37 | 38 | var jsonTests = []struct { 39 | in interface{} 40 | out string 41 | err string 42 | }{ 43 | { 44 | J{}, 45 | `{}`, 46 | ``, 47 | }, 48 | { 49 | J{ 50 | S: S("str"), 51 | SS: []string{"A", "B", "C"}, 52 | D: D(123), 53 | F: F(4.56), 54 | T: T(time.Unix(987, 0)), 55 | }, 56 | `{"S":"str","SS":["A","B","C"],"D":123,"F":4.56,"T":987}`, 57 | ``, 58 | }, 59 | { 60 | J{ 61 | S: S(`"''"`), 62 | }, 63 | `{"S":"\"''\""}`, 64 | ``, 65 | }, 66 | { 67 | J{ 68 | S: S("\x00føø\u00FF\n\\\"\r\t\b\f"), 69 | }, 70 | `{"S":"\u0000føøÿ\n\\\"\r\t\b\f"}`, 71 | ``, 72 | }, 73 | { 74 | J{ 75 | F: F(4.56 / zero), 76 | }, 77 | "", 78 | `json: unsupported value: +Inf`, 79 | }, 80 | } 81 | 82 | func TestBuildJSON(t *testing.T) { 83 | for _, test := range jsonTests { 84 | out, err := jsonutil.BuildJSON(test.in) 85 | if test.err != "" { 86 | assert.Error(t, err) 87 | assert.Contains(t, err.Error(), test.err) 88 | } else { 89 | assert.NoError(t, err) 90 | assert.Equal(t, string(out), test.out) 91 | } 92 | } 93 | } 94 | 95 | func BenchmarkBuildJSON(b *testing.B) { 96 | for i := 0; i < b.N; i++ { 97 | for _, test := range jsonTests { 98 | jsonutil.BuildJSON(test.in) 99 | } 100 | } 101 | } 102 | 103 | func BenchmarkStdlibJSON(b *testing.B) { 104 | for i := 0; i < b.N; i++ { 105 | for _, test := range jsonTests { 106 | json.Marshal(test.in) 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/jsonrpc/build_bench_test.go: -------------------------------------------------------------------------------- 1 | // +build bench 2 | 3 | package jsonrpc_test 4 | 5 | import ( 6 | "bytes" 7 | "encoding/json" 8 | "testing" 9 | 10 | "github.com/aws/aws-sdk-go/aws" 11 | "github.com/aws/aws-sdk-go/aws/request" 12 | "github.com/aws/aws-sdk-go/awstesting" 13 | "github.com/aws/aws-sdk-go/private/protocol/json/jsonutil" 14 | "github.com/aws/aws-sdk-go/private/protocol/jsonrpc" 15 | "github.com/aws/aws-sdk-go/service/dynamodb" 16 | "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" 17 | ) 18 | 19 | func BenchmarkJSONRPCBuild_Simple_dynamodbPutItem(b *testing.B) { 20 | svc := awstesting.NewClient() 21 | 22 | params := getDynamodbPutItemParams(b) 23 | 24 | for i := 0; i < b.N; i++ { 25 | r := svc.NewRequest(&request.Operation{Name: "Operation"}, params, nil) 26 | jsonrpc.Build(r) 27 | if r.Error != nil { 28 | b.Fatal("Unexpected error", r.Error) 29 | } 30 | } 31 | } 32 | 33 | func BenchmarkJSONUtilBuild_Simple_dynamodbPutItem(b *testing.B) { 34 | svc := awstesting.NewClient() 35 | 36 | params := getDynamodbPutItemParams(b) 37 | 38 | for i := 0; i < b.N; i++ { 39 | r := svc.NewRequest(&request.Operation{Name: "Operation"}, params, nil) 40 | _, err := jsonutil.BuildJSON(r.Params) 41 | if err != nil { 42 | b.Fatal("Unexpected error", err) 43 | } 44 | } 45 | } 46 | 47 | func BenchmarkEncodingJSONMarshal_Simple_dynamodbPutItem(b *testing.B) { 48 | params := getDynamodbPutItemParams(b) 49 | 50 | for i := 0; i < b.N; i++ { 51 | buf := &bytes.Buffer{} 52 | encoder := json.NewEncoder(buf) 53 | if err := encoder.Encode(params); err != nil { 54 | b.Fatal("Unexpected error", err) 55 | } 56 | } 57 | } 58 | 59 | func getDynamodbPutItemParams(b *testing.B) *dynamodb.PutItemInput { 60 | av, err := dynamodbattribute.ConvertToMap(struct { 61 | Key string 62 | Data string 63 | }{Key: "MyKey", Data: "MyData"}) 64 | if err != nil { 65 | b.Fatal("benchPutItem, expect no ConvertToMap errors", err) 66 | } 67 | return &dynamodb.PutItemInput{ 68 | Item: av, 69 | TableName: aws.String("tablename"), 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go: -------------------------------------------------------------------------------- 1 | // Package query provides serialization of AWS query requests, and responses. 2 | package query 3 | 4 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/query.json build_test.go 5 | 6 | import ( 7 | "net/url" 8 | 9 | "github.com/aws/aws-sdk-go/aws/awserr" 10 | "github.com/aws/aws-sdk-go/aws/request" 11 | "github.com/aws/aws-sdk-go/private/protocol/query/queryutil" 12 | ) 13 | 14 | // BuildHandler is a named request handler for building query protocol requests 15 | var BuildHandler = request.NamedHandler{Name: "awssdk.query.Build", Fn: Build} 16 | 17 | // Build builds a request for an AWS Query service. 18 | func Build(r *request.Request) { 19 | body := url.Values{ 20 | "Action": {r.Operation.Name}, 21 | "Version": {r.ClientInfo.APIVersion}, 22 | } 23 | if err := queryutil.Parse(body, r.Params, false); err != nil { 24 | r.Error = awserr.New("SerializationError", "failed encoding Query request", err) 25 | return 26 | } 27 | 28 | if r.ExpireTime == 0 { 29 | r.HTTPRequest.Method = "POST" 30 | r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") 31 | r.SetBufferBody([]byte(body.Encode())) 32 | } else { // This is a pre-signed request 33 | r.HTTPRequest.Method = "GET" 34 | r.HTTPRequest.URL.RawQuery = body.Encode() 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/query.json unmarshal_test.go 4 | 5 | import ( 6 | "encoding/xml" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" 11 | ) 12 | 13 | // UnmarshalHandler is a named request handler for unmarshaling query protocol requests 14 | var UnmarshalHandler = request.NamedHandler{Name: "awssdk.query.Unmarshal", Fn: Unmarshal} 15 | 16 | // UnmarshalMetaHandler is a named request handler for unmarshaling query protocol request metadata 17 | var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.query.UnmarshalMeta", Fn: UnmarshalMeta} 18 | 19 | // Unmarshal unmarshals a response for an AWS Query service. 20 | func Unmarshal(r *request.Request) { 21 | defer r.HTTPResponse.Body.Close() 22 | if r.DataFilled() { 23 | decoder := xml.NewDecoder(r.HTTPResponse.Body) 24 | err := xmlutil.UnmarshalXML(r.Data, decoder, r.Operation.Name+"Result") 25 | if err != nil { 26 | r.Error = awserr.New("SerializationError", "failed decoding Query response", err) 27 | return 28 | } 29 | } 30 | } 31 | 32 | // UnmarshalMeta unmarshals header response values for an AWS Query service. 33 | func UnmarshalMeta(r *request.Request) { 34 | r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_error.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "encoding/xml" 5 | "io/ioutil" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | ) 10 | 11 | type xmlErrorResponse struct { 12 | XMLName xml.Name `xml:"ErrorResponse"` 13 | Code string `xml:"Error>Code"` 14 | Message string `xml:"Error>Message"` 15 | RequestID string `xml:"RequestId"` 16 | } 17 | 18 | type xmlServiceUnavailableResponse struct { 19 | XMLName xml.Name `xml:"ServiceUnavailableException"` 20 | } 21 | 22 | // UnmarshalErrorHandler is a name request handler to unmarshal request errors 23 | var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.query.UnmarshalError", Fn: UnmarshalError} 24 | 25 | // UnmarshalError unmarshals an error response for an AWS Query service. 26 | func UnmarshalError(r *request.Request) { 27 | defer r.HTTPResponse.Body.Close() 28 | 29 | bodyBytes, err := ioutil.ReadAll(r.HTTPResponse.Body) 30 | if err != nil { 31 | r.Error = awserr.New("SerializationError", "failed to read from query HTTP response body", err) 32 | return 33 | } 34 | 35 | // First check for specific error 36 | resp := xmlErrorResponse{} 37 | decodeErr := xml.Unmarshal(bodyBytes, &resp) 38 | if decodeErr == nil { 39 | reqID := resp.RequestID 40 | if reqID == "" { 41 | reqID = r.RequestID 42 | } 43 | r.Error = awserr.NewRequestFailure( 44 | awserr.New(resp.Code, resp.Message, nil), 45 | r.HTTPResponse.StatusCode, 46 | reqID, 47 | ) 48 | return 49 | } 50 | 51 | // Check for unhandled error 52 | servUnavailResp := xmlServiceUnavailableResponse{} 53 | unavailErr := xml.Unmarshal(bodyBytes, &servUnavailResp) 54 | if unavailErr == nil { 55 | r.Error = awserr.NewRequestFailure( 56 | awserr.New("ServiceUnavailableException", "service is unavailable", nil), 57 | r.HTTPResponse.StatusCode, 58 | r.RequestID, 59 | ) 60 | return 61 | } 62 | 63 | // Failed to retrieve any error message from the response body 64 | r.Error = awserr.New("SerializationError", 65 | "failed to decode query XML error response", decodeErr) 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build_test.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | "net/http" 5 | "net/url" 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | func TestCleanPath(t *testing.T) { 13 | uri := &url.URL{ 14 | Path: "//foo//bar", 15 | Scheme: "https", 16 | Host: "host", 17 | } 18 | cleanPath(uri) 19 | 20 | expected := "https://host/foo/bar" 21 | if a, e := uri.String(), expected; a != e { 22 | t.Errorf("expect %q URI, got %q", e, a) 23 | } 24 | } 25 | 26 | func TestMarshalPath(t *testing.T) { 27 | in := struct { 28 | Bucket *string `location:"uri" locationName:"bucket"` 29 | Key *string `location:"uri" locationName:"key"` 30 | }{ 31 | Bucket: aws.String("mybucket"), 32 | Key: aws.String("my/cool+thing space/object世界"), 33 | } 34 | 35 | expectURL := `/mybucket/my/cool+thing space/object世界` 36 | expectEscapedURL := `/mybucket/my/cool%2Bthing%20space/object%E4%B8%96%E7%95%8C` 37 | 38 | req := &request.Request{ 39 | HTTPRequest: &http.Request{ 40 | URL: &url.URL{Scheme: "https", Host: "exmaple.com", Path: "/{bucket}/{key+}"}, 41 | }, 42 | Params: &in, 43 | } 44 | 45 | Build(req) 46 | 47 | if req.Error != nil { 48 | t.Fatalf("unexpected error, %v", req.Error) 49 | } 50 | 51 | if a, e := req.HTTPRequest.URL.Path, expectURL; a != e { 52 | t.Errorf("expect %q URI, got %q", e, a) 53 | } 54 | 55 | if a, e := req.HTTPRequest.URL.RawPath, expectEscapedURL; a != e { 56 | t.Errorf("expect %q escaped URI, got %q", e, a) 57 | } 58 | 59 | if a, e := req.HTTPRequest.URL.EscapedPath(), expectEscapedURL; a != e { 60 | t.Errorf("expect %q escaped URI, got %q", e, a) 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import "reflect" 4 | 5 | // PayloadMember returns the payload field member of i if there is one, or nil. 6 | func PayloadMember(i interface{}) interface{} { 7 | if i == nil { 8 | return nil 9 | } 10 | 11 | v := reflect.ValueOf(i).Elem() 12 | if !v.IsValid() { 13 | return nil 14 | } 15 | if field, ok := v.Type().FieldByName("_"); ok { 16 | if payloadName := field.Tag.Get("payload"); payloadName != "" { 17 | field, _ := v.Type().FieldByName(payloadName) 18 | if field.Tag.Get("type") != "structure" { 19 | return nil 20 | } 21 | 22 | payload := v.FieldByName(payloadName) 23 | if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) { 24 | return payload.Interface() 25 | } 26 | } 27 | } 28 | return nil 29 | } 30 | 31 | // PayloadType returns the type of a payload field member of i if there is one, or "". 32 | func PayloadType(i interface{}) string { 33 | v := reflect.Indirect(reflect.ValueOf(i)) 34 | if !v.IsValid() { 35 | return "" 36 | } 37 | if field, ok := v.Type().FieldByName("_"); ok { 38 | if payloadName := field.Tag.Get("payload"); payloadName != "" { 39 | if member, ok := v.Type().FieldByName(payloadName); ok { 40 | return member.Tag.Get("type") 41 | } 42 | } 43 | } 44 | return "" 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/rest/rest_test.go: -------------------------------------------------------------------------------- 1 | package rest_test 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "net/http" 7 | "testing" 8 | 9 | "github.com/aws/aws-sdk-go/aws" 10 | "github.com/aws/aws-sdk-go/aws/client" 11 | "github.com/aws/aws-sdk-go/aws/client/metadata" 12 | "github.com/aws/aws-sdk-go/aws/request" 13 | "github.com/aws/aws-sdk-go/aws/signer/v4" 14 | "github.com/aws/aws-sdk-go/awstesting/unit" 15 | "github.com/aws/aws-sdk-go/private/protocol/rest" 16 | ) 17 | 18 | func TestUnsetHeaders(t *testing.T) { 19 | cfg := &aws.Config{Region: aws.String("us-west-2")} 20 | c := unit.Session.ClientConfig("testService", cfg) 21 | svc := client.New( 22 | *cfg, 23 | metadata.ClientInfo{ 24 | ServiceName: "testService", 25 | SigningName: c.SigningName, 26 | SigningRegion: c.SigningRegion, 27 | Endpoint: c.Endpoint, 28 | APIVersion: "", 29 | }, 30 | c.Handlers, 31 | ) 32 | 33 | // Handlers 34 | svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) 35 | svc.Handlers.Build.PushBackNamed(rest.BuildHandler) 36 | svc.Handlers.Unmarshal.PushBackNamed(rest.UnmarshalHandler) 37 | svc.Handlers.UnmarshalMeta.PushBackNamed(rest.UnmarshalMetaHandler) 38 | op := &request.Operation{ 39 | Name: "test-operation", 40 | HTTPPath: "/", 41 | } 42 | 43 | input := &struct { 44 | Foo aws.JSONValue `location:"header" locationName:"x-amz-foo" type:"jsonvalue"` 45 | Bar aws.JSONValue `location:"header" locationName:"x-amz-bar" type:"jsonvalue"` 46 | }{} 47 | 48 | output := &struct { 49 | Foo aws.JSONValue `location:"header" locationName:"x-amz-foo" type:"jsonvalue"` 50 | Bar aws.JSONValue `location:"header" locationName:"x-amz-bar" type:"jsonvalue"` 51 | }{} 52 | 53 | req := svc.NewRequest(op, input, output) 54 | req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(bytes.NewBuffer(nil)), Header: http.Header{}} 55 | req.HTTPResponse.Header.Set("X-Amz-Foo", "e30=") 56 | 57 | // unmarshal response 58 | rest.UnmarshalMeta(req) 59 | rest.Unmarshal(req) 60 | if req.Error != nil { 61 | t.Fatal(req.Error) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/restxml/restxml.go: -------------------------------------------------------------------------------- 1 | // Package restxml provides RESTful XML serialization of AWS 2 | // requests and responses. 3 | package restxml 4 | 5 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/rest-xml.json build_test.go 6 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/rest-xml.json unmarshal_test.go 7 | 8 | import ( 9 | "bytes" 10 | "encoding/xml" 11 | 12 | "github.com/aws/aws-sdk-go/aws/awserr" 13 | "github.com/aws/aws-sdk-go/aws/request" 14 | "github.com/aws/aws-sdk-go/private/protocol/query" 15 | "github.com/aws/aws-sdk-go/private/protocol/rest" 16 | "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" 17 | ) 18 | 19 | // BuildHandler is a named request handler for building restxml protocol requests 20 | var BuildHandler = request.NamedHandler{Name: "awssdk.restxml.Build", Fn: Build} 21 | 22 | // UnmarshalHandler is a named request handler for unmarshaling restxml protocol requests 23 | var UnmarshalHandler = request.NamedHandler{Name: "awssdk.restxml.Unmarshal", Fn: Unmarshal} 24 | 25 | // UnmarshalMetaHandler is a named request handler for unmarshaling restxml protocol request metadata 26 | var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.restxml.UnmarshalMeta", Fn: UnmarshalMeta} 27 | 28 | // UnmarshalErrorHandler is a named request handler for unmarshaling restxml protocol request errors 29 | var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.restxml.UnmarshalError", Fn: UnmarshalError} 30 | 31 | // Build builds a request payload for the REST XML protocol. 32 | func Build(r *request.Request) { 33 | rest.Build(r) 34 | 35 | if t := rest.PayloadType(r.Params); t == "structure" || t == "" { 36 | var buf bytes.Buffer 37 | err := xmlutil.BuildXML(r.Params, xml.NewEncoder(&buf)) 38 | if err != nil { 39 | r.Error = awserr.New("SerializationError", "failed to encode rest XML request", err) 40 | return 41 | } 42 | r.SetBufferBody(buf.Bytes()) 43 | } 44 | } 45 | 46 | // Unmarshal unmarshals a payload response for the REST XML protocol. 47 | func Unmarshal(r *request.Request) { 48 | if t := rest.PayloadType(r.Data); t == "structure" || t == "" { 49 | defer r.HTTPResponse.Body.Close() 50 | decoder := xml.NewDecoder(r.HTTPResponse.Body) 51 | err := xmlutil.UnmarshalXML(r.Data, decoder, "") 52 | if err != nil { 53 | r.Error = awserr.New("SerializationError", "failed to decode REST XML response", err) 54 | return 55 | } 56 | } else { 57 | rest.Unmarshal(r) 58 | } 59 | } 60 | 61 | // UnmarshalMeta unmarshals response headers for the REST XML protocol. 62 | func UnmarshalMeta(r *request.Request) { 63 | rest.UnmarshalMeta(r) 64 | } 65 | 66 | // UnmarshalError unmarshals a response error for the REST XML protocol. 67 | func UnmarshalError(r *request.Request) { 68 | query.UnmarshalError(r) 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/unmarshal.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | 7 | "github.com/aws/aws-sdk-go/aws/request" 8 | ) 9 | 10 | // UnmarshalDiscardBodyHandler is a named request handler to empty and close a response's body 11 | var UnmarshalDiscardBodyHandler = request.NamedHandler{Name: "awssdk.shared.UnmarshalDiscardBody", Fn: UnmarshalDiscardBody} 12 | 13 | // UnmarshalDiscardBody is a request handler to empty a response's body and closing it. 14 | func UnmarshalDiscardBody(r *request.Request) { 15 | if r.HTTPResponse == nil || r.HTTPResponse.Body == nil { 16 | return 17 | } 18 | 19 | io.Copy(ioutil.Discard, r.HTTPResponse.Body) 20 | r.HTTPResponse.Body.Close() 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/unmarshal_test.go: -------------------------------------------------------------------------------- 1 | package protocol_test 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | "github.com/aws/aws-sdk-go/private/protocol" 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | type mockCloser struct { 14 | *strings.Reader 15 | Closed bool 16 | } 17 | 18 | func (m *mockCloser) Close() error { 19 | m.Closed = true 20 | return nil 21 | } 22 | 23 | func TestUnmarshalDrainBody(t *testing.T) { 24 | b := &mockCloser{Reader: strings.NewReader("example body")} 25 | r := &request.Request{HTTPResponse: &http.Response{ 26 | Body: b, 27 | }} 28 | 29 | protocol.UnmarshalDiscardBody(r) 30 | assert.NoError(t, r.Error) 31 | assert.Equal(t, 0, b.Len()) 32 | assert.True(t, b.Closed) 33 | } 34 | 35 | func TestUnmarshalDrainBodyNoBody(t *testing.T) { 36 | r := &request.Request{HTTPResponse: &http.Response{}} 37 | 38 | protocol.UnmarshalDiscardBody(r) 39 | assert.NoError(t, r.Error) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct_test.go: -------------------------------------------------------------------------------- 1 | package xmlutil_test 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/assert" 9 | 10 | "github.com/aws/aws-sdk-go/aws" 11 | "github.com/aws/aws-sdk-go/awstesting/unit" 12 | "github.com/aws/aws-sdk-go/service/s3" 13 | ) 14 | 15 | func TestUnmarshal(t *testing.T) { 16 | xmlVal := []byte(` 17 | foo-iduserfoo-iduserFULL_CONTROL< 18 | /AccessControlPolicy>`) 19 | 20 | var server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 21 | w.Write(xmlVal) 22 | })) 23 | 24 | sess := unit.Session 25 | sess.Config.Endpoint = &server.URL 26 | sess.Config.S3ForcePathStyle = aws.Bool(true) 27 | svc := s3.New(sess) 28 | 29 | out, err := svc.GetBucketAcl(&s3.GetBucketAclInput{ 30 | Bucket: aws.String("foo"), 31 | }) 32 | 33 | assert.NoError(t, err) 34 | 35 | expected := &s3.GetBucketAclOutput{ 36 | Grants: []*s3.Grant{ 37 | { 38 | Grantee: &s3.Grantee{ 39 | DisplayName: aws.String("user"), 40 | ID: aws.String("foo-id"), 41 | Type: aws.String("type"), 42 | }, 43 | Permission: aws.String("FULL_CONTROL"), 44 | }, 45 | }, 46 | 47 | Owner: &s3.Owner{ 48 | DisplayName: aws.String("user"), 49 | ID: aws.String("foo-id"), 50 | }, 51 | } 52 | assert.Equal(t, expected, out) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/util/sort_keys.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "sort" 4 | 5 | // SortedKeys returns a sorted slice of keys of a map. 6 | func SortedKeys(m map[string]interface{}) []string { 7 | i, sorted := 0, make([]string, len(m)) 8 | for k := range m { 9 | sorted[i] = k 10 | i++ 11 | } 12 | sort.Strings(sorted) 13 | return sorted 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/util/util.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "bytes" 5 | "encoding/xml" 6 | "fmt" 7 | "go/format" 8 | "io" 9 | "reflect" 10 | "regexp" 11 | "strings" 12 | 13 | "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" 14 | ) 15 | 16 | // GoFmt returns the Go formated string of the input. 17 | // 18 | // Panics if the format fails. 19 | func GoFmt(buf string) string { 20 | formatted, err := format.Source([]byte(buf)) 21 | if err != nil { 22 | panic(fmt.Errorf("%s\nOriginal code:\n%s", err.Error(), buf)) 23 | } 24 | return string(formatted) 25 | } 26 | 27 | var reTrim = regexp.MustCompile(`\s{2,}`) 28 | 29 | // Trim removes all leading and trailing white space. 30 | // 31 | // All consecutive spaces will be reduced to a single space. 32 | func Trim(s string) string { 33 | return strings.TrimSpace(reTrim.ReplaceAllString(s, " ")) 34 | } 35 | 36 | // Capitalize capitalizes the first character of the string. 37 | func Capitalize(s string) string { 38 | if len(s) == 1 { 39 | return strings.ToUpper(s) 40 | } 41 | return strings.ToUpper(s[0:1]) + s[1:] 42 | } 43 | 44 | // SortXML sorts the reader's XML elements 45 | func SortXML(r io.Reader) string { 46 | var buf bytes.Buffer 47 | d := xml.NewDecoder(r) 48 | root, _ := xmlutil.XMLToStruct(d, nil) 49 | e := xml.NewEncoder(&buf) 50 | xmlutil.StructToXML(e, root, true) 51 | return buf.String() 52 | } 53 | 54 | // PrettyPrint generates a human readable representation of the value v. 55 | // All values of v are recursively found and pretty printed also. 56 | func PrettyPrint(v interface{}) string { 57 | value := reflect.ValueOf(v) 58 | switch value.Kind() { 59 | case reflect.Struct: 60 | str := fullName(value.Type()) + "{\n" 61 | for i := 0; i < value.NumField(); i++ { 62 | l := string(value.Type().Field(i).Name[0]) 63 | if strings.ToUpper(l) == l { 64 | str += value.Type().Field(i).Name + ": " 65 | str += PrettyPrint(value.Field(i).Interface()) 66 | str += ",\n" 67 | } 68 | } 69 | str += "}" 70 | return str 71 | case reflect.Map: 72 | str := "map[" + fullName(value.Type().Key()) + "]" + fullName(value.Type().Elem()) + "{\n" 73 | for _, k := range value.MapKeys() { 74 | str += "\"" + k.String() + "\": " 75 | str += PrettyPrint(value.MapIndex(k).Interface()) 76 | str += ",\n" 77 | } 78 | str += "}" 79 | return str 80 | case reflect.Ptr: 81 | if e := value.Elem(); e.IsValid() { 82 | return "&" + PrettyPrint(e.Interface()) 83 | } 84 | return "nil" 85 | case reflect.Slice: 86 | str := "[]" + fullName(value.Type().Elem()) + "{\n" 87 | for i := 0; i < value.Len(); i++ { 88 | str += PrettyPrint(value.Index(i).Interface()) 89 | str += ",\n" 90 | } 91 | str += "}" 92 | return str 93 | default: 94 | return fmt.Sprintf("%#v", v) 95 | } 96 | } 97 | 98 | func pkgName(t reflect.Type) string { 99 | pkg := t.PkgPath() 100 | c := strings.Split(pkg, "/") 101 | return c[len(c)-1] 102 | } 103 | 104 | func fullName(t reflect.Type) string { 105 | if pkg := pkgName(t); pkg != "" { 106 | return pkg + "." + t.Name() 107 | } 108 | return t.Name() 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/sdk.go: -------------------------------------------------------------------------------- 1 | // Package sdk is the official AWS SDK for the Go programming language. 2 | // 3 | // See our Developer Guide for information for on getting started and using 4 | // the SDK. 5 | // 6 | // https://github.com/aws/aws-sdk-go/wiki 7 | package sdk 8 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/customizations.go: -------------------------------------------------------------------------------- 1 | package dynamodb 2 | 3 | import ( 4 | "bytes" 5 | "hash/crc32" 6 | "io" 7 | "io/ioutil" 8 | "math" 9 | "strconv" 10 | "time" 11 | 12 | "github.com/aws/aws-sdk-go/aws" 13 | "github.com/aws/aws-sdk-go/aws/awserr" 14 | "github.com/aws/aws-sdk-go/aws/client" 15 | "github.com/aws/aws-sdk-go/aws/request" 16 | ) 17 | 18 | type retryer struct { 19 | client.DefaultRetryer 20 | } 21 | 22 | func (d retryer) RetryRules(r *request.Request) time.Duration { 23 | delay := time.Duration(math.Pow(2, float64(r.RetryCount))) * 50 24 | return delay * time.Millisecond 25 | } 26 | 27 | func init() { 28 | initClient = func(c *client.Client) { 29 | if c.Config.Retryer == nil { 30 | // Only override the retryer with a custom one if the config 31 | // does not already contain a retryer 32 | setCustomRetryer(c) 33 | } 34 | 35 | c.Handlers.Build.PushBack(disableCompression) 36 | c.Handlers.Unmarshal.PushFront(validateCRC32) 37 | } 38 | } 39 | 40 | func setCustomRetryer(c *client.Client) { 41 | maxRetries := aws.IntValue(c.Config.MaxRetries) 42 | if c.Config.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries { 43 | maxRetries = 10 44 | } 45 | 46 | c.Retryer = retryer{ 47 | DefaultRetryer: client.DefaultRetryer{ 48 | NumMaxRetries: maxRetries, 49 | }, 50 | } 51 | } 52 | 53 | func drainBody(b io.ReadCloser, length int64) (out *bytes.Buffer, err error) { 54 | if length < 0 { 55 | length = 0 56 | } 57 | buf := bytes.NewBuffer(make([]byte, 0, length)) 58 | 59 | if _, err = buf.ReadFrom(b); err != nil { 60 | return nil, err 61 | } 62 | if err = b.Close(); err != nil { 63 | return nil, err 64 | } 65 | return buf, nil 66 | } 67 | 68 | func disableCompression(r *request.Request) { 69 | r.HTTPRequest.Header.Set("Accept-Encoding", "identity") 70 | } 71 | 72 | func validateCRC32(r *request.Request) { 73 | if r.Error != nil { 74 | return // already have an error, no need to verify CRC 75 | } 76 | 77 | // Checksum validation is off, skip 78 | if aws.BoolValue(r.Config.DisableComputeChecksums) { 79 | return 80 | } 81 | 82 | // Try to get CRC from response 83 | header := r.HTTPResponse.Header.Get("X-Amz-Crc32") 84 | if header == "" { 85 | return // No header, skip 86 | } 87 | 88 | expected, err := strconv.ParseUint(header, 10, 32) 89 | if err != nil { 90 | return // Could not determine CRC value, skip 91 | } 92 | 93 | buf, err := drainBody(r.HTTPResponse.Body, r.HTTPResponse.ContentLength) 94 | if err != nil { // failed to read the response body, skip 95 | return 96 | } 97 | 98 | // Reset body for subsequent reads 99 | r.HTTPResponse.Body = ioutil.NopCloser(bytes.NewReader(buf.Bytes())) 100 | 101 | // Compute the CRC checksum 102 | crc := crc32.ChecksumIEEE(buf.Bytes()) 103 | 104 | if crc != uint32(expected) { 105 | // CRC does not match, set a retryable error 106 | r.Retryable = aws.Bool(true) 107 | r.Error = awserr.New("CRC32CheckFailed", "CRC32 integrity check failed", nil) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/converter_examples_test.go: -------------------------------------------------------------------------------- 1 | package dynamodbattribute_test 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" 8 | ) 9 | 10 | func ExampleConvertTo() { 11 | type Record struct { 12 | MyField string 13 | Letters []string 14 | Numbers []int 15 | } 16 | 17 | r := Record{ 18 | MyField: "MyFieldValue", 19 | Letters: []string{"a", "b", "c", "d"}, 20 | Numbers: []int{1, 2, 3}, 21 | } 22 | av, err := dynamodbattribute.ConvertTo(r) 23 | fmt.Println("err", err) 24 | fmt.Println("MyField", av.M["MyField"]) 25 | fmt.Println("Letters", av.M["Letters"]) 26 | fmt.Println("Numbers", av.M["Numbers"]) 27 | 28 | // Output: 29 | // err 30 | // MyField { 31 | // S: "MyFieldValue" 32 | // } 33 | // Letters { 34 | // L: [ 35 | // { 36 | // S: "a" 37 | // }, 38 | // { 39 | // S: "b" 40 | // }, 41 | // { 42 | // S: "c" 43 | // }, 44 | // { 45 | // S: "d" 46 | // } 47 | // ] 48 | // } 49 | // Numbers { 50 | // L: [{ 51 | // N: "1" 52 | // },{ 53 | // N: "2" 54 | // },{ 55 | // N: "3" 56 | // }] 57 | // } 58 | } 59 | 60 | func ExampleConvertFrom() { 61 | type Record struct { 62 | MyField string 63 | Letters []string 64 | A2Num map[string]int 65 | } 66 | 67 | r := Record{ 68 | MyField: "MyFieldValue", 69 | Letters: []string{"a", "b", "c", "d"}, 70 | A2Num: map[string]int{"a": 1, "b": 2, "c": 3}, 71 | } 72 | av, err := dynamodbattribute.ConvertTo(r) 73 | 74 | r2 := Record{} 75 | err = dynamodbattribute.ConvertFrom(av, &r2) 76 | fmt.Println(err, reflect.DeepEqual(r, r2)) 77 | 78 | // Output: 79 | // true 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/doc.go: -------------------------------------------------------------------------------- 1 | // Package dynamodbattribute provides marshaling utilities for marshaling to 2 | // dynamodb.AttributeValue types and unmarshaling to Go value types. These 3 | // utilities allow you to marshal slices, maps, structs, and scalar values 4 | // to and from dynamodb.AttributeValue. These are useful when marshaling 5 | // Go value tyes to dynamodb.AttributeValue for DynamoDB requests, or 6 | // unmarshaling the dynamodb.AttributeValue back into a Go value type. 7 | // 8 | // Marshal Go value types to dynamodb.AttributeValue: See (ExampleMarshal) 9 | // 10 | // type Record struct { 11 | // MyField string 12 | // Letters []string 13 | // A2Num map[string]int 14 | // } 15 | // 16 | // ... 17 | // 18 | // r := Record{ 19 | // MyField: "dynamodbattribute.Marshal example", 20 | // Letters: []string{"a", "b", "c", "d"}, 21 | // A2Num: map[string]int{"a": 1, "b": 2, "c": 3}, 22 | // } 23 | // av, err := dynamodbattribute.Marshal(r) 24 | // fmt.Println(av, err) 25 | // 26 | // Unmarshal dynamodb.AttributeValue to Go value type: See (ExampleUnmarshal) 27 | // 28 | // r2 := Record{} 29 | // err = dynamodbattribute.Unmarshal(av, &r2) 30 | // fmt.Println(err, reflect.DeepEqual(r, r2)) 31 | // 32 | // Marshal Go value type for DynamoDB.PutItem: 33 | // 34 | // sess := session.Must(session.NewSession()) 35 | // 36 | // svc := dynamodb.New(sess) 37 | // item, err := dynamodbattribute.MarshalMap(r) 38 | // if err != nil { 39 | // fmt.Println("Failed to convert", err) 40 | // return 41 | // } 42 | // result, err := svc.PutItem(&dynamodb.PutItemInput{ 43 | // Item: item, 44 | // TableName: aws.String("exampleTable"), 45 | // }) 46 | // 47 | // 48 | // 49 | // The ConvertTo, ConvertToList, ConvertToMap, ConvertFrom, ConvertFromMap 50 | // and ConvertFromList methods have been deprecated. The Marshal and Unmarshal 51 | // functions should be used instead. The ConvertTo|From marshallers do not 52 | // support BinarySet, NumberSet, nor StringSets, and will incorrect marshal 53 | // binary data fields in structs as base64 strings. 54 | // 55 | // The Marshal and Unmarshal functions correct this behavior, and removes 56 | // the reliance on encoding.json. `json` struct tags are still supported. In 57 | // addition support for a new struct tag `dynamodbav` was added. Support for 58 | // the json.Marshaler and json.Unmarshaler interfaces have been removed and 59 | // replaced with have been replaced with dynamodbattribute.Marshaler and 60 | // dynamodbattribute.Unmarshaler interfaces. 61 | // 62 | // `time.Time` is marshaled as RFC3339 format. 63 | package dynamodbattribute 64 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/field_test.go: -------------------------------------------------------------------------------- 1 | package dynamodbattribute 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | type testUnionValues struct { 11 | Name string 12 | Value interface{} 13 | } 14 | 15 | type unionSimple struct { 16 | A int 17 | B string 18 | C []string 19 | } 20 | 21 | type unionComplex struct { 22 | unionSimple 23 | A int 24 | } 25 | 26 | type unionTagged struct { 27 | A int `json:"A"` 28 | } 29 | 30 | type unionTaggedComplex struct { 31 | unionSimple 32 | unionTagged 33 | B string 34 | } 35 | 36 | func TestUnionStructFields(t *testing.T) { 37 | var cases = []struct { 38 | in interface{} 39 | expect []testUnionValues 40 | }{ 41 | { 42 | in: unionSimple{1, "2", []string{"abc"}}, 43 | expect: []testUnionValues{ 44 | {"A", 1}, 45 | {"B", "2"}, 46 | {"C", []string{"abc"}}, 47 | }, 48 | }, 49 | { 50 | in: unionComplex{ 51 | unionSimple: unionSimple{1, "2", []string{"abc"}}, 52 | A: 2, 53 | }, 54 | expect: []testUnionValues{ 55 | {"B", "2"}, 56 | {"C", []string{"abc"}}, 57 | {"A", 2}, 58 | }, 59 | }, 60 | { 61 | in: unionTaggedComplex{ 62 | unionSimple: unionSimple{1, "2", []string{"abc"}}, 63 | unionTagged: unionTagged{3}, 64 | B: "3", 65 | }, 66 | expect: []testUnionValues{ 67 | {"C", []string{"abc"}}, 68 | {"A", 3}, 69 | {"B", "3"}, 70 | }, 71 | }, 72 | } 73 | 74 | for i, c := range cases { 75 | v := reflect.ValueOf(c.in) 76 | 77 | fields := unionStructFields(v.Type(), MarshalOptions{SupportJSONTags: true}) 78 | for j, f := range fields { 79 | expected := c.expect[j] 80 | assert.Equal(t, expected.Name, f.Name, "case %d, field %d", i, j) 81 | actual := v.FieldByIndex(f.Index).Interface() 82 | assert.EqualValues(t, expected.Value, actual, "case %d, field %d", i, j) 83 | } 84 | } 85 | } 86 | 87 | func TestFieldByName(t *testing.T) { 88 | fields := []field{ 89 | {Name: "Abc"}, {Name: "mixCase"}, {Name: "UPPERCASE"}, 90 | } 91 | 92 | cases := []struct { 93 | Name, FieldName string 94 | Found bool 95 | }{ 96 | {"abc", "Abc", true}, {"ABC", "Abc", true}, {"Abc", "Abc", true}, 97 | {"123", "", false}, 98 | {"ab", "", false}, 99 | {"MixCase", "mixCase", true}, 100 | {"uppercase", "UPPERCASE", true}, {"UPPERCASE", "UPPERCASE", true}, 101 | } 102 | 103 | for _, c := range cases { 104 | f, ok := fieldByName(fields, c.Name) 105 | assert.Equal(t, c.Found, ok) 106 | if ok { 107 | assert.Equal(t, c.FieldName, f.Name) 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/marshaler_examples_test.go: -------------------------------------------------------------------------------- 1 | package dynamodbattribute_test 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/aws/aws-sdk-go/aws" 8 | "github.com/aws/aws-sdk-go/service/dynamodb" 9 | "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" 10 | ) 11 | 12 | func ExampleMarshal() { 13 | type Record struct { 14 | Bytes []byte 15 | MyField string 16 | Letters []string 17 | Numbers []int 18 | } 19 | 20 | r := Record{ 21 | Bytes: []byte{48, 49}, 22 | MyField: "MyFieldValue", 23 | Letters: []string{"a", "b", "c", "d"}, 24 | Numbers: []int{1, 2, 3}, 25 | } 26 | av, err := dynamodbattribute.Marshal(r) 27 | fmt.Println("err", err) 28 | fmt.Println("Bytes", av.M["Bytes"]) 29 | fmt.Println("MyField", av.M["MyField"]) 30 | fmt.Println("Letters", av.M["Letters"]) 31 | fmt.Println("Numbers", av.M["Numbers"]) 32 | 33 | // Output: 34 | // err 35 | // Bytes { 36 | // B: len 2 37 | // } 38 | // MyField { 39 | // S: "MyFieldValue" 40 | // } 41 | // Letters { 42 | // L: [ 43 | // { 44 | // S: "a" 45 | // }, 46 | // { 47 | // S: "b" 48 | // }, 49 | // { 50 | // S: "c" 51 | // }, 52 | // { 53 | // S: "d" 54 | // } 55 | // ] 56 | // } 57 | // Numbers { 58 | // L: [{ 59 | // N: "1" 60 | // },{ 61 | // N: "2" 62 | // },{ 63 | // N: "3" 64 | // }] 65 | // } 66 | } 67 | 68 | func ExampleUnmarshal() { 69 | type Record struct { 70 | Bytes []byte 71 | MyField string 72 | Letters []string 73 | A2Num map[string]int 74 | } 75 | 76 | expect := Record{ 77 | Bytes: []byte{48, 49}, 78 | MyField: "MyFieldValue", 79 | Letters: []string{"a", "b", "c", "d"}, 80 | A2Num: map[string]int{"a": 1, "b": 2, "c": 3}, 81 | } 82 | 83 | av := &dynamodb.AttributeValue{ 84 | M: map[string]*dynamodb.AttributeValue{ 85 | "Bytes": {B: []byte{48, 49}}, 86 | "MyField": {S: aws.String("MyFieldValue")}, 87 | "Letters": {L: []*dynamodb.AttributeValue{ 88 | {S: aws.String("a")}, {S: aws.String("b")}, {S: aws.String("c")}, {S: aws.String("d")}, 89 | }}, 90 | "A2Num": {M: map[string]*dynamodb.AttributeValue{ 91 | "a": {N: aws.String("1")}, 92 | "b": {N: aws.String("2")}, 93 | "c": {N: aws.String("3")}, 94 | }}, 95 | }, 96 | } 97 | 98 | actual := Record{} 99 | err := dynamodbattribute.Unmarshal(av, &actual) 100 | fmt.Println(err, reflect.DeepEqual(expect, actual)) 101 | 102 | // Output: 103 | // true 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/tag.go: -------------------------------------------------------------------------------- 1 | package dynamodbattribute 2 | 3 | import ( 4 | "reflect" 5 | "strings" 6 | ) 7 | 8 | type tag struct { 9 | Name string 10 | Ignore bool 11 | OmitEmpty bool 12 | OmitEmptyElem bool 13 | AsString bool 14 | AsBinSet, AsNumSet, AsStrSet bool 15 | AsUnixTime bool 16 | } 17 | 18 | func (t *tag) parseAVTag(structTag reflect.StructTag) { 19 | tagStr := structTag.Get("dynamodbav") 20 | if len(tagStr) == 0 { 21 | return 22 | } 23 | 24 | t.parseTagStr(tagStr) 25 | } 26 | 27 | func (t *tag) parseJSONTag(structTag reflect.StructTag) { 28 | tagStr := structTag.Get("json") 29 | if len(tagStr) == 0 { 30 | return 31 | } 32 | 33 | t.parseTagStr(tagStr) 34 | } 35 | 36 | func (t *tag) parseTagStr(tagStr string) { 37 | parts := strings.Split(tagStr, ",") 38 | if len(parts) == 0 { 39 | return 40 | } 41 | 42 | if name := parts[0]; name == "-" { 43 | t.Name = "" 44 | t.Ignore = true 45 | } else { 46 | t.Name = name 47 | t.Ignore = false 48 | } 49 | 50 | for _, opt := range parts[1:] { 51 | switch opt { 52 | case "omitempty": 53 | t.OmitEmpty = true 54 | case "omitemptyelem": 55 | t.OmitEmptyElem = true 56 | case "string": 57 | t.AsString = true 58 | case "binaryset": 59 | t.AsBinSet = true 60 | case "numberset": 61 | t.AsNumSet = true 62 | case "stringset": 63 | t.AsStrSet = true 64 | case "unixtime": 65 | t.AsUnixTime = true 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/tag_test.go: -------------------------------------------------------------------------------- 1 | package dynamodbattribute 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestTagParse(t *testing.T) { 11 | cases := []struct { 12 | in reflect.StructTag 13 | json, av bool 14 | expect tag 15 | }{ 16 | {`json:""`, true, false, tag{}}, 17 | {`json:"name"`, true, false, tag{Name: "name"}}, 18 | {`json:"name,omitempty"`, true, false, tag{Name: "name", OmitEmpty: true}}, 19 | {`json:"-"`, true, false, tag{Ignore: true}}, 20 | {`json:",omitempty"`, true, false, tag{OmitEmpty: true}}, 21 | {`json:",string"`, true, false, tag{AsString: true}}, 22 | {`dynamodbav:""`, false, true, tag{}}, 23 | {`dynamodbav:","`, false, true, tag{}}, 24 | {`dynamodbav:"name"`, false, true, tag{Name: "name"}}, 25 | {`dynamodbav:"name"`, false, true, tag{Name: "name"}}, 26 | {`dynamodbav:"-"`, false, true, tag{Ignore: true}}, 27 | {`dynamodbav:",omitempty"`, false, true, tag{OmitEmpty: true}}, 28 | {`dynamodbav:",omitemptyelem"`, false, true, tag{OmitEmptyElem: true}}, 29 | {`dynamodbav:",string"`, false, true, tag{AsString: true}}, 30 | {`dynamodbav:",binaryset"`, false, true, tag{AsBinSet: true}}, 31 | {`dynamodbav:",numberset"`, false, true, tag{AsNumSet: true}}, 32 | {`dynamodbav:",stringset"`, false, true, tag{AsStrSet: true}}, 33 | {`dynamodbav:",stringset,omitemptyelem"`, false, true, tag{AsStrSet: true, OmitEmptyElem: true}}, 34 | {`dynamodbav:"name,stringset,omitemptyelem"`, false, true, tag{Name: "name", AsStrSet: true, OmitEmptyElem: true}}, 35 | } 36 | 37 | for i, c := range cases { 38 | actual := tag{} 39 | if c.json { 40 | actual.parseJSONTag(c.in) 41 | } 42 | if c.av { 43 | actual.parseAVTag(c.in) 44 | } 45 | assert.Equal(t, c.expect, actual, "case %d", i+1) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/dynamodb/errors.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package dynamodb 4 | 5 | const ( 6 | 7 | // ErrCodeConditionalCheckFailedException for service response error code 8 | // "ConditionalCheckFailedException". 9 | // 10 | // A condition specified in the operation could not be evaluated. 11 | ErrCodeConditionalCheckFailedException = "ConditionalCheckFailedException" 12 | 13 | // ErrCodeInternalServerError for service response error code 14 | // "InternalServerError". 15 | // 16 | // An error occurred on the server side. 17 | ErrCodeInternalServerError = "InternalServerError" 18 | 19 | // ErrCodeItemCollectionSizeLimitExceededException for service response error code 20 | // "ItemCollectionSizeLimitExceededException". 21 | // 22 | // An item collection is too large. This exception is only returned for tables 23 | // that have one or more local secondary indexes. 24 | ErrCodeItemCollectionSizeLimitExceededException = "ItemCollectionSizeLimitExceededException" 25 | 26 | // ErrCodeLimitExceededException for service response error code 27 | // "LimitExceededException". 28 | // 29 | // The number of concurrent table requests (cumulative number of tables in the 30 | // CREATING, DELETING or UPDATING state) exceeds the maximum allowed of 10. 31 | // 32 | // Also, for tables with secondary indexes, only one of those tables can be 33 | // in the CREATING state at any point in time. Do not attempt to create more 34 | // than one such table simultaneously. 35 | // 36 | // The total limit of tables in the ACTIVE state is 250. 37 | ErrCodeLimitExceededException = "LimitExceededException" 38 | 39 | // ErrCodeProvisionedThroughputExceededException for service response error code 40 | // "ProvisionedThroughputExceededException". 41 | // 42 | // Your request rate is too high. The AWS SDKs for DynamoDB automatically retry 43 | // requests that receive this exception. Your request is eventually successful, 44 | // unless your retry queue is too large to finish. Reduce the frequency of requests 45 | // and use exponential backoff. For more information, go to Error Retries and 46 | // Exponential Backoff (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff) 47 | // in the Amazon DynamoDB Developer Guide. 48 | ErrCodeProvisionedThroughputExceededException = "ProvisionedThroughputExceededException" 49 | 50 | // ErrCodeResourceInUseException for service response error code 51 | // "ResourceInUseException". 52 | // 53 | // The operation conflicts with the resource's availability. For example, you 54 | // attempted to recreate an existing table, or tried to delete a table currently 55 | // in the CREATING state. 56 | ErrCodeResourceInUseException = "ResourceInUseException" 57 | 58 | // ErrCodeResourceNotFoundException for service response error code 59 | // "ResourceNotFoundException". 60 | // 61 | // The operation tried to access a nonexistent table or index. The resource 62 | // might not be specified correctly, or its status might not be ACTIVE. 63 | ErrCodeResourceNotFoundException = "ResourceNotFoundException" 64 | ) 65 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/ec2/customizations.go: -------------------------------------------------------------------------------- 1 | package ec2 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/awsutil" 8 | "github.com/aws/aws-sdk-go/aws/endpoints" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | func init() { 13 | initRequest = func(r *request.Request) { 14 | if r.Operation.Name == opCopySnapshot { // fill the PresignedURL parameter 15 | r.Handlers.Build.PushFront(fillPresignedURL) 16 | } 17 | } 18 | } 19 | 20 | func fillPresignedURL(r *request.Request) { 21 | if !r.ParamsFilled() { 22 | return 23 | } 24 | 25 | origParams := r.Params.(*CopySnapshotInput) 26 | 27 | // Stop if PresignedURL/DestinationRegion is set 28 | if origParams.PresignedUrl != nil || origParams.DestinationRegion != nil { 29 | return 30 | } 31 | 32 | origParams.DestinationRegion = r.Config.Region 33 | newParams := awsutil.CopyOf(r.Params).(*CopySnapshotInput) 34 | 35 | // Create a new request based on the existing request. We will use this to 36 | // presign the CopySnapshot request against the source region. 37 | cfg := r.Config.Copy(aws.NewConfig(). 38 | WithEndpoint(""). 39 | WithRegion(aws.StringValue(origParams.SourceRegion))) 40 | 41 | clientInfo := r.ClientInfo 42 | resolved, err := r.Config.EndpointResolver.EndpointFor( 43 | clientInfo.ServiceName, aws.StringValue(cfg.Region), 44 | func(opt *endpoints.Options) { 45 | opt.DisableSSL = aws.BoolValue(cfg.DisableSSL) 46 | opt.UseDualStack = aws.BoolValue(cfg.UseDualStack) 47 | }, 48 | ) 49 | if err != nil { 50 | r.Error = err 51 | return 52 | } 53 | 54 | clientInfo.Endpoint = resolved.URL 55 | clientInfo.SigningRegion = resolved.SigningRegion 56 | 57 | // Presign a CopySnapshot request with modified params 58 | req := request.New(*cfg, clientInfo, r.Handlers, r.Retryer, r.Operation, newParams, r.Data) 59 | url, err := req.Presign(5 * time.Minute) // 5 minutes should be enough. 60 | if err != nil { // bubble error back up to original request 61 | r.Error = err 62 | return 63 | } 64 | 65 | // We have our URL, set it on params 66 | origParams.PresignedUrl = &url 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/ec2/customizations_test.go: -------------------------------------------------------------------------------- 1 | package ec2_test 2 | 3 | import ( 4 | "io/ioutil" 5 | "net/url" 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/awstesting/unit" 10 | "github.com/aws/aws-sdk-go/service/ec2" 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | func TestCopySnapshotPresignedURL(t *testing.T) { 15 | svc := ec2.New(unit.Session, &aws.Config{Region: aws.String("us-west-2")}) 16 | 17 | assert.NotPanics(t, func() { 18 | // Doesn't panic on nil input 19 | req, _ := svc.CopySnapshotRequest(nil) 20 | req.Sign() 21 | }) 22 | 23 | req, _ := svc.CopySnapshotRequest(&ec2.CopySnapshotInput{ 24 | SourceRegion: aws.String("us-west-1"), 25 | SourceSnapshotId: aws.String("snap-id"), 26 | }) 27 | req.Sign() 28 | 29 | b, _ := ioutil.ReadAll(req.HTTPRequest.Body) 30 | q, _ := url.ParseQuery(string(b)) 31 | u, _ := url.QueryUnescape(q.Get("PresignedUrl")) 32 | assert.Equal(t, "us-west-2", q.Get("DestinationRegion")) 33 | assert.Equal(t, "us-west-1", q.Get("SourceRegion")) 34 | assert.Regexp(t, `^https://ec2\.us-west-1\.amazonaws\.com/.+&DestinationRegion=us-west-2`, u) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/ec2/errors.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package ec2 4 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/elastictranscoder/errors.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package elastictranscoder 4 | 5 | const ( 6 | 7 | // ErrCodeAccessDeniedException for service response error code 8 | // "AccessDeniedException". 9 | // 10 | // General authentication failure. The request was not signed correctly. 11 | ErrCodeAccessDeniedException = "AccessDeniedException" 12 | 13 | // ErrCodeIncompatibleVersionException for service response error code 14 | // "IncompatibleVersionException". 15 | ErrCodeIncompatibleVersionException = "IncompatibleVersionException" 16 | 17 | // ErrCodeInternalServiceException for service response error code 18 | // "InternalServiceException". 19 | // 20 | // Elastic Transcoder encountered an unexpected exception while trying to fulfill 21 | // the request. 22 | ErrCodeInternalServiceException = "InternalServiceException" 23 | 24 | // ErrCodeLimitExceededException for service response error code 25 | // "LimitExceededException". 26 | // 27 | // Too many operations for a given AWS account. For example, the number of pipelines 28 | // exceeds the maximum allowed. 29 | ErrCodeLimitExceededException = "LimitExceededException" 30 | 31 | // ErrCodeResourceInUseException for service response error code 32 | // "ResourceInUseException". 33 | // 34 | // The resource you are attempting to change is in use. For example, you are 35 | // attempting to delete a pipeline that is currently in use. 36 | ErrCodeResourceInUseException = "ResourceInUseException" 37 | 38 | // ErrCodeResourceNotFoundException for service response error code 39 | // "ResourceNotFoundException". 40 | // 41 | // The requested resource does not exist or is not available. For example, the 42 | // pipeline to which you're trying to add a job doesn't exist or is still being 43 | // created. 44 | ErrCodeResourceNotFoundException = "ResourceNotFoundException" 45 | 46 | // ErrCodeValidationException for service response error code 47 | // "ValidationException". 48 | // 49 | // One or more required parameter values were not provided in the request. 50 | ErrCodeValidationException = "ValidationException" 51 | ) 52 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/elastictranscoder/waiters.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package elastictranscoder 4 | 5 | import ( 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | // WaitUntilJobComplete uses the Amazon Elastic Transcoder API operation 13 | // ReadJob to wait for a condition to be met before returning. 14 | // If the condition is not meet within the max attempt window an error will 15 | // be returned. 16 | func (c *ElasticTranscoder) WaitUntilJobComplete(input *ReadJobInput) error { 17 | return c.WaitUntilJobCompleteWithContext(aws.BackgroundContext(), input) 18 | } 19 | 20 | // WaitUntilJobCompleteWithContext is an extended version of WaitUntilJobComplete. 21 | // With the support for passing in a context and options to configure the 22 | // Waiter and the underlying request options. 23 | // 24 | // The context must be non-nil and will be used for request cancellation. If 25 | // the context is nil a panic will occur. In the future the SDK may create 26 | // sub-contexts for http.Requests. See https://golang.org/pkg/context/ 27 | // for more information on using Contexts. 28 | func (c *ElasticTranscoder) WaitUntilJobCompleteWithContext(ctx aws.Context, input *ReadJobInput, opts ...request.WaiterOption) error { 29 | w := request.Waiter{ 30 | Name: "WaitUntilJobComplete", 31 | MaxAttempts: 120, 32 | Delay: request.ConstantWaiterDelay(30 * time.Second), 33 | Acceptors: []request.WaiterAcceptor{ 34 | { 35 | State: request.SuccessWaiterState, 36 | Matcher: request.PathWaiterMatch, Argument: "Job.Status", 37 | Expected: "Complete", 38 | }, 39 | { 40 | State: request.FailureWaiterState, 41 | Matcher: request.PathWaiterMatch, Argument: "Job.Status", 42 | Expected: "Canceled", 43 | }, 44 | { 45 | State: request.FailureWaiterState, 46 | Matcher: request.PathWaiterMatch, Argument: "Job.Status", 47 | Expected: "Error", 48 | }, 49 | }, 50 | Logger: c.Config.Logger, 51 | NewRequest: func(opts []request.Option) (*request.Request, error) { 52 | var inCpy *ReadJobInput 53 | if input != nil { 54 | tmp := *input 55 | inCpy = &tmp 56 | } 57 | req, _ := c.ReadJobRequest(inCpy) 58 | req.SetContext(ctx) 59 | req.ApplyOptions(opts...) 60 | return req, nil 61 | }, 62 | } 63 | w.ApplyOptions(opts...) 64 | 65 | return w.WaitWithContext(ctx) 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/kinesis/errors.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package kinesis 4 | 5 | const ( 6 | 7 | // ErrCodeExpiredIteratorException for service response error code 8 | // "ExpiredIteratorException". 9 | // 10 | // The provided iterator exceeds the maximum age allowed. 11 | ErrCodeExpiredIteratorException = "ExpiredIteratorException" 12 | 13 | // ErrCodeInvalidArgumentException for service response error code 14 | // "InvalidArgumentException". 15 | // 16 | // A specified parameter exceeds its restrictions, is not supported, or can't 17 | // be used. For more information, see the returned message. 18 | ErrCodeInvalidArgumentException = "InvalidArgumentException" 19 | 20 | // ErrCodeLimitExceededException for service response error code 21 | // "LimitExceededException". 22 | // 23 | // The requested resource exceeds the maximum number allowed, or the number 24 | // of concurrent stream requests exceeds the maximum number allowed (5). 25 | ErrCodeLimitExceededException = "LimitExceededException" 26 | 27 | // ErrCodeProvisionedThroughputExceededException for service response error code 28 | // "ProvisionedThroughputExceededException". 29 | // 30 | // The request rate for the stream is too high, or the requested data is too 31 | // large for the available throughput. Reduce the frequency or size of your 32 | // requests. For more information, see Streams Limits (http://docs.aws.amazon.com/kinesis/latest/dev/service-sizes-and-limits.html) 33 | // in the Amazon Kinesis Streams Developer Guide, and Error Retries and Exponential 34 | // Backoff in AWS (http://docs.aws.amazon.com/general/latest/gr/api-retries.html) 35 | // in the AWS General Reference. 36 | ErrCodeProvisionedThroughputExceededException = "ProvisionedThroughputExceededException" 37 | 38 | // ErrCodeResourceInUseException for service response error code 39 | // "ResourceInUseException". 40 | // 41 | // The resource is not available for this operation. For successful operation, 42 | // the resource needs to be in the ACTIVE state. 43 | ErrCodeResourceInUseException = "ResourceInUseException" 44 | 45 | // ErrCodeResourceNotFoundException for service response error code 46 | // "ResourceNotFoundException". 47 | // 48 | // The requested resource could not be found. The stream might not be specified 49 | // correctly. 50 | ErrCodeResourceNotFoundException = "ResourceNotFoundException" 51 | ) 52 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/kinesis/waiters.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package kinesis 4 | 5 | import ( 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | // WaitUntilStreamExists uses the Kinesis API operation 13 | // DescribeStream to wait for a condition to be met before returning. 14 | // If the condition is not meet within the max attempt window an error will 15 | // be returned. 16 | func (c *Kinesis) WaitUntilStreamExists(input *DescribeStreamInput) error { 17 | return c.WaitUntilStreamExistsWithContext(aws.BackgroundContext(), input) 18 | } 19 | 20 | // WaitUntilStreamExistsWithContext is an extended version of WaitUntilStreamExists. 21 | // With the support for passing in a context and options to configure the 22 | // Waiter and the underlying request options. 23 | // 24 | // The context must be non-nil and will be used for request cancellation. If 25 | // the context is nil a panic will occur. In the future the SDK may create 26 | // sub-contexts for http.Requests. See https://golang.org/pkg/context/ 27 | // for more information on using Contexts. 28 | func (c *Kinesis) WaitUntilStreamExistsWithContext(ctx aws.Context, input *DescribeStreamInput, opts ...request.WaiterOption) error { 29 | w := request.Waiter{ 30 | Name: "WaitUntilStreamExists", 31 | MaxAttempts: 18, 32 | Delay: request.ConstantWaiterDelay(10 * time.Second), 33 | Acceptors: []request.WaiterAcceptor{ 34 | { 35 | State: request.SuccessWaiterState, 36 | Matcher: request.PathWaiterMatch, Argument: "StreamDescription.StreamStatus", 37 | Expected: "ACTIVE", 38 | }, 39 | }, 40 | Logger: c.Config.Logger, 41 | NewRequest: func(opts []request.Option) (*request.Request, error) { 42 | var inCpy *DescribeStreamInput 43 | if input != nil { 44 | tmp := *input 45 | inCpy = &tmp 46 | } 47 | req, _ := c.DescribeStreamRequest(inCpy) 48 | req.SetContext(ctx) 49 | req.ApplyOptions(opts...) 50 | return req, nil 51 | }, 52 | } 53 | w.ApplyOptions(opts...) 54 | 55 | return w.WaitWithContext(ctx) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/route53/customizations.go: -------------------------------------------------------------------------------- 1 | package route53 2 | 3 | import ( 4 | "net/url" 5 | "regexp" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | "github.com/aws/aws-sdk-go/aws/client" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/private/protocol/restxml" 11 | ) 12 | 13 | func init() { 14 | initClient = func(c *client.Client) { 15 | c.Handlers.Build.PushBack(sanitizeURL) 16 | } 17 | 18 | initRequest = func(r *request.Request) { 19 | switch r.Operation.Name { 20 | case opChangeResourceRecordSets: 21 | r.Handlers.UnmarshalError.Remove(restxml.UnmarshalErrorHandler) 22 | r.Handlers.UnmarshalError.PushBack(unmarshalChangeResourceRecordSetsError) 23 | } 24 | } 25 | } 26 | 27 | var reSanitizeURL = regexp.MustCompile(`\/%2F\w+%2F`) 28 | 29 | func sanitizeURL(r *request.Request) { 30 | r.HTTPRequest.URL.RawPath = 31 | reSanitizeURL.ReplaceAllString(r.HTTPRequest.URL.RawPath, "/") 32 | 33 | // Update Path so that it reflects the cleaned RawPath 34 | updated, err := url.Parse(r.HTTPRequest.URL.RawPath) 35 | if err != nil { 36 | r.Error = awserr.New("SerializationError", "failed to clean Route53 URL", err) 37 | return 38 | } 39 | 40 | // Take the updated path so the requests's URL Path has parity with RawPath. 41 | r.HTTPRequest.URL.Path = updated.Path 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/route53/customizations_test.go: -------------------------------------------------------------------------------- 1 | package route53_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/awstesting/unit" 8 | "github.com/aws/aws-sdk-go/service/route53" 9 | ) 10 | 11 | func TestBuildCorrectURI(t *testing.T) { 12 | const expectPath = "/2013-04-01/hostedzone/ABCDEFG" 13 | 14 | svc := route53.New(unit.Session) 15 | svc.Handlers.Validate.Clear() 16 | req, _ := svc.GetHostedZoneRequest(&route53.GetHostedZoneInput{ 17 | Id: aws.String("/hostedzone/ABCDEFG"), 18 | }) 19 | 20 | req.HTTPRequest.URL.RawQuery = "abc=123" 21 | 22 | req.Build() 23 | 24 | if a, e := req.HTTPRequest.URL.Path, expectPath; a != e { 25 | t.Errorf("expect path %q, got %q", e, a) 26 | } 27 | 28 | if a, e := req.HTTPRequest.URL.RawPath, expectPath; a != e { 29 | t.Errorf("expect raw path %q, got %q", e, a) 30 | } 31 | 32 | if a, e := req.HTTPRequest.URL.RawQuery, "abc=123"; a != e { 33 | t.Errorf("expect query to be %q, got %q", e, a) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/route53/unmarshal_error.go: -------------------------------------------------------------------------------- 1 | package route53 2 | 3 | import ( 4 | "bytes" 5 | "encoding/xml" 6 | "io/ioutil" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/private/protocol/restxml" 11 | ) 12 | 13 | type baseXMLErrorResponse struct { 14 | XMLName xml.Name 15 | } 16 | 17 | type standardXMLErrorResponse struct { 18 | XMLName xml.Name `xml:"ErrorResponse"` 19 | Code string `xml:"Error>Code"` 20 | Message string `xml:"Error>Message"` 21 | RequestID string `xml:"RequestId"` 22 | } 23 | 24 | type invalidChangeBatchXMLErrorResponse struct { 25 | XMLName xml.Name `xml:"InvalidChangeBatch"` 26 | Messages []string `xml:"Messages>Message"` 27 | } 28 | 29 | func unmarshalChangeResourceRecordSetsError(r *request.Request) { 30 | defer r.HTTPResponse.Body.Close() 31 | 32 | responseBody, err := ioutil.ReadAll(r.HTTPResponse.Body) 33 | 34 | if err != nil { 35 | r.Error = awserr.New("SerializationError", "failed to read Route53 XML error response", err) 36 | return 37 | } 38 | 39 | baseError := &baseXMLErrorResponse{} 40 | 41 | if err := xml.Unmarshal(responseBody, baseError); err != nil { 42 | r.Error = awserr.New("SerializationError", "failed to decode Route53 XML error response", err) 43 | return 44 | } 45 | 46 | switch baseError.XMLName.Local { 47 | case "InvalidChangeBatch": 48 | unmarshalInvalidChangeBatchError(r, responseBody) 49 | default: 50 | r.HTTPResponse.Body = ioutil.NopCloser(bytes.NewReader(responseBody)) 51 | restxml.UnmarshalError(r) 52 | } 53 | } 54 | 55 | func unmarshalInvalidChangeBatchError(r *request.Request, requestBody []byte) { 56 | resp := &invalidChangeBatchXMLErrorResponse{} 57 | err := xml.Unmarshal(requestBody, resp) 58 | 59 | if err != nil { 60 | r.Error = awserr.New("SerializationError", "failed to decode query XML error response", err) 61 | return 62 | } 63 | 64 | const errorCode = "InvalidChangeBatch" 65 | errors := []error{} 66 | 67 | for _, msg := range resp.Messages { 68 | errors = append(errors, awserr.New(errorCode, msg, nil)) 69 | } 70 | 71 | r.Error = awserr.NewRequestFailure( 72 | awserr.NewBatchError(errorCode, "ChangeBatch errors occurred", errors), 73 | r.HTTPResponse.StatusCode, 74 | r.RequestID, 75 | ) 76 | 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/route53/unmarshal_error_leak_test.go: -------------------------------------------------------------------------------- 1 | package route53 2 | 3 | import ( 4 | "net/http" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/awstesting" 11 | ) 12 | 13 | func TestUnmarhsalErrorLeak(t *testing.T) { 14 | req := &request.Request{ 15 | Operation: &request.Operation{ 16 | Name: opChangeResourceRecordSets, 17 | }, 18 | HTTPRequest: &http.Request{ 19 | Header: make(http.Header), 20 | Body: &awstesting.ReadCloser{Size: 2048}, 21 | }, 22 | } 23 | req.HTTPResponse = &http.Response{ 24 | Body: &awstesting.ReadCloser{Size: 2048}, 25 | Header: http.Header{ 26 | "X-Amzn-Requestid": []string{"1"}, 27 | }, 28 | StatusCode: http.StatusOK, 29 | } 30 | 31 | reader := req.HTTPResponse.Body.(*awstesting.ReadCloser) 32 | unmarshalChangeResourceRecordSetsError(req) 33 | 34 | assert.NotNil(t, req.Error) 35 | assert.Equal(t, reader.Closed, true) 36 | assert.Equal(t, reader.Size, 0) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/route53/waiters.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package route53 4 | 5 | import ( 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | // WaitUntilResourceRecordSetsChanged uses the Route 53 API operation 13 | // GetChange to wait for a condition to be met before returning. 14 | // If the condition is not meet within the max attempt window an error will 15 | // be returned. 16 | func (c *Route53) WaitUntilResourceRecordSetsChanged(input *GetChangeInput) error { 17 | return c.WaitUntilResourceRecordSetsChangedWithContext(aws.BackgroundContext(), input) 18 | } 19 | 20 | // WaitUntilResourceRecordSetsChangedWithContext is an extended version of WaitUntilResourceRecordSetsChanged. 21 | // With the support for passing in a context and options to configure the 22 | // Waiter and the underlying request options. 23 | // 24 | // The context must be non-nil and will be used for request cancellation. If 25 | // the context is nil a panic will occur. In the future the SDK may create 26 | // sub-contexts for http.Requests. See https://golang.org/pkg/context/ 27 | // for more information on using Contexts. 28 | func (c *Route53) WaitUntilResourceRecordSetsChangedWithContext(ctx aws.Context, input *GetChangeInput, opts ...request.WaiterOption) error { 29 | w := request.Waiter{ 30 | Name: "WaitUntilResourceRecordSetsChanged", 31 | MaxAttempts: 60, 32 | Delay: request.ConstantWaiterDelay(30 * time.Second), 33 | Acceptors: []request.WaiterAcceptor{ 34 | { 35 | State: request.SuccessWaiterState, 36 | Matcher: request.PathWaiterMatch, Argument: "ChangeInfo.Status", 37 | Expected: "INSYNC", 38 | }, 39 | }, 40 | Logger: c.Config.Logger, 41 | NewRequest: func(opts []request.Option) (*request.Request, error) { 42 | var inCpy *GetChangeInput 43 | if input != nil { 44 | tmp := *input 45 | inCpy = &tmp 46 | } 47 | req, _ := c.GetChangeRequest(inCpy) 48 | req.SetContext(ctx) 49 | req.ApplyOptions(opts...) 50 | return req, nil 51 | }, 52 | } 53 | w.ApplyOptions(opts...) 54 | 55 | return w.WaitWithContext(ctx) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/bucket_location.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "io/ioutil" 5 | "regexp" 6 | 7 | "github.com/aws/aws-sdk-go/aws" 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | "github.com/aws/aws-sdk-go/aws/awsutil" 10 | "github.com/aws/aws-sdk-go/aws/request" 11 | ) 12 | 13 | var reBucketLocation = regexp.MustCompile(`>([^<>]+)<\/Location`) 14 | 15 | func buildGetBucketLocation(r *request.Request) { 16 | if r.DataFilled() { 17 | out := r.Data.(*GetBucketLocationOutput) 18 | b, err := ioutil.ReadAll(r.HTTPResponse.Body) 19 | if err != nil { 20 | r.Error = awserr.New("SerializationError", "failed reading response body", err) 21 | return 22 | } 23 | 24 | match := reBucketLocation.FindSubmatch(b) 25 | if len(match) > 1 { 26 | loc := string(match[1]) 27 | out.LocationConstraint = &loc 28 | } 29 | } 30 | } 31 | 32 | func populateLocationConstraint(r *request.Request) { 33 | if r.ParamsFilled() && aws.StringValue(r.Config.Region) != "us-east-1" { 34 | in := r.Params.(*CreateBucketInput) 35 | if in.CreateBucketConfiguration == nil { 36 | r.Params = awsutil.CopyOf(r.Params) 37 | in = r.Params.(*CreateBucketInput) 38 | in.CreateBucketConfiguration = &CreateBucketConfiguration{ 39 | LocationConstraint: r.Config.Region, 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/bucket_location_test.go: -------------------------------------------------------------------------------- 1 | package s3_test 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "net/http" 7 | "testing" 8 | 9 | "github.com/aws/aws-sdk-go/aws" 10 | "github.com/aws/aws-sdk-go/aws/awsutil" 11 | "github.com/aws/aws-sdk-go/aws/request" 12 | "github.com/aws/aws-sdk-go/awstesting/unit" 13 | "github.com/aws/aws-sdk-go/service/s3" 14 | "github.com/stretchr/testify/assert" 15 | ) 16 | 17 | var s3LocationTests = []struct { 18 | body string 19 | loc string 20 | }{ 21 | {``, ``}, 22 | {`EU`, `EU`}, 23 | } 24 | 25 | func TestGetBucketLocation(t *testing.T) { 26 | for _, test := range s3LocationTests { 27 | s := s3.New(unit.Session) 28 | s.Handlers.Send.Clear() 29 | s.Handlers.Send.PushBack(func(r *request.Request) { 30 | reader := ioutil.NopCloser(bytes.NewReader([]byte(test.body))) 31 | r.HTTPResponse = &http.Response{StatusCode: 200, Body: reader} 32 | }) 33 | 34 | resp, err := s.GetBucketLocation(&s3.GetBucketLocationInput{Bucket: aws.String("bucket")}) 35 | assert.NoError(t, err) 36 | if test.loc == "" { 37 | assert.Nil(t, resp.LocationConstraint) 38 | } else { 39 | assert.Equal(t, test.loc, *resp.LocationConstraint) 40 | } 41 | } 42 | } 43 | 44 | func TestPopulateLocationConstraint(t *testing.T) { 45 | s := s3.New(unit.Session) 46 | in := &s3.CreateBucketInput{ 47 | Bucket: aws.String("bucket"), 48 | } 49 | req, _ := s.CreateBucketRequest(in) 50 | err := req.Build() 51 | assert.NoError(t, err) 52 | v, _ := awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint") 53 | assert.Equal(t, "mock-region", *(v[0].(*string))) 54 | assert.Nil(t, in.CreateBucketConfiguration) // don't modify original params 55 | } 56 | 57 | func TestNoPopulateLocationConstraintIfProvided(t *testing.T) { 58 | s := s3.New(unit.Session) 59 | req, _ := s.CreateBucketRequest(&s3.CreateBucketInput{ 60 | Bucket: aws.String("bucket"), 61 | CreateBucketConfiguration: &s3.CreateBucketConfiguration{}, 62 | }) 63 | err := req.Build() 64 | assert.NoError(t, err) 65 | v, _ := awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint") 66 | assert.Equal(t, 0, len(v)) 67 | } 68 | 69 | func TestNoPopulateLocationConstraintIfClassic(t *testing.T) { 70 | s := s3.New(unit.Session, &aws.Config{Region: aws.String("us-east-1")}) 71 | req, _ := s.CreateBucketRequest(&s3.CreateBucketInput{ 72 | Bucket: aws.String("bucket"), 73 | }) 74 | err := req.Build() 75 | assert.NoError(t, err) 76 | v, _ := awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint") 77 | assert.Equal(t, 0, len(v)) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "crypto/md5" 5 | "encoding/base64" 6 | "io" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | // contentMD5 computes and sets the HTTP Content-MD5 header for requests that 13 | // require it. 14 | func contentMD5(r *request.Request) { 15 | h := md5.New() 16 | 17 | // hash the body. seek back to the first position after reading to reset 18 | // the body for transmission. copy errors may be assumed to be from the 19 | // body. 20 | _, err := io.Copy(h, r.Body) 21 | if err != nil { 22 | r.Error = awserr.New("ContentMD5", "failed to read body", err) 23 | return 24 | } 25 | _, err = r.Body.Seek(0, 0) 26 | if err != nil { 27 | r.Error = awserr.New("ContentMD5", "failed to seek body", err) 28 | return 29 | } 30 | 31 | // encode the md5 checksum in base64 and set the request header. 32 | sum := h.Sum(nil) 33 | sum64 := make([]byte, base64.StdEncoding.EncodedLen(len(sum))) 34 | base64.StdEncoding.Encode(sum64, sum) 35 | r.HTTPRequest.Header.Set("Content-MD5", string(sum64)) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/customizations.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "github.com/aws/aws-sdk-go/aws/client" 5 | "github.com/aws/aws-sdk-go/aws/request" 6 | ) 7 | 8 | func init() { 9 | initClient = defaultInitClientFn 10 | initRequest = defaultInitRequestFn 11 | } 12 | 13 | func defaultInitClientFn(c *client.Client) { 14 | // Support building custom endpoints based on config 15 | c.Handlers.Build.PushFront(updateEndpointForS3Config) 16 | 17 | // Require SSL when using SSE keys 18 | c.Handlers.Validate.PushBack(validateSSERequiresSSL) 19 | c.Handlers.Build.PushBack(computeSSEKeys) 20 | 21 | // S3 uses custom error unmarshaling logic 22 | c.Handlers.UnmarshalError.Clear() 23 | c.Handlers.UnmarshalError.PushBack(unmarshalError) 24 | } 25 | 26 | func defaultInitRequestFn(r *request.Request) { 27 | // Add reuest handlers for specific platforms. 28 | // e.g. 100-continue support for PUT requests using Go 1.6 29 | platformRequestHandlers(r) 30 | 31 | switch r.Operation.Name { 32 | case opPutBucketCors, opPutBucketLifecycle, opPutBucketPolicy, 33 | opPutBucketTagging, opDeleteObjects, opPutBucketLifecycleConfiguration, 34 | opPutBucketReplication: 35 | // These S3 operations require Content-MD5 to be set 36 | r.Handlers.Build.PushBack(contentMD5) 37 | case opGetBucketLocation: 38 | // GetBucketLocation has custom parsing logic 39 | r.Handlers.Unmarshal.PushFront(buildGetBucketLocation) 40 | case opCreateBucket: 41 | // Auto-populate LocationConstraint with current region 42 | r.Handlers.Validate.PushFront(populateLocationConstraint) 43 | case opCopyObject, opUploadPartCopy, opCompleteMultipartUpload: 44 | r.Handlers.Unmarshal.PushFront(copyMultipartStatusOKUnmarhsalError) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/errors.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package s3 4 | 5 | const ( 6 | 7 | // ErrCodeBucketAlreadyExists for service response error code 8 | // "BucketAlreadyExists". 9 | // 10 | // The requested bucket name is not available. The bucket namespace is shared 11 | // by all users of the system. Please select a different name and try again. 12 | ErrCodeBucketAlreadyExists = "BucketAlreadyExists" 13 | 14 | // ErrCodeBucketAlreadyOwnedByYou for service response error code 15 | // "BucketAlreadyOwnedByYou". 16 | ErrCodeBucketAlreadyOwnedByYou = "BucketAlreadyOwnedByYou" 17 | 18 | // ErrCodeNoSuchBucket for service response error code 19 | // "NoSuchBucket". 20 | // 21 | // The specified bucket does not exist. 22 | ErrCodeNoSuchBucket = "NoSuchBucket" 23 | 24 | // ErrCodeNoSuchKey for service response error code 25 | // "NoSuchKey". 26 | // 27 | // The specified key does not exist. 28 | ErrCodeNoSuchKey = "NoSuchKey" 29 | 30 | // ErrCodeNoSuchUpload for service response error code 31 | // "NoSuchUpload". 32 | // 33 | // The specified multipart upload does not exist. 34 | ErrCodeNoSuchUpload = "NoSuchUpload" 35 | 36 | // ErrCodeObjectAlreadyInActiveTierError for service response error code 37 | // "ObjectAlreadyInActiveTierError". 38 | // 39 | // This operation is not allowed against this storage tier 40 | ErrCodeObjectAlreadyInActiveTierError = "ObjectAlreadyInActiveTierError" 41 | 42 | // ErrCodeObjectNotInActiveTierError for service response error code 43 | // "ObjectNotInActiveTierError". 44 | // 45 | // The source object of the COPY operation is not in the active tier and is 46 | // only stored in Amazon Glacier. 47 | ErrCodeObjectNotInActiveTierError = "ObjectNotInActiveTierError" 48 | ) 49 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/platform_handlers.go: -------------------------------------------------------------------------------- 1 | // +build !go1.6 2 | 3 | package s3 4 | 5 | import "github.com/aws/aws-sdk-go/aws/request" 6 | 7 | func platformRequestHandlers(r *request.Request) { 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/platform_handlers_go1.6.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package s3 4 | 5 | import ( 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/request" 8 | ) 9 | 10 | func platformRequestHandlers(r *request.Request) { 11 | if r.Operation.HTTPMethod == "PUT" { 12 | // 100-Continue should only be used on put requests. 13 | r.Handlers.Sign.PushBack(add100Continue) 14 | } 15 | } 16 | 17 | func add100Continue(r *request.Request) { 18 | if aws.BoolValue(r.Config.S3Disable100Continue) { 19 | return 20 | } 21 | if r.HTTPRequest.ContentLength < 1024*1024*2 { 22 | // Ignore requests smaller than 2MB. This helps prevent delaying 23 | // requests unnecessarily. 24 | return 25 | } 26 | 27 | r.HTTPRequest.Header.Set("Expect", "100-Continue") 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/platform_handlers_go1.6_test.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package s3_test 4 | 5 | import ( 6 | "bytes" 7 | "testing" 8 | 9 | "github.com/aws/aws-sdk-go/aws" 10 | "github.com/aws/aws-sdk-go/awstesting/unit" 11 | "github.com/aws/aws-sdk-go/service/s3" 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | func TestAdd100Continue_Added(t *testing.T) { 16 | svc := s3.New(unit.Session) 17 | r, _ := svc.PutObjectRequest(&s3.PutObjectInput{ 18 | Bucket: aws.String("bucket"), 19 | Key: aws.String("dest"), 20 | Body: bytes.NewReader(make([]byte, 1024*1024*5)), 21 | }) 22 | 23 | err := r.Sign() 24 | 25 | assert.NoError(t, err) 26 | assert.Equal(t, "100-Continue", r.HTTPRequest.Header.Get("Expect")) 27 | } 28 | 29 | func TestAdd100Continue_SkipDisabled(t *testing.T) { 30 | svc := s3.New(unit.Session, aws.NewConfig().WithS3Disable100Continue(true)) 31 | r, _ := svc.PutObjectRequest(&s3.PutObjectInput{ 32 | Bucket: aws.String("bucket"), 33 | Key: aws.String("dest"), 34 | Body: bytes.NewReader(make([]byte, 1024*1024*5)), 35 | }) 36 | 37 | err := r.Sign() 38 | 39 | assert.NoError(t, err) 40 | assert.Empty(t, r.HTTPRequest.Header.Get("Expect")) 41 | } 42 | 43 | func TestAdd100Continue_SkipNonPUT(t *testing.T) { 44 | svc := s3.New(unit.Session) 45 | r, _ := svc.GetObjectRequest(&s3.GetObjectInput{ 46 | Bucket: aws.String("bucket"), 47 | Key: aws.String("dest"), 48 | }) 49 | 50 | err := r.Sign() 51 | 52 | assert.NoError(t, err) 53 | assert.Empty(t, r.HTTPRequest.Header.Get("Expect")) 54 | } 55 | 56 | func TestAdd100Continue_SkipTooSmall(t *testing.T) { 57 | svc := s3.New(unit.Session) 58 | r, _ := svc.PutObjectRequest(&s3.PutObjectInput{ 59 | Bucket: aws.String("bucket"), 60 | Key: aws.String("dest"), 61 | Body: bytes.NewReader(make([]byte, 1024*1024*1)), 62 | }) 63 | 64 | err := r.Sign() 65 | 66 | assert.NoError(t, err) 67 | assert.Empty(t, r.HTTPRequest.Header.Get("Expect")) 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/service.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package s3 4 | 5 | import ( 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/client" 8 | "github.com/aws/aws-sdk-go/aws/client/metadata" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | "github.com/aws/aws-sdk-go/aws/signer/v4" 11 | "github.com/aws/aws-sdk-go/private/protocol/restxml" 12 | ) 13 | 14 | // S3 is a client for Amazon S3. 15 | // The service client's operations are safe to be used concurrently. 16 | // It is not safe to mutate any of the client's properties though. 17 | // Please also see https://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01 18 | type S3 struct { 19 | *client.Client 20 | } 21 | 22 | // Used for custom client initialization logic 23 | var initClient func(*client.Client) 24 | 25 | // Used for custom request initialization logic 26 | var initRequest func(*request.Request) 27 | 28 | // Service information constants 29 | const ( 30 | ServiceName = "s3" // Service endpoint prefix API calls made to. 31 | EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata. 32 | ) 33 | 34 | // New creates a new instance of the S3 client with a session. 35 | // If additional configuration is needed for the client instance use the optional 36 | // aws.Config parameter to add your extra config. 37 | // 38 | // Example: 39 | // // Create a S3 client from just a session. 40 | // svc := s3.New(mySession) 41 | // 42 | // // Create a S3 client with additional configuration 43 | // svc := s3.New(mySession, aws.NewConfig().WithRegion("us-west-2")) 44 | func New(p client.ConfigProvider, cfgs ...*aws.Config) *S3 { 45 | c := p.ClientConfig(EndpointsID, cfgs...) 46 | return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName) 47 | } 48 | 49 | // newClient creates, initializes and returns a new service client instance. 50 | func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *S3 { 51 | svc := &S3{ 52 | Client: client.New( 53 | cfg, 54 | metadata.ClientInfo{ 55 | ServiceName: ServiceName, 56 | SigningName: signingName, 57 | SigningRegion: signingRegion, 58 | Endpoint: endpoint, 59 | APIVersion: "2006-03-01", 60 | }, 61 | handlers, 62 | ), 63 | } 64 | 65 | // Handlers 66 | svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) 67 | svc.Handlers.Build.PushBackNamed(restxml.BuildHandler) 68 | svc.Handlers.Unmarshal.PushBackNamed(restxml.UnmarshalHandler) 69 | svc.Handlers.UnmarshalMeta.PushBackNamed(restxml.UnmarshalMetaHandler) 70 | svc.Handlers.UnmarshalError.PushBackNamed(restxml.UnmarshalErrorHandler) 71 | 72 | // Run custom client initialization if present 73 | if initClient != nil { 74 | initClient(svc.Client) 75 | } 76 | 77 | return svc 78 | } 79 | 80 | // newRequest creates a new request for a S3 operation and runs any 81 | // custom request initialization. 82 | func (c *S3) newRequest(op *request.Operation, params, data interface{}) *request.Request { 83 | req := c.NewRequest(op, params, data) 84 | 85 | // Run custom request initialization if present 86 | if initRequest != nil { 87 | initRequest(req) 88 | } 89 | 90 | return req 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/sse.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "crypto/md5" 5 | "encoding/base64" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | "github.com/aws/aws-sdk-go/aws/awsutil" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | var errSSERequiresSSL = awserr.New("ConfigError", "cannot send SSE keys over HTTP.", nil) 13 | 14 | func validateSSERequiresSSL(r *request.Request) { 15 | if r.HTTPRequest.URL.Scheme != "https" { 16 | p, _ := awsutil.ValuesAtPath(r.Params, "SSECustomerKey||CopySourceSSECustomerKey") 17 | if len(p) > 0 { 18 | r.Error = errSSERequiresSSL 19 | } 20 | } 21 | } 22 | 23 | func computeSSEKeys(r *request.Request) { 24 | headers := []string{ 25 | "x-amz-server-side-encryption-customer-key", 26 | "x-amz-copy-source-server-side-encryption-customer-key", 27 | } 28 | 29 | for _, h := range headers { 30 | md5h := h + "-md5" 31 | if key := r.HTTPRequest.Header.Get(h); key != "" { 32 | // Base64-encode the value 33 | b64v := base64.StdEncoding.EncodeToString([]byte(key)) 34 | r.HTTPRequest.Header.Set(h, b64v) 35 | 36 | // Add MD5 if it wasn't computed 37 | if r.HTTPRequest.Header.Get(md5h) == "" { 38 | sum := md5.Sum([]byte(key)) 39 | b64sum := base64.StdEncoding.EncodeToString(sum[:]) 40 | r.HTTPRequest.Header.Set(md5h, b64sum) 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/statusok_error.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "net/http" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | "github.com/aws/aws-sdk-go/aws/request" 10 | ) 11 | 12 | func copyMultipartStatusOKUnmarhsalError(r *request.Request) { 13 | b, err := ioutil.ReadAll(r.HTTPResponse.Body) 14 | if err != nil { 15 | r.Error = awserr.New("SerializationError", "unable to read response body", err) 16 | return 17 | } 18 | body := bytes.NewReader(b) 19 | r.HTTPResponse.Body = ioutil.NopCloser(body) 20 | defer body.Seek(0, 0) 21 | 22 | if body.Len() == 0 { 23 | // If there is no body don't attempt to parse the body. 24 | return 25 | } 26 | 27 | unmarshalError(r) 28 | if err, ok := r.Error.(awserr.Error); ok && err != nil { 29 | if err.Code() == "SerializationError" { 30 | r.Error = nil 31 | return 32 | } 33 | r.HTTPResponse.StatusCode = http.StatusServiceUnavailable 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "encoding/xml" 5 | "fmt" 6 | "io" 7 | "io/ioutil" 8 | "net/http" 9 | "strings" 10 | 11 | "github.com/aws/aws-sdk-go/aws" 12 | "github.com/aws/aws-sdk-go/aws/awserr" 13 | "github.com/aws/aws-sdk-go/aws/request" 14 | ) 15 | 16 | type xmlErrorResponse struct { 17 | XMLName xml.Name `xml:"Error"` 18 | Code string `xml:"Code"` 19 | Message string `xml:"Message"` 20 | } 21 | 22 | func unmarshalError(r *request.Request) { 23 | defer r.HTTPResponse.Body.Close() 24 | defer io.Copy(ioutil.Discard, r.HTTPResponse.Body) 25 | 26 | hostID := r.HTTPResponse.Header.Get("X-Amz-Id-2") 27 | 28 | // Bucket exists in a different region, and request needs 29 | // to be made to the correct region. 30 | if r.HTTPResponse.StatusCode == http.StatusMovedPermanently { 31 | r.Error = requestFailure{ 32 | RequestFailure: awserr.NewRequestFailure( 33 | awserr.New("BucketRegionError", 34 | fmt.Sprintf("incorrect region, the bucket is not in '%s' region", 35 | aws.StringValue(r.Config.Region)), 36 | nil), 37 | r.HTTPResponse.StatusCode, 38 | r.RequestID, 39 | ), 40 | hostID: hostID, 41 | } 42 | return 43 | } 44 | 45 | var errCode, errMsg string 46 | 47 | // Attempt to parse error from body if it is known 48 | resp := &xmlErrorResponse{} 49 | err := xml.NewDecoder(r.HTTPResponse.Body).Decode(resp) 50 | if err != nil && err != io.EOF { 51 | errCode = "SerializationError" 52 | errMsg = "failed to decode S3 XML error response" 53 | } else { 54 | errCode = resp.Code 55 | errMsg = resp.Message 56 | err = nil 57 | } 58 | 59 | // Fallback to status code converted to message if still no error code 60 | if len(errCode) == 0 { 61 | statusText := http.StatusText(r.HTTPResponse.StatusCode) 62 | errCode = strings.Replace(statusText, " ", "", -1) 63 | errMsg = statusText 64 | } 65 | 66 | r.Error = requestFailure{ 67 | RequestFailure: awserr.NewRequestFailure( 68 | awserr.New(errCode, errMsg, err), 69 | r.HTTPResponse.StatusCode, 70 | r.RequestID, 71 | ), 72 | hostID: hostID, 73 | } 74 | } 75 | 76 | // A RequestFailure provides access to the S3 Request ID and Host ID values 77 | // returned from API operation errors. Getting the error as a string will 78 | // return the formated error with the same information as awserr.RequestFailure, 79 | // while also adding the HostID value from the response. 80 | type RequestFailure interface { 81 | awserr.RequestFailure 82 | 83 | // Host ID is the S3 Host ID needed for debug, and contacting support 84 | HostID() string 85 | } 86 | 87 | type requestFailure struct { 88 | awserr.RequestFailure 89 | 90 | hostID string 91 | } 92 | 93 | func (r requestFailure) Error() string { 94 | extra := fmt.Sprintf("status code: %d, request id: %s, host id: %s", 95 | r.StatusCode(), r.RequestID(), r.hostID) 96 | return awserr.SprintError(r.Code(), r.Message(), extra, r.OrigErr()) 97 | } 98 | func (r requestFailure) String() string { 99 | return r.Error() 100 | } 101 | func (r requestFailure) HostID() string { 102 | return r.hostID 103 | } 104 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error_leak_test.go: -------------------------------------------------------------------------------- 1 | package s3 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "net/http" 6 | "testing" 7 | 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | "github.com/aws/aws-sdk-go/awstesting" 10 | ) 11 | 12 | func TestUnmarhsalErrorLeak(t *testing.T) { 13 | req := &request.Request{ 14 | HTTPRequest: &http.Request{ 15 | Header: make(http.Header), 16 | Body: &awstesting.ReadCloser{Size: 2048}, 17 | }, 18 | } 19 | req.HTTPResponse = &http.Response{ 20 | Body: &awstesting.ReadCloser{Size: 2048}, 21 | Header: http.Header{ 22 | "X-Amzn-Requestid": []string{"1"}, 23 | }, 24 | StatusCode: http.StatusOK, 25 | } 26 | 27 | reader := req.HTTPResponse.Body.(*awstesting.ReadCloser) 28 | unmarshalError(req) 29 | 30 | assert.NotNil(t, req.Error) 31 | assert.Equal(t, reader.Closed, true) 32 | assert.Equal(t, reader.Size, 0) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/sqs/api_test.go: -------------------------------------------------------------------------------- 1 | // +build integration 2 | 3 | package sqs_test 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/stretchr/testify/assert" 9 | 10 | "github.com/aws/aws-sdk-go/aws" 11 | "github.com/aws/aws-sdk-go/awstesting/unit" 12 | "github.com/aws/aws-sdk-go/service/sqs" 13 | ) 14 | 15 | func TestFlattenedTraits(t *testing.T) { 16 | s := sqs.New(unit.Session) 17 | _, err := s.DeleteMessageBatch(&sqs.DeleteMessageBatchInput{ 18 | QueueURL: aws.String("QUEUE"), 19 | Entries: []*sqs.DeleteMessageBatchRequestEntry{ 20 | { 21 | ID: aws.String("TEST"), 22 | ReceiptHandle: aws.String("RECEIPT"), 23 | }, 24 | }, 25 | }) 26 | 27 | assert.Error(t, err) 28 | assert.Equal(t, "InvalidAddress", err.Code()) 29 | assert.Equal(t, "The address QUEUE is not valid for this endpoint.", err.Message()) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/sqs/customizations.go: -------------------------------------------------------------------------------- 1 | package sqs 2 | 3 | import "github.com/aws/aws-sdk-go/aws/request" 4 | 5 | func init() { 6 | initRequest = func(r *request.Request) { 7 | setupChecksumValidation(r) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/sts/customizations.go: -------------------------------------------------------------------------------- 1 | package sts 2 | 3 | import "github.com/aws/aws-sdk-go/aws/request" 4 | 5 | func init() { 6 | initRequest = func(r *request.Request) { 7 | switch r.Operation.Name { 8 | case opAssumeRoleWithSAML, opAssumeRoleWithWebIdentity: 9 | r.Handlers.Sign.Clear() // these operations are unsigned 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/sts/customizations_test.go: -------------------------------------------------------------------------------- 1 | package sts_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/awstesting/unit" 10 | "github.com/aws/aws-sdk-go/service/sts" 11 | ) 12 | 13 | var svc = sts.New(unit.Session, &aws.Config{ 14 | Region: aws.String("mock-region"), 15 | }) 16 | 17 | func TestUnsignedRequest_AssumeRoleWithSAML(t *testing.T) { 18 | req, _ := svc.AssumeRoleWithSAMLRequest(&sts.AssumeRoleWithSAMLInput{ 19 | PrincipalArn: aws.String("ARN01234567890123456789"), 20 | RoleArn: aws.String("ARN01234567890123456789"), 21 | SAMLAssertion: aws.String("ASSERT"), 22 | }) 23 | 24 | err := req.Sign() 25 | assert.NoError(t, err) 26 | assert.Equal(t, "", req.HTTPRequest.Header.Get("Authorization")) 27 | } 28 | 29 | func TestUnsignedRequest_AssumeRoleWithWebIdentity(t *testing.T) { 30 | req, _ := svc.AssumeRoleWithWebIdentityRequest(&sts.AssumeRoleWithWebIdentityInput{ 31 | RoleArn: aws.String("ARN01234567890123456789"), 32 | RoleSessionName: aws.String("SESSION"), 33 | WebIdentityToken: aws.String("TOKEN"), 34 | }) 35 | 36 | err := req.Sign() 37 | assert.NoError(t, err) 38 | assert.Equal(t, "", req.HTTPRequest.Header.Get("Authorization")) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2013 Dave Collins 4 | 5 | Permission to use, copy, modify, and distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build test bench vet 2 | 3 | build: vet bench 4 | 5 | test: 6 | go test -v -cover -race 7 | 8 | bench: 9 | go test -v -cover -race -test.bench=. -test.benchmem 10 | 11 | vet: 12 | go vet 13 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | type ErrDelimiterNotFound struct { 22 | Line string 23 | } 24 | 25 | func IsErrDelimiterNotFound(err error) bool { 26 | _, ok := err.(ErrDelimiterNotFound) 27 | return ok 28 | } 29 | 30 | func (err ErrDelimiterNotFound) Error() string { 31 | return fmt.Sprintf("key-value delimiter not found: %s", err.Line) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/parser_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "testing" 19 | 20 | . "github.com/smartystreets/goconvey/convey" 21 | ) 22 | 23 | func Test_BOM(t *testing.T) { 24 | Convey("Test handling BOM", t, func() { 25 | Convey("UTF-8-BOM", func() { 26 | cfg, err := Load("testdata/UTF-8-BOM.ini") 27 | So(err, ShouldBeNil) 28 | So(cfg, ShouldNotBeNil) 29 | 30 | So(cfg.Section("author").Key("E-MAIL").String(), ShouldEqual, "u@gogs.io") 31 | }) 32 | 33 | Convey("UTF-16-LE-BOM", func() { 34 | cfg, err := Load("testdata/UTF-16-LE-BOM.ini") 35 | So(err, ShouldBeNil) 36 | So(cfg, ShouldNotBeNil) 37 | }) 38 | 39 | Convey("UTF-16-BE-BOM", func() { 40 | }) 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/section_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "strings" 19 | "testing" 20 | 21 | . "github.com/smartystreets/goconvey/convey" 22 | ) 23 | 24 | func Test_Section(t *testing.T) { 25 | Convey("Test CRD sections", t, func() { 26 | cfg, err := Load([]byte(_CONF_DATA), "testdata/conf.ini") 27 | So(err, ShouldBeNil) 28 | So(cfg, ShouldNotBeNil) 29 | 30 | Convey("Get section strings", func() { 31 | So(strings.Join(cfg.SectionStrings(), ","), ShouldEqual, "DEFAULT,author,package,package.sub,features,types,array,note,comments,advance") 32 | }) 33 | 34 | Convey("Delete a section", func() { 35 | cfg.DeleteSection("") 36 | So(cfg.SectionStrings()[0], ShouldNotEqual, DEFAULT_SECTION) 37 | }) 38 | 39 | Convey("Create new sections", func() { 40 | cfg.NewSections("test", "test2") 41 | _, err := cfg.GetSection("test") 42 | So(err, ShouldBeNil) 43 | _, err = cfg.GetSection("test2") 44 | So(err, ShouldBeNil) 45 | }) 46 | }) 47 | } 48 | 49 | func Test_SectionRaw(t *testing.T) { 50 | Convey("Test section raw string", t, func() { 51 | cfg, err := LoadSources( 52 | LoadOptions{ 53 | Insensitive: true, 54 | UnparseableSections: []string{"core_lesson", "comments"}, 55 | }, 56 | "testdata/aicc.ini") 57 | So(err, ShouldBeNil) 58 | So(cfg, ShouldNotBeNil) 59 | 60 | Convey("Get section strings", func() { 61 | So(strings.Join(cfg.SectionStrings(), ","), ShouldEqual, "DEFAULT,core,core_lesson,comments") 62 | }) 63 | 64 | Convey("Validate non-raw section", func() { 65 | val, err := cfg.Section("core").GetKey("lesson_status") 66 | So(err, ShouldBeNil) 67 | So(val.String(), ShouldEqual, "C") 68 | }) 69 | 70 | Convey("Validate raw section", func() { 71 | So(cfg.Section("core_lesson").Body(), ShouldEqual, `my lesson state data – 1111111111111111111000000000000000001110000 72 | 111111111111111111100000000000111000000000 – end my lesson state data`) 73 | }) 74 | }) 75 | } -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/UTF-16-BE-BOM.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remind101/assume-role/06a34b06d24a610291bb0952f2a24341e67a9b6e/vendor/github.com/go-ini/ini/testdata/UTF-16-BE-BOM.ini -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/UTF-16-LE-BOM.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remind101/assume-role/06a34b06d24a610291bb0952f2a24341e67a9b6e/vendor/github.com/go-ini/ini/testdata/UTF-16-LE-BOM.ini -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/UTF-8-BOM.ini: -------------------------------------------------------------------------------- 1 | [author] 2 | E-MAIL = u@gogs.io -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/aicc.ini: -------------------------------------------------------------------------------- 1 | [Core] 2 | Lesson_Location = 87 3 | Lesson_Status = C 4 | Score = 3 5 | Time = 00:02:30 6 | 7 | [CORE_LESSON] 8 | my lesson state data – 1111111111111111111000000000000000001110000 9 | 111111111111111111100000000000111000000000 – end my lesson state data 10 | [COMMENTS] 11 | <1> This slide has the fuel listed in the wrong units 12 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/conf.ini: -------------------------------------------------------------------------------- 1 | [author] 2 | E-MAIL = u@gogs.io -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015 James Saryerwinnie 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CMD = jpgo 3 | 4 | help: 5 | @echo "Please use \`make ' where is one of" 6 | @echo " test to run all the tests" 7 | @echo " build to build the library and jp executable" 8 | @echo " generate to run codegen" 9 | 10 | 11 | generate: 12 | go generate ./... 13 | 14 | build: 15 | rm -f $(CMD) 16 | go build ./... 17 | rm -f cmd/$(CMD)/$(CMD) && cd cmd/$(CMD)/ && go build ./... 18 | mv cmd/$(CMD)/$(CMD) . 19 | 20 | test: 21 | go test -v ./... 22 | 23 | check: 24 | go vet ./... 25 | @echo "golint ./..." 26 | @lint=`golint ./...`; \ 27 | lint=`echo "$$lint" | grep -v "astnodetype_string.go" | grep -v "toktype_string.go"`; \ 28 | echo "$$lint"; \ 29 | if [ "$$lint" != "" ]; then exit 1; fi 30 | 31 | htmlc: 32 | go test -coverprofile="/tmp/jpcov" && go tool cover -html="/tmp/jpcov" && unlink /tmp/jpcov 33 | 34 | buildfuzz: 35 | go-fuzz-build github.com/jmespath/go-jmespath/fuzz 36 | 37 | fuzz: buildfuzz 38 | go-fuzz -bin=./jmespath-fuzz.zip -workdir=fuzz/testdata 39 | 40 | bench: 41 | go test -bench . -cpuprofile cpu.out 42 | 43 | pprof-cpu: 44 | go tool pprof ./go-jmespath.test ./cpu.out 45 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/README.md: -------------------------------------------------------------------------------- 1 | # go-jmespath - A JMESPath implementation in Go 2 | 3 | [![Build Status](https://img.shields.io/travis/jmespath/go-jmespath.svg)](https://travis-ci.org/jmespath/go-jmespath) 4 | 5 | 6 | 7 | See http://jmespath.org for more info. 8 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/api.go: -------------------------------------------------------------------------------- 1 | package jmespath 2 | 3 | import "strconv" 4 | 5 | // JmesPath is the epresentation of a compiled JMES path query. A JmesPath is 6 | // safe for concurrent use by multiple goroutines. 7 | type JMESPath struct { 8 | ast ASTNode 9 | intr *treeInterpreter 10 | } 11 | 12 | // Compile parses a JMESPath expression and returns, if successful, a JMESPath 13 | // object that can be used to match against data. 14 | func Compile(expression string) (*JMESPath, error) { 15 | parser := NewParser() 16 | ast, err := parser.Parse(expression) 17 | if err != nil { 18 | return nil, err 19 | } 20 | jmespath := &JMESPath{ast: ast, intr: newInterpreter()} 21 | return jmespath, nil 22 | } 23 | 24 | // MustCompile is like Compile but panics if the expression cannot be parsed. 25 | // It simplifies safe initialization of global variables holding compiled 26 | // JMESPaths. 27 | func MustCompile(expression string) *JMESPath { 28 | jmespath, err := Compile(expression) 29 | if err != nil { 30 | panic(`jmespath: Compile(` + strconv.Quote(expression) + `): ` + err.Error()) 31 | } 32 | return jmespath 33 | } 34 | 35 | // Search evaluates a JMESPath expression against input data and returns the result. 36 | func (jp *JMESPath) Search(data interface{}) (interface{}, error) { 37 | return jp.intr.Execute(jp.ast, data) 38 | } 39 | 40 | // Search evaluates a JMESPath expression against input data and returns the result. 41 | func Search(expression string, data interface{}) (interface{}, error) { 42 | intr := newInterpreter() 43 | parser := NewParser() 44 | ast, err := parser.Parse(expression) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return intr.Execute(ast, data) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/api_test.go: -------------------------------------------------------------------------------- 1 | package jmespath 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestValidPrecompiledExpressionSearches(t *testing.T) { 10 | assert := assert.New(t) 11 | data := make(map[string]interface{}) 12 | data["foo"] = "bar" 13 | precompiled, err := Compile("foo") 14 | assert.Nil(err) 15 | result, err := precompiled.Search(data) 16 | assert.Nil(err) 17 | assert.Equal("bar", result) 18 | } 19 | 20 | func TestInvalidPrecompileErrors(t *testing.T) { 21 | assert := assert.New(t) 22 | _, err := Compile("not a valid expression") 23 | assert.NotNil(err) 24 | } 25 | 26 | func TestInvalidMustCompilePanics(t *testing.T) { 27 | defer func() { 28 | r := recover() 29 | assert.NotNil(t, r) 30 | }() 31 | MustCompile("not a valid expression") 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/astnodetype_string.go: -------------------------------------------------------------------------------- 1 | // generated by stringer -type astNodeType; DO NOT EDIT 2 | 3 | package jmespath 4 | 5 | import "fmt" 6 | 7 | const _astNodeType_name = "ASTEmptyASTComparatorASTCurrentNodeASTExpRefASTFunctionExpressionASTFieldASTFilterProjectionASTFlattenASTIdentityASTIndexASTIndexExpressionASTKeyValPairASTLiteralASTMultiSelectHashASTMultiSelectListASTOrExpressionASTAndExpressionASTNotExpressionASTPipeASTProjectionASTSubexpressionASTSliceASTValueProjection" 8 | 9 | var _astNodeType_index = [...]uint16{0, 8, 21, 35, 44, 65, 73, 92, 102, 113, 121, 139, 152, 162, 180, 198, 213, 229, 245, 252, 265, 281, 289, 307} 10 | 11 | func (i astNodeType) String() string { 12 | if i < 0 || i >= astNodeType(len(_astNodeType_index)-1) { 13 | return fmt.Sprintf("astNodeType(%d)", i) 14 | } 15 | return _astNodeType_name[_astNodeType_index[i]:_astNodeType_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/toktype_string.go: -------------------------------------------------------------------------------- 1 | // generated by stringer -type=tokType; DO NOT EDIT 2 | 3 | package jmespath 4 | 5 | import "fmt" 6 | 7 | const _tokType_name = "tUnknowntStartDottFiltertFlattentLparentRparentLbrackettRbrackettLbracetRbracetOrtPipetNumbertUnquotedIdentifiertQuotedIdentifiertCommatColontLTtLTEtGTtGTEtEQtNEtJSONLiteraltStringLiteraltCurrenttExpreftAndtNottEOF" 8 | 9 | var _tokType_index = [...]uint8{0, 8, 13, 17, 24, 32, 39, 46, 55, 64, 71, 78, 81, 86, 93, 112, 129, 135, 141, 144, 148, 151, 155, 158, 161, 173, 187, 195, 202, 206, 210, 214} 10 | 11 | func (i tokType) String() string { 12 | if i < 0 || i >= tokType(len(_tokType_index)-1) { 13 | return fmt.Sprintf("tokType(%d)", i) 14 | } 15 | return _tokType_name[_tokType_index[i]:_tokType_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/util_test.go: -------------------------------------------------------------------------------- 1 | package jmespath 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestSlicePositiveStep(t *testing.T) { 9 | assert := assert.New(t) 10 | input := make([]interface{}, 5) 11 | input[0] = 0 12 | input[1] = 1 13 | input[2] = 2 14 | input[3] = 3 15 | input[4] = 4 16 | result, err := slice(input, []sliceParam{{0, true}, {3, true}, {1, true}}) 17 | assert.Nil(err) 18 | assert.Equal(input[:3], result) 19 | } 20 | 21 | func TestIsFalseJSONTypes(t *testing.T) { 22 | assert := assert.New(t) 23 | assert.True(isFalse(false)) 24 | assert.True(isFalse("")) 25 | var empty []interface{} 26 | assert.True(isFalse(empty)) 27 | m := make(map[string]interface{}) 28 | assert.True(isFalse(m)) 29 | assert.True(isFalse(nil)) 30 | 31 | } 32 | 33 | func TestIsFalseWithUserDefinedStructs(t *testing.T) { 34 | assert := assert.New(t) 35 | type nilStructType struct { 36 | SliceOfPointers []*string 37 | } 38 | nilStruct := nilStructType{SliceOfPointers: nil} 39 | assert.True(isFalse(nilStruct.SliceOfPointers)) 40 | 41 | // A user defined struct will never be false though, 42 | // even if it's fields are the zero type. 43 | assert.False(isFalse(nilStruct)) 44 | } 45 | 46 | func TestIsFalseWithNilInterface(t *testing.T) { 47 | assert := assert.New(t) 48 | var a *int = nil 49 | var nilInterface interface{} 50 | nilInterface = a 51 | assert.True(isFalse(nilInterface)) 52 | } 53 | 54 | func TestIsFalseWithMapOfUserStructs(t *testing.T) { 55 | assert := assert.New(t) 56 | type foo struct { 57 | Bar string 58 | Baz string 59 | } 60 | m := make(map[int]foo) 61 | assert.True(isFalse(m)) 62 | } 63 | 64 | func TestObjsEqual(t *testing.T) { 65 | assert := assert.New(t) 66 | assert.True(objsEqual("foo", "foo")) 67 | assert.True(objsEqual(20, 20)) 68 | assert.True(objsEqual([]int{1, 2, 3}, []int{1, 2, 3})) 69 | assert.True(objsEqual(nil, nil)) 70 | assert.True(!objsEqual(nil, "foo")) 71 | assert.True(objsEqual([]int{}, []int{})) 72 | assert.True(!objsEqual([]int{}, nil)) 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/require" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // require.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // Assertions 22 | // 23 | // The `require` package have same global functions as in the `assert` package, 24 | // but instead of returning a boolean result they call `t.FailNow()`. 25 | // 26 | // Every assertion function also takes an optional string message as the final argument, 27 | // allowing custom error messages to be appended to the message the assertion method outputs. 28 | package require 29 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { 4 | t.FailNow() 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | //go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl 10 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/README.md: -------------------------------------------------------------------------------- 1 | # YAML support for the Go language 2 | 3 | Introduction 4 | ------------ 5 | 6 | The yaml package enables Go programs to comfortably encode and decode YAML 7 | values. It was developed within [Canonical](https://www.canonical.com) as 8 | part of the [juju](https://juju.ubuntu.com) project, and is based on a 9 | pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) 10 | C library to parse and generate YAML data quickly and reliably. 11 | 12 | Compatibility 13 | ------------- 14 | 15 | The yaml package supports most of YAML 1.1 and 1.2, including support for 16 | anchors, tags, map merging, etc. Multi-document unmarshalling is not yet 17 | implemented, and base-60 floats from YAML 1.1 are purposefully not 18 | supported since they're a poor design and are gone in YAML 1.2. 19 | 20 | Installation and usage 21 | ---------------------- 22 | 23 | The import path for the package is *gopkg.in/yaml.v2*. 24 | 25 | To install it, run: 26 | 27 | go get gopkg.in/yaml.v2 28 | 29 | API documentation 30 | ----------------- 31 | 32 | If opened in a browser, the import path itself leads to the API documentation: 33 | 34 | * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) 35 | 36 | API stability 37 | ------------- 38 | 39 | The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). 40 | 41 | 42 | License 43 | ------- 44 | 45 | The yaml package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details. 46 | 47 | 48 | Example 49 | ------- 50 | 51 | ```Go 52 | package main 53 | 54 | import ( 55 | "fmt" 56 | "log" 57 | 58 | "gopkg.in/yaml.v2" 59 | ) 60 | 61 | var data = ` 62 | a: Easy! 63 | b: 64 | c: 2 65 | d: [3, 4] 66 | ` 67 | 68 | type T struct { 69 | A string 70 | B struct{C int; D []int ",flow"} 71 | } 72 | 73 | func main() { 74 | t := T{} 75 | 76 | err := yaml.Unmarshal([]byte(data), &t) 77 | if err != nil { 78 | log.Fatalf("error: %v", err) 79 | } 80 | fmt.Printf("--- t:\n%v\n\n", t) 81 | 82 | d, err := yaml.Marshal(&t) 83 | if err != nil { 84 | log.Fatalf("error: %v", err) 85 | } 86 | fmt.Printf("--- t dump:\n%s\n\n", string(d)) 87 | 88 | m := make(map[interface{}]interface{}) 89 | 90 | err = yaml.Unmarshal([]byte(data), &m) 91 | if err != nil { 92 | log.Fatalf("error: %v", err) 93 | } 94 | fmt.Printf("--- m:\n%v\n\n", m) 95 | 96 | d, err = yaml.Marshal(&m) 97 | if err != nil { 98 | log.Fatalf("error: %v", err) 99 | } 100 | fmt.Printf("--- m dump:\n%s\n\n", string(d)) 101 | } 102 | ``` 103 | 104 | This example will generate the following output: 105 | 106 | ``` 107 | --- t: 108 | {Easy! {2 [3 4]}} 109 | 110 | --- t dump: 111 | a: Easy! 112 | b: 113 | c: 2 114 | d: [3, 4] 115 | 116 | 117 | --- m: 118 | map[a:Easy! b:map[c:2 d:[3 4]]] 119 | 120 | --- m dump: 121 | a: Easy! 122 | b: 123 | c: 2 124 | d: 125 | - 3 126 | - 4 127 | ``` 128 | 129 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/sorter.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "reflect" 5 | "unicode" 6 | ) 7 | 8 | type keyList []reflect.Value 9 | 10 | func (l keyList) Len() int { return len(l) } 11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 12 | func (l keyList) Less(i, j int) bool { 13 | a := l[i] 14 | b := l[j] 15 | ak := a.Kind() 16 | bk := b.Kind() 17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 18 | a = a.Elem() 19 | ak = a.Kind() 20 | } 21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 22 | b = b.Elem() 23 | bk = b.Kind() 24 | } 25 | af, aok := keyFloat(a) 26 | bf, bok := keyFloat(b) 27 | if aok && bok { 28 | if af != bf { 29 | return af < bf 30 | } 31 | if ak != bk { 32 | return ak < bk 33 | } 34 | return numLess(a, b) 35 | } 36 | if ak != reflect.String || bk != reflect.String { 37 | return ak < bk 38 | } 39 | ar, br := []rune(a.String()), []rune(b.String()) 40 | for i := 0; i < len(ar) && i < len(br); i++ { 41 | if ar[i] == br[i] { 42 | continue 43 | } 44 | al := unicode.IsLetter(ar[i]) 45 | bl := unicode.IsLetter(br[i]) 46 | if al && bl { 47 | return ar[i] < br[i] 48 | } 49 | if al || bl { 50 | return bl 51 | } 52 | var ai, bi int 53 | var an, bn int64 54 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 55 | an = an*10 + int64(ar[ai]-'0') 56 | } 57 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 58 | bn = bn*10 + int64(br[bi]-'0') 59 | } 60 | if an != bn { 61 | return an < bn 62 | } 63 | if ai != bi { 64 | return ai < bi 65 | } 66 | return ar[i] < br[i] 67 | } 68 | return len(ar) < len(br) 69 | } 70 | 71 | // keyFloat returns a float value for v if it is a number/bool 72 | // and whether it is a number/bool or not. 73 | func keyFloat(v reflect.Value) (f float64, ok bool) { 74 | switch v.Kind() { 75 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 76 | return float64(v.Int()), true 77 | case reflect.Float32, reflect.Float64: 78 | return v.Float(), true 79 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 80 | return float64(v.Uint()), true 81 | case reflect.Bool: 82 | if v.Bool() { 83 | return 1, true 84 | } 85 | return 0, true 86 | } 87 | return 0, false 88 | } 89 | 90 | // numLess returns whether a < b. 91 | // a and b must necessarily have the same kind. 92 | func numLess(a, b reflect.Value) bool { 93 | switch a.Kind() { 94 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 95 | return a.Int() < b.Int() 96 | case reflect.Float32, reflect.Float64: 97 | return a.Float() < b.Float() 98 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 99 | return a.Uint() < b.Uint() 100 | case reflect.Bool: 101 | return !a.Bool() && b.Bool() 102 | } 103 | panic("not a number") 104 | } 105 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/suite_test.go: -------------------------------------------------------------------------------- 1 | package yaml_test 2 | 3 | import ( 4 | . "gopkg.in/check.v1" 5 | "testing" 6 | ) 7 | 8 | func Test(t *testing.T) { TestingT(t) } 9 | 10 | type S struct{} 11 | 12 | var _ = Suite(&S{}) 13 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | // If the output encoding is UTF-8, we don't need to recode the buffer. 22 | if emitter.encoding == yaml_UTF8_ENCODING { 23 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 24 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 25 | } 26 | emitter.buffer_pos = 0 27 | return true 28 | } 29 | 30 | // Recode the buffer into the raw buffer. 31 | var low, high int 32 | if emitter.encoding == yaml_UTF16LE_ENCODING { 33 | low, high = 0, 1 34 | } else { 35 | high, low = 1, 0 36 | } 37 | 38 | pos := 0 39 | for pos < emitter.buffer_pos { 40 | // See the "reader.c" code for more details on UTF-8 encoding. Note 41 | // that we assume that the buffer contains a valid UTF-8 sequence. 42 | 43 | // Read the next UTF-8 character. 44 | octet := emitter.buffer[pos] 45 | 46 | var w int 47 | var value rune 48 | switch { 49 | case octet&0x80 == 0x00: 50 | w, value = 1, rune(octet&0x7F) 51 | case octet&0xE0 == 0xC0: 52 | w, value = 2, rune(octet&0x1F) 53 | case octet&0xF0 == 0xE0: 54 | w, value = 3, rune(octet&0x0F) 55 | case octet&0xF8 == 0xF0: 56 | w, value = 4, rune(octet&0x07) 57 | } 58 | for k := 1; k < w; k++ { 59 | octet = emitter.buffer[pos+k] 60 | value = (value << 6) + (rune(octet) & 0x3F) 61 | } 62 | pos += w 63 | 64 | // Write the character. 65 | if value < 0x10000 { 66 | var b [2]byte 67 | b[high] = byte(value >> 8) 68 | b[low] = byte(value & 0xFF) 69 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) 70 | } else { 71 | // Write the character using a surrogate pair (check "reader.c"). 72 | var b [4]byte 73 | value -= 0x10000 74 | b[high] = byte(0xD8 + (value >> 18)) 75 | b[low] = byte((value >> 10) & 0xFF) 76 | b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) 77 | b[low+2] = byte(value & 0xFF) 78 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) 79 | } 80 | } 81 | 82 | // Write the raw buffer. 83 | if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { 84 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 85 | } 86 | emitter.buffer_pos = 0 87 | emitter.raw_buffer = emitter.raw_buffer[:0] 88 | return true 89 | } 90 | --------------------------------------------------------------------------------