├── .github └── workflows │ └── build-test.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── amicache ├── cache.go ├── cache_test.go ├── filter.go ├── filter_test.go ├── image.go └── image_test.go ├── api └── query │ ├── params.go │ ├── params_test.go │ ├── query.go │ └── query_test.go ├── config.go ├── config_test.go ├── go.mod ├── go.sum ├── main.go ├── main_test.go ├── resources ├── Makefile └── rhel │ ├── ami-query.service │ ├── ami-query.spec │ └── settings ├── vendor ├── github.com │ ├── aws │ │ └── aws-sdk-go │ │ │ ├── LICENSE.txt │ │ │ ├── NOTICE.txt │ │ │ ├── aws │ │ │ ├── awserr │ │ │ │ ├── error.go │ │ │ │ └── types.go │ │ │ ├── awsutil │ │ │ │ ├── copy.go │ │ │ │ ├── equal.go │ │ │ │ ├── path_value.go │ │ │ │ ├── prettify.go │ │ │ │ └── string_value.go │ │ │ ├── client │ │ │ │ ├── client.go │ │ │ │ ├── default_retryer.go │ │ │ │ ├── logger.go │ │ │ │ ├── metadata │ │ │ │ │ └── client_info.go │ │ │ │ └── no_op_retryer.go │ │ │ ├── config.go │ │ │ ├── context_1_5.go │ │ │ ├── context_1_9.go │ │ │ ├── context_background_1_5.go │ │ │ ├── context_background_1_7.go │ │ │ ├── context_sleep.go │ │ │ ├── convert_types.go │ │ │ ├── corehandlers │ │ │ │ ├── handlers.go │ │ │ │ ├── param_validator.go │ │ │ │ └── user_agent.go │ │ │ ├── credentials │ │ │ │ ├── chain_provider.go │ │ │ │ ├── credentials.go │ │ │ │ ├── ec2rolecreds │ │ │ │ │ └── ec2_role_provider.go │ │ │ │ ├── endpointcreds │ │ │ │ │ └── provider.go │ │ │ │ ├── env_provider.go │ │ │ │ ├── example.ini │ │ │ │ ├── processcreds │ │ │ │ │ └── provider.go │ │ │ │ ├── shared_credentials_provider.go │ │ │ │ ├── static_provider.go │ │ │ │ └── stscreds │ │ │ │ │ ├── assume_role_provider.go │ │ │ │ │ └── web_identity_provider.go │ │ │ ├── csm │ │ │ │ ├── doc.go │ │ │ │ ├── enable.go │ │ │ │ ├── metric.go │ │ │ │ ├── metric_chan.go │ │ │ │ ├── metric_exception.go │ │ │ │ └── reporter.go │ │ │ ├── defaults │ │ │ │ ├── defaults.go │ │ │ │ └── shared_config.go │ │ │ ├── doc.go │ │ │ ├── ec2metadata │ │ │ │ ├── api.go │ │ │ │ └── service.go │ │ │ ├── endpoints │ │ │ │ ├── decode.go │ │ │ │ ├── defaults.go │ │ │ │ ├── dep_service_ids.go │ │ │ │ ├── doc.go │ │ │ │ ├── endpoints.go │ │ │ │ ├── v3model.go │ │ │ │ └── v3model_codegen.go │ │ │ ├── errors.go │ │ │ ├── jsonvalue.go │ │ │ ├── logger.go │ │ │ ├── request │ │ │ │ ├── connection_reset_error.go │ │ │ │ ├── handlers.go │ │ │ │ ├── http_request.go │ │ │ │ ├── offset_reader.go │ │ │ │ ├── request.go │ │ │ │ ├── request_1_7.go │ │ │ │ ├── request_1_8.go │ │ │ │ ├── request_context.go │ │ │ │ ├── request_context_1_6.go │ │ │ │ ├── request_pagination.go │ │ │ │ ├── retryer.go │ │ │ │ ├── timeout_read_closer.go │ │ │ │ ├── validation.go │ │ │ │ └── waiter.go │ │ │ ├── session │ │ │ │ ├── cabundle_transport.go │ │ │ │ ├── cabundle_transport_1_5.go │ │ │ │ ├── cabundle_transport_1_6.go │ │ │ │ ├── credentials.go │ │ │ │ ├── doc.go │ │ │ │ ├── env_config.go │ │ │ │ ├── session.go │ │ │ │ └── shared_config.go │ │ │ ├── signer │ │ │ │ └── v4 │ │ │ │ │ ├── header_rules.go │ │ │ │ │ ├── options.go │ │ │ │ │ ├── uri_path.go │ │ │ │ │ └── v4.go │ │ │ ├── types.go │ │ │ ├── url.go │ │ │ ├── url_1_7.go │ │ │ └── version.go │ │ │ ├── internal │ │ │ ├── ini │ │ │ │ ├── ast.go │ │ │ │ ├── comma_token.go │ │ │ │ ├── comment_token.go │ │ │ │ ├── doc.go │ │ │ │ ├── empty_token.go │ │ │ │ ├── expression.go │ │ │ │ ├── fuzz.go │ │ │ │ ├── ini.go │ │ │ │ ├── ini_lexer.go │ │ │ │ ├── ini_parser.go │ │ │ │ ├── literal_tokens.go │ │ │ │ ├── newline_token.go │ │ │ │ ├── number_helper.go │ │ │ │ ├── op_tokens.go │ │ │ │ ├── parse_error.go │ │ │ │ ├── parse_stack.go │ │ │ │ ├── sep_tokens.go │ │ │ │ ├── skipper.go │ │ │ │ ├── statement.go │ │ │ │ ├── value_util.go │ │ │ │ ├── visitor.go │ │ │ │ ├── walker.go │ │ │ │ └── ws_token.go │ │ │ ├── sdkio │ │ │ │ ├── byte.go │ │ │ │ ├── io_go1.6.go │ │ │ │ └── io_go1.7.go │ │ │ ├── sdkmath │ │ │ │ ├── floor.go │ │ │ │ └── floor_go1.9.go │ │ │ ├── sdkrand │ │ │ │ ├── locked_source.go │ │ │ │ ├── read.go │ │ │ │ └── read_1_5.go │ │ │ ├── sdkuri │ │ │ │ └── path.go │ │ │ └── shareddefaults │ │ │ │ ├── ecs_container.go │ │ │ │ └── shared_config.go │ │ │ ├── private │ │ │ └── protocol │ │ │ │ ├── ec2query │ │ │ │ ├── build.go │ │ │ │ └── unmarshal.go │ │ │ │ ├── host.go │ │ │ │ ├── host_prefix.go │ │ │ │ ├── idempotency.go │ │ │ │ ├── json │ │ │ │ └── jsonutil │ │ │ │ │ ├── build.go │ │ │ │ │ └── unmarshal.go │ │ │ │ ├── jsonvalue.go │ │ │ │ ├── payload.go │ │ │ │ ├── query │ │ │ │ ├── build.go │ │ │ │ ├── queryutil │ │ │ │ │ └── queryutil.go │ │ │ │ ├── unmarshal.go │ │ │ │ └── unmarshal_error.go │ │ │ │ ├── rest │ │ │ │ ├── build.go │ │ │ │ ├── payload.go │ │ │ │ └── unmarshal.go │ │ │ │ ├── timestamp.go │ │ │ │ ├── unmarshal.go │ │ │ │ └── xml │ │ │ │ └── xmlutil │ │ │ │ ├── build.go │ │ │ │ ├── sort.go │ │ │ │ ├── unmarshal.go │ │ │ │ └── xml_to_struct.go │ │ │ └── service │ │ │ ├── ec2 │ │ │ ├── api.go │ │ │ ├── customizations.go │ │ │ ├── doc.go │ │ │ ├── ec2iface │ │ │ │ └── interface.go │ │ │ ├── errors.go │ │ │ ├── service.go │ │ │ └── waiters.go │ │ │ └── sts │ │ │ ├── api.go │ │ │ ├── customizations.go │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── service.go │ │ │ └── stsiface │ │ │ └── interface.go │ ├── go-kit │ │ └── kit │ │ │ ├── LICENSE │ │ │ └── log │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── json_logger.go │ │ │ ├── level │ │ │ ├── doc.go │ │ │ └── level.go │ │ │ ├── log.go │ │ │ ├── logfmt_logger.go │ │ │ ├── nop_logger.go │ │ │ ├── stdlib.go │ │ │ ├── sync.go │ │ │ └── value.go │ ├── go-logfmt │ │ └── logfmt │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── decode.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── fuzz.go │ │ │ └── jsonstring.go │ ├── go-stack │ │ └── stack │ │ │ ├── .travis.yml │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ └── stack.go │ ├── gorilla │ │ ├── context │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ └── doc.go │ │ ├── handlers │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── canonical.go │ │ │ ├── compress.go │ │ │ ├── cors.go │ │ │ ├── doc.go │ │ │ ├── handlers.go │ │ │ ├── handlers_go18.go │ │ │ ├── handlers_pre18.go │ │ │ ├── proxy_headers.go │ │ │ └── recovery.go │ │ └── mux │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context_gorilla.go │ │ │ ├── context_native.go │ │ │ ├── doc.go │ │ │ ├── mux.go │ │ │ ├── regexp.go │ │ │ └── route.go │ ├── jmespath │ │ └── go-jmespath │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── api.go │ │ │ ├── astnodetype_string.go │ │ │ ├── functions.go │ │ │ ├── interpreter.go │ │ │ ├── lexer.go │ │ │ ├── parser.go │ │ │ ├── toktype_string.go │ │ │ └── util.go │ ├── kr │ │ └── logfmt │ │ │ ├── .gitignore │ │ │ ├── Readme │ │ │ ├── decode.go │ │ │ ├── scanner.go │ │ │ └── unquote.go │ └── oklog │ │ └── oklog │ │ ├── LICENSE │ │ └── pkg │ │ └── group │ │ └── group.go └── modules.txt └── version.go /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: build-test 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths-ignore: 7 | - '**.md' 8 | pull_request: 9 | branches: [ master ] 10 | paths-ignore: 11 | - '**.md' 12 | 13 | jobs: 14 | 15 | build: 16 | runs-on: ubuntu-latest 17 | steps: 18 | 19 | - name: Set up Go 1.x 20 | uses: actions/setup-go@v2 21 | with: 22 | go-version: ^1.15 23 | id: go 24 | 25 | - name: Check out code into the Go module directory 26 | uses: actions/checkout@v2 27 | 28 | - name: make 29 | run: | 30 | make 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | /bin 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | 25 | *.rpm 26 | 27 | resources/rpmbuild 28 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [2.6.0] - 2020-08-27 2 | 3 | ### Changed 4 | 5 | * Updated to golang `1.15`. 6 | 7 | ## [2.5.0] - 2019-10-28 8 | 9 | ### Changed 10 | 11 | * Updated to golang `1.13.3`. 12 | * Update aws-sdk-go to `v1.25.14`. 13 | 14 | ### Removed 15 | 16 | * Using dep for dependencies (in favor of modules). 17 | * RHEL 6 rpm support. 18 | 19 | ## [2.4.0] - 2019-03-20 20 | 21 | ### Added 22 | 23 | * Added compression support to API responses. 24 | 25 | ## [2.3.0] - 2018-08-15 26 | 27 | ### Added 28 | 29 | * Added a config item to disable collecting launch permission information 30 | (AMIQUERY_COLLECT_LAUNCH_PERMISSIONS). 31 | 32 | 33 | ## [2.2.0] - 2018-04-16 34 | 35 | ### Changed 36 | 37 | * The `tag` query parameter now properly handles tag values with one or more 38 | colons, e.g. `tag=key:value:of:tag` translates to `key=value:of:tag`. 39 | 40 | ### Added 41 | 42 | * The tag representing an AMI's state is now configurable through the 43 | `AMIQUERY_STATE_TAG` environment variable. If not provided, the default value 44 | is `state`. 45 | 46 | ## [2.1.0] - 2018-03-23 47 | 48 | ### Added 49 | 50 | * Now supports CORS Origin header through the `AMIQUERY_CORS_ALLOWED_ORIGINS` 51 | environment variable. 52 | 53 | ## [2.0.1] - 2018-02-13 54 | 55 | ### Added 56 | 57 | * Ability to filter AMIs cached from accounts based on a key-tag. Set via the 58 | `AMIQUERY_TAG_FILTER` environment variable. 59 | 60 | ## [2.0.0] - 2017-12-19 61 | 62 | ### Added 63 | 64 | * Ability cache AMIs from mulitple accounts (requires an IAM role). 65 | * Caches the Launch Permissions for an AMI. 66 | * New query paramter, `account_id=123456789012`, to filter on AMIs said account 67 | has access to. 68 | 69 | ### Changed 70 | 71 | * Now uses [dep][dep] to manage dependencies. 72 | 73 | ### Removed 74 | 75 | * Memcached is no longer an option for caching AMIs. It's strictly an internal 76 | memory cache now. 77 | 78 | ## [1.1.0] - 2017-05-23 79 | 80 | ### Added 81 | 82 | * HTTPS support. 83 | * Timeouts to the http.Client to prevent AWS API calls from blocking. 84 | 85 | ## [1.0.0] - 2015-09-29 86 | 87 | * Initial Release. 88 | 89 | 90 | [dep]:https://github.com/golang/dep 91 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Intuit, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export GOFLAGS=-mod=vendor 2 | 3 | BIN := ./bin/ami-query 4 | 5 | # Default Go linker flags. 6 | GO_LDFLAGS ?= -ldflags="-s -w" 7 | 8 | .PHONY: all 9 | all: test clean 10 | GOOS=linux GOARCH=amd64 go build $(GO_LDFLAGS) $(BUILDARGS) -o $(BIN) 11 | 12 | .PHONY: race 13 | race: 14 | @$(MAKE) all BUILDARGS=-race 15 | 16 | .PHONY: rpm 17 | rpm: clean all 18 | @$(MAKE) -C resources 19 | 20 | .PHONY: clean 21 | clean: 22 | @rm -rf ./bin *.rpm 23 | @$(MAKE) -C resources clean 24 | 25 | .PHONY: vendor 26 | vendor: 27 | go mod tidy 28 | go mod vendor 29 | 30 | .PHONY: test 31 | test: 32 | go test -race -timeout=30s $(TESTARGS) ./... 33 | @$(MAKE) vet 34 | @if [ -z "${GITHUB_ACTIONS}" ]; then $(MAKE) lint; fi 35 | 36 | .PHONY: vet 37 | vet: 38 | go vet $(VETARGS) ./... 39 | 40 | .PHONY: lint 41 | lint: 42 | @echo "golint $(LINTARGS)" 43 | @for pkg in $(shell go list ./...) ; do \ 44 | golint $(LINTARGS) $$pkg ; \ 45 | done 46 | 47 | .PHONY: cover 48 | cover: 49 | @$(MAKE) test TESTARGS="-tags test -coverprofile=coverage.out" 50 | @go tool cover -html=coverage.out 51 | @rm -f coverage.out 52 | -------------------------------------------------------------------------------- /amicache/filter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Intuit, Inc. All rights reserved. 2 | // Use of this source code is governed the MIT license 3 | // that can be found in the LICENSE file. 4 | 5 | package amicache 6 | 7 | // Filterer is an interface used to apply specified filters on a slice of 8 | // Image objects. 9 | type Filterer interface { 10 | Filter([]Image) []Image 11 | } 12 | 13 | // Filter is used to filter Image objects. 14 | type Filter struct { 15 | filters []Filterer 16 | } 17 | 18 | // NewFilter creates a new Filter. 19 | func NewFilter(filters ...Filterer) *Filter { 20 | return &Filter{filters: filters} 21 | } 22 | 23 | // Apply returns the filtered images. 24 | func (f *Filter) Apply(images []Image) []Image { 25 | for _, f := range f.filters { 26 | images = f.Filter(images) 27 | } 28 | return images 29 | } 30 | 31 | // The FilterFunc type is an adapter to allow the use of ordinary functions as 32 | // filter handlers. If f is a function with the appropriate signature, 33 | // FilterFunc(f) is a Filterer object that calls f. 34 | type FilterFunc func([]Image) []Image 35 | 36 | // Filter implements the Filterer interface. 37 | func (f FilterFunc) Filter(images []Image) []Image { return f(images) } 38 | 39 | // FilterByImageID returns images with matching AMI ids. 40 | func FilterByImageID(ids ...string) FilterFunc { 41 | return FilterFunc(func(images []Image) []Image { 42 | if len(ids) == 0 { 43 | return images 44 | } 45 | newImages := []Image{} 46 | for i := range images { 47 | for _, id := range ids { 48 | if id == *images[i].Image.ImageId { 49 | newImages = append(newImages, images[i]) 50 | } 51 | } 52 | } 53 | return newImages 54 | }) 55 | } 56 | 57 | // FilterByTags returns images with matching tags. 58 | func FilterByTags(tags map[string][]string) FilterFunc { 59 | return FilterFunc(func(images []Image) []Image { 60 | if len(tags) == 0 { 61 | return images 62 | } 63 | newImages := []Image{} 64 | for i := range images { 65 | tagMatches := 0 66 | for _, tag := range images[i].Image.Tags { 67 | if values, ok := tags[*tag.Key]; ok { 68 | for _, val := range values { 69 | if val == *tag.Value { 70 | tagMatches++ 71 | break 72 | } 73 | } 74 | } 75 | } 76 | if tagMatches == len(tags) { 77 | newImages = append(newImages, images[i]) 78 | } 79 | } 80 | return newImages 81 | }) 82 | } 83 | 84 | // FilterByOwnerID returns only the images owned by the provided owner ID. 85 | func FilterByOwnerID(id string) FilterFunc { 86 | return FilterFunc(func(images []Image) []Image { 87 | if id == "" { 88 | return images 89 | } 90 | newImages := []Image{} 91 | for i := range images { 92 | if id == images[i].OwnerID { 93 | newImages = append(newImages, images[i]) 94 | } 95 | } 96 | return newImages 97 | }) 98 | } 99 | 100 | // FilterByLaunchPermission returns images that have the account id in its 101 | // launch permissions. 102 | func FilterByLaunchPermission(id string) FilterFunc { 103 | return FilterFunc(func(images []Image) []Image { 104 | if id == "" { 105 | return images 106 | } 107 | newImages := []Image{} 108 | for i := range images { 109 | for _, iid := range images[i].launchPerms { 110 | if id == iid { 111 | newImages = append(newImages, images[i]) 112 | break 113 | } 114 | } 115 | } 116 | return newImages 117 | }) 118 | } 119 | -------------------------------------------------------------------------------- /amicache/image.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intuit, Inc. All rights reserved. 2 | // Use of this source code is governed the MIT license 3 | // that can be found in the LICENSE file. 4 | 5 | package amicache 6 | 7 | import ( 8 | "sort" 9 | "strings" 10 | "time" 11 | 12 | "github.com/aws/aws-sdk-go/service/ec2" 13 | ) 14 | 15 | // DefaultStateTag is the default tag-key for determining AMI state. 16 | const DefaultStateTag = "state" 17 | 18 | // Life cycle state weights. 19 | const ( 20 | _ = iota 21 | deregistered uint64 = 10000000000 * iota 22 | development 23 | prerelease 24 | unavailable 25 | exception 26 | deprecated 27 | available 28 | ) 29 | 30 | // State weight lookup table. 31 | var stateWeight = map[string]uint64{ 32 | "available": available, 33 | "deprecated": deprecated, 34 | "exception": exception, 35 | "unavailable": unavailable, 36 | "pre-release": prerelease, 37 | "development": development, 38 | "deregistered": deregistered, 39 | } 40 | 41 | // Image represents an Amazon Machine Image. 42 | type Image struct { 43 | Image *ec2.Image 44 | OwnerID string 45 | Region string 46 | launchPerms []string 47 | } 48 | 49 | // NewImage returns a new Image from the provided ec2.Image and region. 50 | func NewImage(image *ec2.Image, ownerID, region string, perms []string) Image { 51 | return Image{ 52 | Image: image, 53 | OwnerID: ownerID, 54 | Region: region, 55 | launchPerms: perms, 56 | } 57 | } 58 | 59 | // Tag returns the value of the provided tag key. An empty string is returned if 60 | // there is no matching key. 61 | func (i *Image) Tag(key string) string { 62 | for _, tag := range i.Image.Tags { 63 | if *tag.Key == key { 64 | return *tag.Value 65 | } 66 | } 67 | return "" 68 | } 69 | 70 | // Tags is a convenience function that returns ec2.Image.Tags as a 71 | // map[string]string 72 | func (i *Image) Tags() map[string]string { 73 | tags := make(map[string]string) 74 | for _, tag := range i.Image.Tags { 75 | tags[*tag.Key] = *tag.Value 76 | } 77 | return tags 78 | } 79 | 80 | // SortByState sorts by taking the CreationDate attribute, converting it to 81 | // UNIX epoch, and adds it to the weighted value of the status tag. It sorts 82 | // from newest to oldest AMIs. 83 | func SortByState(state string, images []Image) { 84 | sort.Slice(images, func(i, j int) bool { 85 | var dateFmt = "2006-01-02T15:04:05.000Z" 86 | var icdate, istate uint64 87 | var jcdate, jstate uint64 88 | 89 | // Parse the CreationDate attribute 90 | if date, err := time.Parse(dateFmt, *images[i].Image.CreationDate); err == nil { 91 | icdate = uint64(date.Unix()) 92 | } 93 | 94 | if date, err := time.Parse(dateFmt, *images[j].Image.CreationDate); err == nil { 95 | jcdate = uint64(date.Unix()) 96 | } 97 | 98 | // Get the state tag 99 | if state := images[i].Tag(state); state != "" { 100 | istate = stateWeight[strings.ToLower(state)] 101 | } 102 | 103 | if state := images[j].Tag(state); state != "" { 104 | jstate = stateWeight[strings.ToLower(state)] 105 | } 106 | 107 | return icdate+istate > jcdate+jstate 108 | }) 109 | } 110 | -------------------------------------------------------------------------------- /amicache/image_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intuit, Inc. All rights reserved. 2 | // Use of this source code is governed the MIT license 3 | // that can be found in the LICENSE file. 4 | 5 | package amicache 6 | 7 | import ( 8 | "reflect" 9 | "testing" 10 | 11 | "github.com/aws/aws-sdk-go/aws" 12 | "github.com/aws/aws-sdk-go/service/ec2" 13 | ) 14 | 15 | func TestTags(t *testing.T) { 16 | i := NewImage( 17 | &ec2.Image{ 18 | Tags: []*ec2.Tag{{ 19 | Key: aws.String("test"), 20 | Value: aws.String("foo"), 21 | }}, 22 | }, 23 | "foo", 24 | "bar", 25 | []string{"foo"}, 26 | ) 27 | 28 | if want, got := "", i.Tag("foo"); want != got { 29 | t.Errorf("want: %s, got: %s", want, got) 30 | } 31 | 32 | if want, got := "foo", i.Tag("test"); want != got { 33 | t.Errorf("want: %s, got: %s", want, got) 34 | } 35 | 36 | if want, got := map[string]string{"test": "foo"}, i.Tags(); !reflect.DeepEqual(want, got) { 37 | t.Errorf("want: %v, got: %v", want, got) 38 | } 39 | } 40 | 41 | func TestSortByState(t *testing.T) { 42 | var ( 43 | img1 = Image{ 44 | Image: &ec2.Image{ 45 | CreationDate: aws.String("2017-10-29T16:00:00.000Z"), 46 | Tags: []*ec2.Tag{{ 47 | Key: aws.String(DefaultStateTag), 48 | Value: aws.String("available"), 49 | }}, 50 | }, 51 | } 52 | img2 = Image{ 53 | Image: &ec2.Image{ 54 | CreationDate: aws.String("2017-05-15T16:00:00.000Z"), 55 | Tags: []*ec2.Tag{{ 56 | Key: aws.String(DefaultStateTag), 57 | Value: aws.String("deprecated"), 58 | }}, 59 | }, 60 | } 61 | img3 = Image{ 62 | Image: &ec2.Image{ 63 | CreationDate: aws.String("2017-10-25T16:00:00.000Z"), 64 | Tags: []*ec2.Tag{{ 65 | Key: aws.String(DefaultStateTag), 66 | Value: aws.String("foo"), 67 | }}, 68 | }, 69 | } 70 | img4 = Image{ 71 | Image: &ec2.Image{ 72 | CreationDate: aws.String("2017-10-25T16:00:00.000Z"), 73 | Tags: []*ec2.Tag{{ 74 | Key: aws.String(DefaultStateTag), 75 | Value: aws.String("available"), 76 | }}, 77 | }, 78 | } 79 | ) 80 | 81 | images := []Image{img3, img2, img4, img1} 82 | sortedImages := []Image{img1, img4, img2, img3} 83 | 84 | SortByState(DefaultStateTag, images) 85 | 86 | if !reflect.DeepEqual(sortedImages, images) { 87 | t.Errorf("\n\twant: %+v\n\t got: %+v", sortedImages, images) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /api/query/params.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intuit, Inc. All rights reserved. 2 | // Use of this source code is governed the MIT license 3 | // that can be found in the LICENSE file. 4 | 5 | package query 6 | 7 | import ( 8 | "fmt" 9 | "net/url" 10 | "strings" 11 | ) 12 | 13 | // Params defines all the dimensions of a query. 14 | type Params struct { 15 | regions []string 16 | images []string 17 | tags map[string][]string 18 | ownerID string 19 | launchPerm string 20 | callback string 21 | pretty bool 22 | } 23 | 24 | // Decode populates a Params from a URL. 25 | func (p *Params) Decode(stateTag string, u *url.URL) error { 26 | params, err := url.ParseQuery(u.RawQuery) 27 | if err != nil { 28 | return err 29 | } 30 | 31 | p.regions = []string{} 32 | p.images = []string{} 33 | p.tags = map[string][]string{} 34 | 35 | for key, values := range params { 36 | values = dedup(values) 37 | switch key { 38 | case "tag": 39 | for _, value := range values { 40 | if i := strings.Index(value, ":"); i != -1 { 41 | p.tags[value[:i]] = append(p.tags[value[:i]], value[i+1:]) 42 | } else { 43 | return fmt.Errorf("invalid query tag value: %s", value) 44 | } 45 | } 46 | case stateTag, "state", "status": // aliases for the state tag 47 | p.tags[stateTag] = append(p.tags[stateTag], values...) 48 | case "ami": 49 | p.images = values 50 | case "region": 51 | p.regions = values 52 | case "owner_id": 53 | p.ownerID = values[0] 54 | case "launch_permission": 55 | p.launchPerm = values[0] 56 | case "callback": 57 | p.callback = values[0] 58 | case "pretty": 59 | p.pretty = p.pretty || values[0] != "0" 60 | default: 61 | return fmt.Errorf("unknown query key: %s", key) 62 | } 63 | } 64 | 65 | return nil 66 | } 67 | 68 | // Removes dups from a string slice. 69 | func dedup(items []string) []string { 70 | newItems := []string{} 71 | added := map[string]struct{}{} 72 | for _, item := range items { 73 | if _, ok := added[item]; !ok { 74 | newItems = append(newItems, item) 75 | added[item] = struct{}{} 76 | } 77 | } 78 | return newItems 79 | } 80 | -------------------------------------------------------------------------------- /api/query/query_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Intuit, Inc. All rights reserved. 2 | // Use of this source code is governed the MIT license 3 | // that can be found in the LICENSE file. 4 | 5 | package query 6 | 7 | import ( 8 | "errors" 9 | "net/http" 10 | "net/http/httptest" 11 | "testing" 12 | 13 | "github.com/intuit/ami-query/amicache" 14 | 15 | "github.com/aws/aws-sdk-go/aws" 16 | "github.com/aws/aws-sdk-go/service/ec2" 17 | ) 18 | 19 | type mockCache struct { 20 | filterErr error 21 | collectLaunchPerms bool 22 | } 23 | 24 | func (mockCache) Regions() []string { return []string{"us-west-2"} } 25 | func (m *mockCache) StateTag() string { return amicache.DefaultStateTag } 26 | func (m *mockCache) CollectLaunchPermissions() bool { return m.collectLaunchPerms } 27 | func (m *mockCache) FilterImages(string, *amicache.Filter) ([]amicache.Image, error) { 28 | images := []amicache.Image{ 29 | { 30 | OwnerID: "123456789012", 31 | Region: "us-west-2", 32 | Image: &ec2.Image{ 33 | Name: aws.String("test-ami-1"), 34 | Description: aws.String("Test AMI 1"), 35 | VirtualizationType: aws.String("hvm"), 36 | CreationDate: aws.String("2017-11-29T16:00:00.000Z"), 37 | ImageId: aws.String("ami-1a2b3c4d"), 38 | Tags: []*ec2.Tag{{ 39 | Key: aws.String(amicache.DefaultStateTag), 40 | Value: aws.String("available"), 41 | }}, 42 | }, 43 | }, 44 | } 45 | return images, m.filterErr 46 | } 47 | 48 | func TestHandler(t *testing.T) { 49 | var tests = []struct { 50 | name string 51 | query string 52 | statusCode int 53 | filterErr error 54 | }{ 55 | {"amis", "/amis", http.StatusOK, nil}, 56 | {"callback", "/amis?callback=foo", http.StatusOK, nil}, 57 | {"pretty", "/amis?pretty", http.StatusOK, nil}, 58 | {"bad_key", "/amis?foo=bar", http.StatusBadRequest, nil}, 59 | {"bad_tag", "/amis?tag=foobar", http.StatusBadRequest, nil}, 60 | {"bad_region", "/amis?region=us-foo-1", http.StatusBadRequest, errors.New("foo")}, 61 | } 62 | 63 | mc := &mockCache{} 64 | ts := httptest.NewServer(&API{ 65 | cache: mc, 66 | regions: []string{"us-west-2"}, 67 | }) 68 | defer ts.Close() 69 | 70 | for _, tt := range tests { 71 | t.Run(tt.name, func(t *testing.T) { 72 | mc.filterErr = tt.filterErr 73 | defer func() { mc.filterErr = nil }() 74 | 75 | rsp, err := http.Get(ts.URL + tt.query) 76 | if err != nil { 77 | t.Errorf("want: , got: %v", err) 78 | return 79 | } 80 | 81 | if rsp.StatusCode != tt.statusCode { 82 | t.Errorf("want: status %d, got: status %d", tt.statusCode, rsp.StatusCode) 83 | } 84 | }) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/intuit/ami-query 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/aws/aws-sdk-go v1.25.14 7 | github.com/go-kit/kit v0.6.0 8 | github.com/go-logfmt/logfmt v0.3.0 // indirect 9 | github.com/go-stack/stack v1.7.0 // indirect 10 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect 11 | github.com/gorilla/handlers v1.3.0 12 | github.com/gorilla/mux v1.6.0 13 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect 14 | github.com/oklog/oklog v0.2.2 15 | github.com/stretchr/testify v1.4.0 // indirect 16 | golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 // indirect 17 | ) 18 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/aws/aws-sdk-go v1.25.14 h1:hEsU+cukBOQe1wRRuvEgG+y6AVCyS2eyHWuTefhGxTY= 2 | github.com/aws/aws-sdk-go v1.25.14/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= 3 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 4 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 5 | github.com/go-kit/kit v0.6.0 h1:wTifptAGIyIuir4bRyN4h7+kAa2a4eepLYVmRe5qqQ8= 6 | github.com/go-kit/kit v0.6.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 7 | github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2ic= 8 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 9 | github.com/go-stack/stack v1.7.0 h1:S04+lLfST9FvL8dl4R31wVUC/paZp/WQZbLmUgWboGw= 10 | github.com/go-stack/stack v1.7.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 11 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk= 12 | github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 13 | github.com/gorilla/handlers v1.3.0 h1:tsg9qP3mjt1h4Roxp+M1paRjrVBfPSOpBuVclh6YluI= 14 | github.com/gorilla/handlers v1.3.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= 15 | github.com/gorilla/mux v1.6.0 h1:UykbtMB/w5No2LmE16gINgLj+r/vbziTgaoERQv6U+0= 16 | github.com/gorilla/mux v1.6.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 17 | github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= 18 | github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= 19 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= 20 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 21 | github.com/oklog/oklog v0.2.2 h1:4W3HfADpCfWVI6oo0qhfRFmkjVGuOEY+QKxK8f7XjhI= 22 | github.com/oklog/oklog v0.2.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= 23 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 24 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 25 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 26 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 27 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 28 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 29 | golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 h1:p9xBe/w/OzkeYVKm234g55gMdD1nSIooTir5kV11kfA= 30 | golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 31 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 32 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 33 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 34 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 35 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 36 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 37 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 38 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intuit, Inc. All rights reserved. 2 | // Use of this source code is governed the MIT license 3 | // that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "context" 9 | "os" 10 | "os/signal" 11 | "path" 12 | "syscall" 13 | "testing" 14 | ) 15 | 16 | func TestSigTrapper(t *testing.T) { 17 | errCh := make(chan error) 18 | ctx, cancel := context.WithCancel(context.Background()) 19 | 20 | go func() { errCh <- sigTrapper(ctx, nil) }() 21 | cancel() 22 | 23 | if want, got := context.Canceled, <-errCh; want != got { 24 | t.Errorf("want: %v, got: %v", want, got) 25 | } 26 | 27 | sigCh := make(chan os.Signal, 1) 28 | signal.Notify(sigCh, syscall.SIGINT) 29 | 30 | go func() { errCh <- sigTrapper(context.Background(), sigCh) }() 31 | 32 | if err := syscall.Kill(syscall.Getpid(), syscall.SIGINT); err != nil { 33 | t.Fatal(err) 34 | } 35 | 36 | err := <-errCh 37 | 38 | if want, got := "received signal interrupt", err.Error(); want != got { 39 | t.Errorf("want: %s, got: %s", want, got) 40 | } 41 | } 42 | 43 | func TestSetLoggerStderr(t *testing.T) { 44 | logger, err := setLogger("") 45 | if err != nil { 46 | t.Fatal(err) 47 | } 48 | if logger != os.Stderr { 49 | t.Errorf("want: os.Stderr, got: %T", logger) 50 | } 51 | } 52 | 53 | func TestSetLoggerFile(t *testing.T) { 54 | file := path.Join(os.TempDir(), "ami-query-test.txt") 55 | if _, err := setLogger(file); err != nil { 56 | t.Fatal(err) 57 | } 58 | os.Remove(file) 59 | } 60 | 61 | func TestSetLoggerBadFile(t *testing.T) { 62 | _, err := setLogger("/F0o/b4r.txt") 63 | if want, got := "open /F0o/b4r.txt: no such file or directory", err.Error(); want != got { 64 | t.Errorf("want: %s, got: %s", want, got) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /resources/Makefile: -------------------------------------------------------------------------------- 1 | NAME = ami-query 2 | VERSION := $(shell grep '^const version' ../version.go | awk -F\" '{print $$2}') 3 | RPM_TOPDIR = "$(shell pwd)/rpmbuild" 4 | 5 | RPMBUILD_ARGS := \ 6 | --define "_topdir $(RPM_TOPDIR)" \ 7 | --define "name $(NAME)" \ 8 | --define "version $(VERSION)" 9 | 10 | .PHONY: all 11 | all: clean 12 | @mkdir -p $(RPM_TOPDIR)/{BUILD,RPMS,SRPMS} 13 | @mkdir -p $(RPM_TOPDIR)/SOURCES/$(NAME)-$(VERSION) 14 | @cp -p ./rhel/{settings,ami-query.service} $(RPM_TOPDIR)/SOURCES/$(NAME)-$(VERSION)/ 15 | @cp -p ../{bin/ami-query,README.md} $(RPM_TOPDIR)/SOURCES/$(NAME)-$(VERSION)/ 16 | @tar czf $(RPM_TOPDIR)/SOURCES/$(NAME)-$(VERSION).tar.gz -C $(RPM_TOPDIR)/SOURCES --exclude ".git" $(NAME)-$(VERSION) 17 | @rpmbuild $(RPMBUILD_ARGS) -ba --clean ./rhel/$(NAME).spec 18 | @cp -p $(RPM_TOPDIR)/RPMS/x86_64/$(NAME)-$(VERSION)*.x86_64.rpm ../ 19 | 20 | .PHONY: clean 21 | clean: 22 | @rm -rf $(RPM_TOPDIR) 23 | 24 | .PHONY: check-version 25 | check-version: 26 | ifndef VERSION 27 | $(error VERSION is undefined) 28 | endif 29 | -------------------------------------------------------------------------------- /resources/rhel/ami-query.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=amiquery RESTful service 3 | After=network.target 4 | 5 | [Service] 6 | User=ami-query 7 | EnvironmentFile=-/etc/sysconfig/ami-query 8 | ExecStart=/usr/bin/ami-query 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /resources/rhel/ami-query.spec: -------------------------------------------------------------------------------- 1 | Name: %{name} 2 | Version: %{version} 3 | Release: 1%{?dist} 4 | Summary: A RESTful API service to query Amazon AWS AMIs. 5 | URL: https://github.com/intuit/ami-query 6 | License: MIT 7 | Group: Application/SystemTools 8 | Source0: %{name}-%{version}.tar.gz 9 | 10 | BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) 11 | BuildArch: x86_64 12 | 13 | %define debug_package %{nil} 14 | %define _unpackaged_files_terminate_build 0 15 | 16 | %description 17 | Provide a RESTful API to query information about Amazon AWS AMIs. 18 | 19 | %pre 20 | if grep ^ami-query: /etc/group >> /dev/null ; then 21 | : # group already exists 22 | else 23 | groupadd ami-query 24 | fi 25 | 26 | if grep ^ami-query: /etc/passwd >> /dev/null ; then 27 | : # user already exists 28 | else 29 | useradd -g ami-query -s /sbin/nologin ami-query 30 | fi 31 | 32 | %prep 33 | %setup -q 34 | 35 | %build 36 | 37 | %install 38 | rm -rf $RPM_BUILD_ROOT 39 | install -m 0755 -d $RPM_BUILD_ROOT/usr/bin/ 40 | install -m 0755 ami-query $RPM_BUILD_ROOT/usr/bin/ami-query 41 | install -m 0755 -d $RPM_BUILD_ROOT/etc/sysconfig/ 42 | install -m 0640 settings $RPM_BUILD_ROOT/etc/sysconfig/ami-query 43 | 44 | install -m 0755 -d $RPM_BUILD_ROOT/usr/lib/systemd/system/ 45 | install -m 0644 ami-query.service $RPM_BUILD_ROOT/usr/lib/systemd/system/ami-query.service 46 | 47 | %clean 48 | rm -rf $RPM_BUILD_ROOT 49 | 50 | %files 51 | %defattr(-,root,root,-) 52 | %doc README.md 53 | /usr/bin/ami-query 54 | %config(noreplace) %attr(0640,root,ami-query) /etc/sysconfig/ami-query 55 | 56 | /usr/lib/systemd/system/ami-query.service 57 | 58 | %changelog 59 | * Thu Sep 24 2015 James Massara 60 | See https://github.com/intuit/ami-query/blob/master/CHANGELOG.md 61 | -------------------------------------------------------------------------------- /resources/rhel/settings: -------------------------------------------------------------------------------- 1 | # 2 | # User account that runs the ami-query daemon. 3 | # 4 | # NOTE: changing this setting will also require updating the permissions of 5 | # AMIQUERY_APP_LOGFILE and AMIQUERY_HTTP_LOGFILE. 6 | # 7 | AMIQUERY_USER=ami-query 8 | 9 | # 10 | # The AWS account owner IDs used to filter AMI results. The value must be a 11 | # comma-separate list of IDs (e.g. "111122223333,444455556666"). 12 | # 13 | # NOTE: This value must be defined for ami-query to start. 14 | # 15 | AMIQUERY_OWNER_IDS= 16 | 17 | # 18 | # The name of the role ued for AssumeRole. This role must exist in every account 19 | # provided by AMIQUERY_OWNER_IDS and the role must allow access from the account 20 | # ami-query is running in. 21 | # 22 | # NOTE: This value must be defined for ami-query to start. 23 | # 24 | #AMIQUERY_ROLE_NAME= 25 | 26 | # 27 | # AWS API access key 28 | # 29 | # NOTE: This value must be defined either through this environment variable, 30 | # the ~/.aws/credentials file, or an IAM role pulled from EC2 meta-data. 31 | # 32 | #AWS_ACCESS_KEY_ID= 33 | 34 | # 35 | # AWS API secret key 36 | # 37 | # NOTE: This value must be defined either through this environment variable, 38 | # the ~/.aws/credentials file, or an IAM role pulled from EC2 meta-data. 39 | # 40 | #AWS_SECRET_ACCESS_KEY= 41 | 42 | # 43 | # The tag-key name used to filter the results of ec2:DescribeImages. The value 44 | # is irrelevant, only the existence of the tag is required. 45 | # 46 | #AMIQUERY_TAG_FILTER= 47 | 48 | # 49 | # The regions to query for AMIs. The value must be a comma-separated list of 50 | # regions (e.g. "us-east-1,us-west-1"). If undefined, all AWS Standard Regions 51 | # will be used. 52 | # 53 | #AMIQUERY_REGIONS= 54 | 55 | # 56 | # The address and port ami-query will bind to. If undefined, the default value 57 | # is localhost:8080 58 | # 59 | #AMIQUERY_LISTEN_ADDRESS=localhost:8080 60 | 61 | # 62 | # The time out between cache updates. If undefined, the default value is 15 63 | # minutes. 64 | # 65 | #AMIQUERY_CACHE_TTL=15m 66 | 67 | # 68 | # The following two settings control the number of concurrent 69 | # DescribeImageAttributes API requests and allowed retries. These are used to 70 | # control RequestLimitExceed errors. 71 | # See the following for more information: 72 | # http://docs.aws.amazon.com/AWSEC2/latest/APIReference/query-api-troubleshooting.html#api-request-rate 73 | # 74 | #AMIQUERY_CACHE_MAX_CONCURRENT_REQUESTS=15 75 | #AMIQUERY_CACHE_MAX_REQUEST_RETRIES=5 76 | 77 | # 78 | # Application log file location. If undefined, ami-query logs to STDERR. 79 | # 80 | # NOTE: Log rotation is not handled by ami-query. Consider using logrotate to 81 | # manage the ami-query log file. 82 | # 83 | #AMIQUERY_APP_LOGFILE=/var/log/ami-query.log 84 | 85 | # 86 | # HTTP log file location. If undefined, ami-query logs to STDERR. 87 | # 88 | # NOTE: Log rotation is not handled by ami-query. Consider using logrotate to 89 | # manage the ami-query HTTP log file. 90 | # 91 | #AMIQUERY_HTTP_LOGFILE=/var/log/ami-query_http.log 92 | 93 | # 94 | # A comma-separated list of allowed Origins. 95 | # 96 | #AMIQUERY_CORS_ALLOWED_ORIGINS= 97 | 98 | # 99 | # The SSL certificate to use if running HTTPS. 100 | # 101 | #SSL_CERTIFICATE_FILE= 102 | 103 | # 104 | # The SSL key to use if running HTTPS. 105 | #SSL_KEY_FILE= 106 | 107 | # 108 | # The following settings only apply when communicating to AWS through a proxy 109 | # server. 110 | # 111 | #http_proxy= 112 | #https_proxy= 113 | #no_proxy= -------------------------------------------------------------------------------- /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/copy.go: -------------------------------------------------------------------------------- 1 | package awsutil 2 | 3 | import ( 4 | "io" 5 | "reflect" 6 | "time" 7 | ) 8 | 9 | // Copy deeply copies a src structure to dst. Useful for copying request and 10 | // response structures. 11 | // 12 | // Can copy between structs of different type, but will only copy fields which 13 | // are assignable, and exist in both structs. Fields which are not assignable, 14 | // or do not exist in both structs are ignored. 15 | func Copy(dst, src interface{}) { 16 | dstval := reflect.ValueOf(dst) 17 | if !dstval.IsValid() { 18 | panic("Copy dst cannot be nil") 19 | } 20 | 21 | rcopy(dstval, reflect.ValueOf(src), true) 22 | } 23 | 24 | // CopyOf returns a copy of src while also allocating the memory for dst. 25 | // src must be a pointer type or this operation will fail. 26 | func CopyOf(src interface{}) (dst interface{}) { 27 | dsti := reflect.New(reflect.TypeOf(src).Elem()) 28 | dst = dsti.Interface() 29 | rcopy(dsti, reflect.ValueOf(src), true) 30 | return 31 | } 32 | 33 | // rcopy performs a recursive copy of values from the source to destination. 34 | // 35 | // root is used to skip certain aspects of the copy which are not valid 36 | // for the root node of a object. 37 | func rcopy(dst, src reflect.Value, root bool) { 38 | if !src.IsValid() { 39 | return 40 | } 41 | 42 | switch src.Kind() { 43 | case reflect.Ptr: 44 | if _, ok := src.Interface().(io.Reader); ok { 45 | if dst.Kind() == reflect.Ptr && dst.Elem().CanSet() { 46 | dst.Elem().Set(src) 47 | } else if dst.CanSet() { 48 | dst.Set(src) 49 | } 50 | } else { 51 | e := src.Type().Elem() 52 | if dst.CanSet() && !src.IsNil() { 53 | if _, ok := src.Interface().(*time.Time); !ok { 54 | dst.Set(reflect.New(e)) 55 | } else { 56 | tempValue := reflect.New(e) 57 | tempValue.Elem().Set(src.Elem()) 58 | // Sets time.Time's unexported values 59 | dst.Set(tempValue) 60 | } 61 | } 62 | if src.Elem().IsValid() { 63 | // Keep the current root state since the depth hasn't changed 64 | rcopy(dst.Elem(), src.Elem(), root) 65 | } 66 | } 67 | case reflect.Struct: 68 | t := dst.Type() 69 | for i := 0; i < t.NumField(); i++ { 70 | name := t.Field(i).Name 71 | srcVal := src.FieldByName(name) 72 | dstVal := dst.FieldByName(name) 73 | if srcVal.IsValid() && dstVal.CanSet() { 74 | rcopy(dstVal, srcVal, false) 75 | } 76 | } 77 | case reflect.Slice: 78 | if src.IsNil() { 79 | break 80 | } 81 | 82 | s := reflect.MakeSlice(src.Type(), src.Len(), src.Cap()) 83 | dst.Set(s) 84 | for i := 0; i < src.Len(); i++ { 85 | rcopy(dst.Index(i), src.Index(i), false) 86 | } 87 | case reflect.Map: 88 | if src.IsNil() { 89 | break 90 | } 91 | 92 | s := reflect.MakeMap(src.Type()) 93 | dst.Set(s) 94 | for _, k := range src.MapKeys() { 95 | v := src.MapIndex(k) 96 | v2 := reflect.New(v.Type()).Elem() 97 | rcopy(v2, v, false) 98 | dst.SetMapIndex(k, v2) 99 | } 100 | default: 101 | // Assign the value if possible. If its not assignable, the value would 102 | // need to be converted and the impact of that may be unexpected, or is 103 | // not compatible with the dst type. 104 | if src.Type().AssignableTo(dst.Type()) { 105 | dst.Set(src) 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /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 they 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/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 | for i := 0; i < v.Type().NumField(); i++ { 27 | ft := v.Type().Field(i) 28 | fv := v.Field(i) 29 | 30 | if ft.Name[0:1] == strings.ToLower(ft.Name[0:1]) { 31 | continue // ignore unexported fields 32 | } 33 | if (fv.Kind() == reflect.Ptr || fv.Kind() == reflect.Slice) && fv.IsNil() { 34 | continue // ignore unset fields 35 | } 36 | 37 | buf.WriteString(strings.Repeat(" ", indent+2)) 38 | buf.WriteString(ft.Name + ": ") 39 | 40 | if tag := ft.Tag.Get("sensitive"); tag == "true" { 41 | buf.WriteString("") 42 | } else { 43 | stringValue(fv, indent+2, buf) 44 | } 45 | 46 | buf.WriteString(",\n") 47 | } 48 | 49 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 50 | case reflect.Slice: 51 | nl, id, id2 := "", "", "" 52 | if v.Len() > 3 { 53 | nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) 54 | } 55 | buf.WriteString("[" + nl) 56 | for i := 0; i < v.Len(); i++ { 57 | buf.WriteString(id2) 58 | stringValue(v.Index(i), indent+2, buf) 59 | 60 | if i < v.Len()-1 { 61 | buf.WriteString("," + nl) 62 | } 63 | } 64 | 65 | buf.WriteString(nl + id + "]") 66 | case reflect.Map: 67 | buf.WriteString("{\n") 68 | 69 | for i, k := range v.MapKeys() { 70 | buf.WriteString(strings.Repeat(" ", indent+2)) 71 | buf.WriteString(k.String() + ": ") 72 | stringValue(v.MapIndex(k), indent+2, buf) 73 | 74 | if i < v.Len()-1 { 75 | buf.WriteString(",\n") 76 | } 77 | } 78 | 79 | buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") 80 | default: 81 | format := "%v" 82 | switch v.Interface().(type) { 83 | case string: 84 | format = "%q" 85 | } 86 | fmt.Fprintf(buf, format, v.Interface()) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/client/metadata" 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | ) 10 | 11 | // A Config provides configuration to a service client instance. 12 | type Config struct { 13 | Config *aws.Config 14 | Handlers request.Handlers 15 | Endpoint string 16 | SigningRegion string 17 | SigningName string 18 | 19 | // States that the signing name did not come from a modeled source but 20 | // was derived based on other data. Used by service client constructors 21 | // to determine if the signin name can be overridden based on metadata the 22 | // service has. 23 | SigningNameDerived bool 24 | } 25 | 26 | // ConfigProvider provides a generic way for a service client to receive 27 | // the ClientConfig without circular dependencies. 28 | type ConfigProvider interface { 29 | ClientConfig(serviceName string, cfgs ...*aws.Config) Config 30 | } 31 | 32 | // ConfigNoResolveEndpointProvider same as ConfigProvider except it will not 33 | // resolve the endpoint automatically. The service client's endpoint must be 34 | // provided via the aws.Config.Endpoint field. 35 | type ConfigNoResolveEndpointProvider interface { 36 | ClientConfigNoResolveEndpoint(cfgs ...*aws.Config) Config 37 | } 38 | 39 | // A Client implements the base client request and response handling 40 | // used by all service clients. 41 | type Client struct { 42 | request.Retryer 43 | metadata.ClientInfo 44 | 45 | Config aws.Config 46 | Handlers request.Handlers 47 | } 48 | 49 | // New will return a pointer to a new initialized service client. 50 | func New(cfg aws.Config, info metadata.ClientInfo, handlers request.Handlers, options ...func(*Client)) *Client { 51 | svc := &Client{ 52 | Config: cfg, 53 | ClientInfo: info, 54 | Handlers: handlers.Copy(), 55 | } 56 | 57 | switch retryer, ok := cfg.Retryer.(request.Retryer); { 58 | case ok: 59 | svc.Retryer = retryer 60 | case cfg.Retryer != nil && cfg.Logger != nil: 61 | s := fmt.Sprintf("WARNING: %T does not implement request.Retryer; using DefaultRetryer instead", cfg.Retryer) 62 | cfg.Logger.Log(s) 63 | fallthrough 64 | default: 65 | maxRetries := aws.IntValue(cfg.MaxRetries) 66 | if cfg.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries { 67 | maxRetries = DefaultRetryerMaxNumRetries 68 | } 69 | svc.Retryer = DefaultRetryer{NumMaxRetries: maxRetries} 70 | } 71 | 72 | svc.AddDebugHandlers() 73 | 74 | for _, option := range options { 75 | option(svc) 76 | } 77 | 78 | return svc 79 | } 80 | 81 | // NewRequest returns a new Request pointer for the service API 82 | // operation and parameters. 83 | func (c *Client) NewRequest(operation *request.Operation, params interface{}, data interface{}) *request.Request { 84 | return request.New(c.Config, c.ClientInfo, c.Handlers, c.Retryer, operation, params, data) 85 | } 86 | 87 | // AddDebugHandlers injects debug logging handlers into the service to log request 88 | // debug information. 89 | func (c *Client) AddDebugHandlers() { 90 | if !c.Config.LogLevel.AtLeast(aws.LogDebug) { 91 | return 92 | } 93 | 94 | c.Handlers.Send.PushFrontNamed(LogHTTPRequestHandler) 95 | c.Handlers.Send.PushBackNamed(LogHTTPResponseHandler) 96 | } 97 | -------------------------------------------------------------------------------- /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 | ServiceID string 7 | APIVersion string 8 | Endpoint string 9 | SigningName string 10 | SigningRegion string 11 | JSONVersion string 12 | TargetPrefix string 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/client/no_op_retryer.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/aws/aws-sdk-go/aws/request" 7 | ) 8 | 9 | // NoOpRetryer provides a retryer that performs no retries. 10 | // It should be used when we do not want retries to be performed. 11 | type NoOpRetryer struct{} 12 | 13 | // MaxRetries returns the number of maximum returns the service will use to make 14 | // an individual API; For NoOpRetryer the MaxRetries will always be zero. 15 | func (d NoOpRetryer) MaxRetries() int { 16 | return 0 17 | } 18 | 19 | // ShouldRetry will always return false for NoOpRetryer, as it should never retry. 20 | func (d NoOpRetryer) ShouldRetry(_ *request.Request) bool { 21 | return false 22 | } 23 | 24 | // RetryRules returns the delay duration before retrying this request again; 25 | // since NoOpRetryer does not retry, RetryRules always returns 0. 26 | func (d NoOpRetryer) RetryRules(_ *request.Request) time.Duration { 27 | return 0 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_1_5.go: -------------------------------------------------------------------------------- 1 | // +build !go1.9 2 | 3 | package aws 4 | 5 | import "time" 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 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_1_9.go: -------------------------------------------------------------------------------- 1 | // +build go1.9 2 | 3 | package aws 4 | 5 | import "context" 6 | 7 | // Context is an alias of the Go stdlib's context.Context interface. 8 | // It can be used within the SDK's API operation "WithContext" methods. 9 | // 10 | // See https://golang.org/pkg/context on how to use contexts. 11 | type Context = context.Context 12 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_background_1_5.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package aws 4 | 5 | import "time" 6 | 7 | // An emptyCtx is a copy of the Go 1.7 context.emptyCtx type. This is copied to 8 | // provide a 1.6 and 1.5 safe version of context that is compatible with Go 9 | // 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 | 43 | // BackgroundContext returns a context that will never be canceled, has no 44 | // values, and no deadline. This context is used by the SDK to provide 45 | // backwards compatibility with non-context API operations and functionality. 46 | // 47 | // Go 1.6 and before: 48 | // This context function is equivalent to context.Background in the Go stdlib. 49 | // 50 | // Go 1.7 and later: 51 | // The context returned will be the value returned by context.Background() 52 | // 53 | // See https://golang.org/pkg/context for more information on Contexts. 54 | func BackgroundContext() Context { 55 | return backgroundCtx 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_background_1_7.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package aws 4 | 5 | import "context" 6 | 7 | // BackgroundContext returns a context that will never be canceled, has no 8 | // values, and no deadline. This context is used by the SDK to provide 9 | // backwards compatibility with non-context API operations and functionality. 10 | // 11 | // Go 1.6 and before: 12 | // This context function is equivalent to context.Background in the Go stdlib. 13 | // 14 | // Go 1.7 and later: 15 | // The context returned will be the value returned by context.Background() 16 | // 17 | // See https://golang.org/pkg/context for more information on Contexts. 18 | func BackgroundContext() Context { 19 | return context.Background() 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/context_sleep.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // SleepWithContext will wait for the timer duration to expire, or the context 8 | // is canceled. Which ever happens first. If the context is canceled the Context's 9 | // error will be returned. 10 | // 11 | // Expects Context to always return a non-nil error if the Done channel is closed. 12 | func SleepWithContext(ctx Context, dur time.Duration) error { 13 | t := time.NewTimer(dur) 14 | defer t.Stop() 15 | 16 | select { 17 | case <-t.C: 18 | break 19 | case <-ctx.Done(): 20 | return ctx.Err() 21 | } 22 | 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /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/corehandlers/user_agent.go: -------------------------------------------------------------------------------- 1 | package corehandlers 2 | 3 | import ( 4 | "os" 5 | "runtime" 6 | 7 | "github.com/aws/aws-sdk-go/aws" 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | ) 10 | 11 | // SDKVersionUserAgentHandler is a request handler for adding the SDK Version 12 | // to the user agent. 13 | var SDKVersionUserAgentHandler = request.NamedHandler{ 14 | Name: "core.SDKVersionUserAgentHandler", 15 | Fn: request.MakeAddToUserAgentHandler(aws.SDKName, aws.SDKVersion, 16 | runtime.Version(), runtime.GOOS, runtime.GOARCH), 17 | } 18 | 19 | const execEnvVar = `AWS_EXECUTION_ENV` 20 | const execEnvUAKey = `exec-env` 21 | 22 | // AddHostExecEnvUserAgentHander is a request handler appending the SDK's 23 | // execution environment to the user agent. 24 | // 25 | // If the environment variable AWS_EXECUTION_ENV is set, its value will be 26 | // appended to the user agent string. 27 | var AddHostExecEnvUserAgentHander = request.NamedHandler{ 28 | Name: "core.AddHostExecEnvUserAgentHander", 29 | Fn: func(r *request.Request) { 30 | v := os.Getenv(execEnvVar) 31 | if len(v) == 0 { 32 | return 33 | } 34 | 35 | request.AddToUserAgent(r, execEnvUAKey+"/"+v) 36 | }, 37 | } 38 | -------------------------------------------------------------------------------- /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 | ErrAccessKeyIDNotFound = awserr.New("EnvAccessKeyNotFound", "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment", nil) 16 | 17 | // ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key 18 | // can't be found in the process's environment. 19 | ErrSecretAccessKeyNotFound = awserr.New("EnvSecretNotFound", "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment", nil) 20 | ) 21 | 22 | // A EnvProvider retrieves credentials from the environment variables of the 23 | // running process. Environment credentials never expire. 24 | // 25 | // Environment variables used: 26 | // 27 | // * Access Key ID: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY 28 | // 29 | // * Secret Access Key: AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY 30 | type EnvProvider struct { 31 | retrieved bool 32 | } 33 | 34 | // NewEnvCredentials returns a pointer to a new Credentials object 35 | // wrapping the environment variable provider. 36 | func NewEnvCredentials() *Credentials { 37 | return NewCredentials(&EnvProvider{}) 38 | } 39 | 40 | // Retrieve retrieves the keys from the environment. 41 | func (e *EnvProvider) Retrieve() (Value, error) { 42 | e.retrieved = false 43 | 44 | id := os.Getenv("AWS_ACCESS_KEY_ID") 45 | if id == "" { 46 | id = os.Getenv("AWS_ACCESS_KEY") 47 | } 48 | 49 | secret := os.Getenv("AWS_SECRET_ACCESS_KEY") 50 | if secret == "" { 51 | secret = os.Getenv("AWS_SECRET_KEY") 52 | } 53 | 54 | if id == "" { 55 | return Value{ProviderName: EnvProviderName}, ErrAccessKeyIDNotFound 56 | } 57 | 58 | if secret == "" { 59 | return Value{ProviderName: EnvProviderName}, ErrSecretAccessKeyNotFound 60 | } 61 | 62 | e.retrieved = true 63 | return Value{ 64 | AccessKeyID: id, 65 | SecretAccessKey: secret, 66 | SessionToken: os.Getenv("AWS_SESSION_TOKEN"), 67 | ProviderName: EnvProviderName, 68 | }, nil 69 | } 70 | 71 | // IsExpired returns if the credentials have been retrieved. 72 | func (e *EnvProvider) IsExpired() bool { 73 | return !e.retrieved 74 | } 75 | -------------------------------------------------------------------------------- /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 | ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil) 13 | ) 14 | 15 | // A StaticProvider is a set of credentials which are set programmatically, 16 | // and will never expire. 17 | type StaticProvider struct { 18 | Value 19 | } 20 | 21 | // NewStaticCredentials returns a pointer to a new Credentials object 22 | // wrapping a static credentials value provider. 23 | func NewStaticCredentials(id, secret, token string) *Credentials { 24 | return NewCredentials(&StaticProvider{Value: Value{ 25 | AccessKeyID: id, 26 | SecretAccessKey: secret, 27 | SessionToken: token, 28 | }}) 29 | } 30 | 31 | // NewStaticCredentialsFromCreds returns a pointer to a new Credentials object 32 | // wrapping the static credentials value provide. Same as NewStaticCredentials 33 | // but takes the creds Value instead of individual fields 34 | func NewStaticCredentialsFromCreds(creds Value) *Credentials { 35 | return NewCredentials(&StaticProvider{Value: creds}) 36 | } 37 | 38 | // Retrieve returns the credentials or error if the credentials are invalid. 39 | func (s *StaticProvider) Retrieve() (Value, error) { 40 | if s.AccessKeyID == "" || s.SecretAccessKey == "" { 41 | return Value{ProviderName: StaticProviderName}, ErrStaticCredentialsEmpty 42 | } 43 | 44 | if len(s.Value.ProviderName) == 0 { 45 | s.Value.ProviderName = StaticProviderName 46 | } 47 | return s.Value, nil 48 | } 49 | 50 | // IsExpired returns if the credentials are expired. 51 | // 52 | // For StaticProvider, the credentials never expired. 53 | func (s *StaticProvider) IsExpired() bool { 54 | return false 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/csm/doc.go: -------------------------------------------------------------------------------- 1 | // Package csm provides the Client Side Monitoring (CSM) client which enables 2 | // sending metrics via UDP connection to the CSM agent. This package provides 3 | // control options, and configuration for the CSM client. The client can be 4 | // controlled manually, or automatically via the SDK's Session configuration. 5 | // 6 | // Enabling CSM client via SDK's Session configuration 7 | // 8 | // The CSM client can be enabled automatically via SDK's Session configuration. 9 | // The SDK's session configuration enables the CSM client if the AWS_CSM_PORT 10 | // environment variable is set to a non-empty value. 11 | // 12 | // The configuration options for the CSM client via the SDK's session 13 | // configuration are: 14 | // 15 | // * AWS_CSM_PORT= 16 | // The port number the CSM agent will receive metrics on. 17 | // 18 | // * AWS_CSM_HOST= 19 | // The hostname, or IP address the CSM agent will receive metrics on. 20 | // Without port number. 21 | // 22 | // Manually enabling the CSM client 23 | // 24 | // The CSM client can be started, paused, and resumed manually. The Start 25 | // function will enable the CSM client to publish metrics to the CSM agent. It 26 | // is safe to call Start concurrently, but if Start is called additional times 27 | // with different ClientID or address it will panic. 28 | // 29 | // r, err := csm.Start("clientID", ":31000") 30 | // if err != nil { 31 | // panic(fmt.Errorf("failed starting CSM: %v", err)) 32 | // } 33 | // 34 | // When controlling the CSM client manually, you must also inject its request 35 | // handlers into the SDK's Session configuration for the SDK's API clients to 36 | // publish metrics. 37 | // 38 | // sess, err := session.NewSession(&aws.Config{}) 39 | // if err != nil { 40 | // panic(fmt.Errorf("failed loading session: %v", err)) 41 | // } 42 | // 43 | // // Add CSM client's metric publishing request handlers to the SDK's 44 | // // Session Configuration. 45 | // r.InjectHandlers(&sess.Handlers) 46 | // 47 | // Controlling CSM client 48 | // 49 | // Once the CSM client has been enabled the Get function will return a Reporter 50 | // value that you can use to pause and resume the metrics published to the CSM 51 | // agent. If Get function is called before the reporter is enabled with the 52 | // Start function or via SDK's Session configuration nil will be returned. 53 | // 54 | // The Pause method can be called to stop the CSM client publishing metrics to 55 | // the CSM agent. The Continue method will resume metric publishing. 56 | // 57 | // // Get the CSM client Reporter. 58 | // r := csm.Get() 59 | // 60 | // // Will pause monitoring 61 | // r.Pause() 62 | // resp, err = client.GetObject(&s3.GetObjectInput{ 63 | // Bucket: aws.String("bucket"), 64 | // Key: aws.String("key"), 65 | // }) 66 | // 67 | // // Resume monitoring 68 | // r.Continue() 69 | package csm 70 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go: -------------------------------------------------------------------------------- 1 | package csm 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "sync" 7 | ) 8 | 9 | var ( 10 | lock sync.Mutex 11 | ) 12 | 13 | const ( 14 | // DefaultPort is used when no port is specified. 15 | DefaultPort = "31000" 16 | 17 | // DefaultHost is the host that will be used when none is specified. 18 | DefaultHost = "127.0.0.1" 19 | ) 20 | 21 | // AddressWithDefaults returns a CSM address built from the host and port 22 | // values. If the host or port is not set, default values will be used 23 | // instead. If host is "localhost" it will be replaced with "127.0.0.1". 24 | func AddressWithDefaults(host, port string) string { 25 | if len(host) == 0 || strings.EqualFold(host, "localhost") { 26 | host = DefaultHost 27 | } 28 | 29 | if len(port) == 0 { 30 | port = DefaultPort 31 | } 32 | 33 | // Only IP6 host can contain a colon 34 | if strings.Contains(host, ":") { 35 | return "[" + host + "]:" + port 36 | } 37 | 38 | return host + ":" + port 39 | } 40 | 41 | // Start will start a long running go routine to capture 42 | // client side metrics. Calling start multiple time will only 43 | // start the metric listener once and will panic if a different 44 | // client ID or port is passed in. 45 | // 46 | // r, err := csm.Start("clientID", "127.0.0.1:31000") 47 | // if err != nil { 48 | // panic(fmt.Errorf("expected no error, but received %v", err)) 49 | // } 50 | // sess := session.NewSession() 51 | // r.InjectHandlers(sess.Handlers) 52 | // 53 | // svc := s3.New(sess) 54 | // out, err := svc.GetObject(&s3.GetObjectInput{ 55 | // Bucket: aws.String("bucket"), 56 | // Key: aws.String("key"), 57 | // }) 58 | func Start(clientID string, url string) (*Reporter, error) { 59 | lock.Lock() 60 | defer lock.Unlock() 61 | 62 | if sender == nil { 63 | sender = newReporter(clientID, url) 64 | } else { 65 | if sender.clientID != clientID { 66 | panic(fmt.Errorf("inconsistent client IDs. %q was expected, but received %q", sender.clientID, clientID)) 67 | } 68 | 69 | if sender.url != url { 70 | panic(fmt.Errorf("inconsistent URLs. %q was expected, but received %q", sender.url, url)) 71 | } 72 | } 73 | 74 | if err := connect(url); err != nil { 75 | sender = nil 76 | return nil, err 77 | } 78 | 79 | return sender, nil 80 | } 81 | 82 | // Get will return a reporter if one exists, if one does not exist, nil will 83 | // be returned. 84 | func Get() *Reporter { 85 | lock.Lock() 86 | defer lock.Unlock() 87 | 88 | return sender 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/csm/metric_chan.go: -------------------------------------------------------------------------------- 1 | package csm 2 | 3 | import ( 4 | "sync/atomic" 5 | ) 6 | 7 | const ( 8 | runningEnum = iota 9 | pausedEnum 10 | ) 11 | 12 | var ( 13 | // MetricsChannelSize of metrics to hold in the channel 14 | MetricsChannelSize = 100 15 | ) 16 | 17 | type metricChan struct { 18 | ch chan metric 19 | paused *int64 20 | } 21 | 22 | func newMetricChan(size int) metricChan { 23 | return metricChan{ 24 | ch: make(chan metric, size), 25 | paused: new(int64), 26 | } 27 | } 28 | 29 | func (ch *metricChan) Pause() { 30 | atomic.StoreInt64(ch.paused, pausedEnum) 31 | } 32 | 33 | func (ch *metricChan) Continue() { 34 | atomic.StoreInt64(ch.paused, runningEnum) 35 | } 36 | 37 | func (ch *metricChan) IsPaused() bool { 38 | v := atomic.LoadInt64(ch.paused) 39 | return v == pausedEnum 40 | } 41 | 42 | // Push will push metrics to the metric channel if the channel 43 | // is not paused 44 | func (ch *metricChan) Push(m metric) bool { 45 | if ch.IsPaused() { 46 | return false 47 | } 48 | 49 | select { 50 | case ch.ch <- m: 51 | return true 52 | default: 53 | return false 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/csm/metric_exception.go: -------------------------------------------------------------------------------- 1 | package csm 2 | 3 | type metricException interface { 4 | Exception() string 5 | Message() string 6 | } 7 | 8 | type requestException struct { 9 | exception string 10 | message string 11 | } 12 | 13 | func (e requestException) Exception() string { 14 | return e.exception 15 | } 16 | func (e requestException) Message() string { 17 | return e.message 18 | } 19 | 20 | type awsException struct { 21 | requestException 22 | } 23 | 24 | type sdkException struct { 25 | requestException 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/defaults/shared_config.go: -------------------------------------------------------------------------------- 1 | package defaults 2 | 3 | import ( 4 | "github.com/aws/aws-sdk-go/internal/shareddefaults" 5 | ) 6 | 7 | // SharedCredentialsFilename returns the SDK's default file path 8 | // for the shared credentials file. 9 | // 10 | // Builds the shared config file path based on the OS's platform. 11 | // 12 | // - Linux/Unix: $HOME/.aws/credentials 13 | // - Windows: %USERPROFILE%\.aws\credentials 14 | func SharedCredentialsFilename() string { 15 | return shareddefaults.SharedCredentialsFilename() 16 | } 17 | 18 | // SharedConfigFilename returns the SDK's default file path for 19 | // the shared config file. 20 | // 21 | // Builds the shared config file path based on the OS's platform. 22 | // 23 | // - Linux/Unix: $HOME/.aws/config 24 | // - Windows: %USERPROFILE%\.aws\config 25 | func SharedConfigFilename() string { 26 | return shareddefaults.SharedConfigFilename() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/doc.go: -------------------------------------------------------------------------------- 1 | // Package aws provides the core SDK's utilities and shared types. Use this package's 2 | // utilities to simplify setting and reading API operations parameters. 3 | // 4 | // Value and Pointer Conversion Utilities 5 | // 6 | // This package includes a helper conversion utility for each scalar type the SDK's 7 | // API use. These utilities make getting a pointer of the scalar, and dereferencing 8 | // a pointer easier. 9 | // 10 | // Each conversion utility comes in two forms. Value to Pointer and Pointer to Value. 11 | // The Pointer to value will safely dereference the pointer and return its value. 12 | // If the pointer was nil, the scalar's zero value will be returned. 13 | // 14 | // The value to pointer functions will be named after the scalar type. So get a 15 | // *string from a string value use the "String" function. This makes it easy to 16 | // to get pointer of a literal string value, because getting the address of a 17 | // literal requires assigning the value to a variable first. 18 | // 19 | // var strPtr *string 20 | // 21 | // // Without the SDK's conversion functions 22 | // str := "my string" 23 | // strPtr = &str 24 | // 25 | // // With the SDK's conversion functions 26 | // strPtr = aws.String("my string") 27 | // 28 | // // Convert *string to string value 29 | // str = aws.StringValue(strPtr) 30 | // 31 | // In addition to scalars the aws package also includes conversion utilities for 32 | // map and slice for commonly types used in API parameters. The map and slice 33 | // conversion functions use similar naming pattern as the scalar conversion 34 | // functions. 35 | // 36 | // var strPtrs []*string 37 | // var strs []string = []string{"Go", "Gophers", "Go"} 38 | // 39 | // // Convert []string to []*string 40 | // strPtrs = aws.StringSlice(strs) 41 | // 42 | // // Convert []*string to []string 43 | // strs = aws.StringValueSlice(strPtrs) 44 | // 45 | // SDK Default HTTP Client 46 | // 47 | // The SDK will use the http.DefaultClient if a HTTP client is not provided to 48 | // the SDK's Session, or service client constructor. This means that if the 49 | // http.DefaultClient is modified by other components of your application the 50 | // modifications will be picked up by the SDK as well. 51 | // 52 | // In some cases this might be intended, but it is a better practice to create 53 | // a custom HTTP Client to share explicitly through your application. You can 54 | // configure the SDK to use the custom HTTP Client by setting the HTTPClient 55 | // value of the SDK's Config type when creating a Session or service client. 56 | package aws 57 | -------------------------------------------------------------------------------- /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.ID()) 25 | // for id, _ := range p.Regions() { 26 | // fmt.Println("*", id) 27 | // } 28 | // 29 | // fmt.Println("Services for", p.ID()) 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/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 | ErrMissingRegion = awserr.New("MissingRegion", "could not find region configuration", nil) 9 | 10 | // ErrMissingEndpoint is an error that is returned if an endpoint cannot be 11 | // resolved for a service. 12 | ErrMissingEndpoint = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) 13 | ) 14 | -------------------------------------------------------------------------------- /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 | // 8 | // values := aws.JSONValue{ 9 | // "Foo": "Bar", 10 | // } 11 | // values["Baz"] = "Qux" 12 | type JSONValue map[string]interface{} 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/connection_reset_error.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func isErrConnectionReset(err error) bool { 8 | if strings.Contains(err.Error(), "read: connection reset") { 9 | return false 10 | } 11 | 12 | if strings.Contains(err.Error(), "connection reset") || 13 | strings.Contains(err.Error(), "broken pipe") { 14 | return true 15 | } 16 | 17 | return false 18 | } 19 | -------------------------------------------------------------------------------- /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/offset_reader.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "io" 5 | "sync" 6 | 7 | "github.com/aws/aws-sdk-go/internal/sdkio" 8 | ) 9 | 10 | // offsetReader is a thread-safe io.ReadCloser to prevent racing 11 | // with retrying requests 12 | type offsetReader struct { 13 | buf io.ReadSeeker 14 | lock sync.Mutex 15 | closed bool 16 | } 17 | 18 | func newOffsetReader(buf io.ReadSeeker, offset int64) (*offsetReader, error) { 19 | reader := &offsetReader{} 20 | _, err := buf.Seek(offset, sdkio.SeekStart) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | reader.buf = buf 26 | return reader, nil 27 | } 28 | 29 | // Close will close the instance of the offset reader's access to 30 | // the underlying io.ReadSeeker. 31 | func (o *offsetReader) Close() error { 32 | o.lock.Lock() 33 | defer o.lock.Unlock() 34 | o.closed = true 35 | return nil 36 | } 37 | 38 | // Read is a thread-safe read of the underlying io.ReadSeeker 39 | func (o *offsetReader) Read(p []byte) (int, error) { 40 | o.lock.Lock() 41 | defer o.lock.Unlock() 42 | 43 | if o.closed { 44 | return 0, io.EOF 45 | } 46 | 47 | return o.buf.Read(p) 48 | } 49 | 50 | // Seek is a thread-safe seeking operation. 51 | func (o *offsetReader) Seek(offset int64, whence int) (int64, error) { 52 | o.lock.Lock() 53 | defer o.lock.Unlock() 54 | 55 | return o.buf.Seek(offset, whence) 56 | } 57 | 58 | // CloseAndCopy will return a new offsetReader with a copy of the old buffer 59 | // and close the old buffer. 60 | func (o *offsetReader) CloseAndCopy(offset int64) (*offsetReader, error) { 61 | if err := o.Close(); err != nil { 62 | return nil, err 63 | } 64 | return newOffsetReader(o.buf, offset) 65 | } 66 | -------------------------------------------------------------------------------- /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 | // NoBody is an empty reader that will trigger the Go HTTP client to not include 20 | // and body in the HTTP request. 21 | var NoBody = noBody{} 22 | 23 | // ResetBody rewinds the request body back to its starting position, and 24 | // sets the HTTP Request body reference. When the body is read prior 25 | // to being sent in the HTTP request it will need to be rewound. 26 | // 27 | // ResetBody will automatically be called by the SDK's build handler, but if 28 | // the request is being used directly ResetBody must be called before the request 29 | // is Sent. SetStringBody, SetBufferBody, and SetReaderBody will automatically 30 | // call ResetBody. 31 | func (r *Request) ResetBody() { 32 | body, err := r.getNextRequestBody() 33 | if err != nil { 34 | r.Error = err 35 | return 36 | } 37 | 38 | r.HTTPRequest.Body = body 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/request/request_1_8.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package request 4 | 5 | import ( 6 | "net/http" 7 | 8 | "github.com/aws/aws-sdk-go/aws/awserr" 9 | ) 10 | 11 | // NoBody is a http.NoBody reader instructing Go HTTP client to not include 12 | // and body in the HTTP request. 13 | var NoBody = http.NoBody 14 | 15 | // ResetBody rewinds the request body back to its starting position, and 16 | // sets the HTTP Request body reference. When the body is read prior 17 | // to being sent in the HTTP request it will need to be rewound. 18 | // 19 | // ResetBody will automatically be called by the SDK's build handler, but if 20 | // the request is being used directly ResetBody must be called before the request 21 | // is Sent. SetStringBody, SetBufferBody, and SetReaderBody will automatically 22 | // call ResetBody. 23 | // 24 | // Will also set the Go 1.8's http.Request.GetBody member to allow retrying 25 | // PUT/POST redirects. 26 | func (r *Request) ResetBody() { 27 | body, err := r.getNextRequestBody() 28 | if err != nil { 29 | r.Error = awserr.New(ErrCodeSerialization, 30 | "failed to reset request body", err) 31 | return 32 | } 33 | 34 | r.HTTPRequest.Body = body 35 | r.HTTPRequest.GetBody = r.getNextRequestBody 36 | } 37 | -------------------------------------------------------------------------------- /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/timeout_read_closer.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "io" 5 | "time" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | ) 9 | 10 | var timeoutErr = awserr.New( 11 | ErrCodeResponseTimeout, 12 | "read on body has reached the timeout limit", 13 | nil, 14 | ) 15 | 16 | type readResult struct { 17 | n int 18 | err error 19 | } 20 | 21 | // timeoutReadCloser will handle body reads that take too long. 22 | // We will return a ErrReadTimeout error if a timeout occurs. 23 | type timeoutReadCloser struct { 24 | reader io.ReadCloser 25 | duration time.Duration 26 | } 27 | 28 | // Read will spin off a goroutine to call the reader's Read method. We will 29 | // select on the timer's channel or the read's channel. Whoever completes first 30 | // will be returned. 31 | func (r *timeoutReadCloser) Read(b []byte) (int, error) { 32 | timer := time.NewTimer(r.duration) 33 | c := make(chan readResult, 1) 34 | 35 | go func() { 36 | n, err := r.reader.Read(b) 37 | timer.Stop() 38 | c <- readResult{n: n, err: err} 39 | }() 40 | 41 | select { 42 | case data := <-c: 43 | return data.n, data.err 44 | case <-timer.C: 45 | return 0, timeoutErr 46 | } 47 | } 48 | 49 | func (r *timeoutReadCloser) Close() error { 50 | return r.reader.Close() 51 | } 52 | 53 | const ( 54 | // HandlerResponseTimeout is what we use to signify the name of the 55 | // response timeout handler. 56 | HandlerResponseTimeout = "ResponseTimeoutHandler" 57 | ) 58 | 59 | // adaptToResponseTimeoutError is a handler that will replace any top level error 60 | // to a ErrCodeResponseTimeout, if its child is that. 61 | func adaptToResponseTimeoutError(req *Request) { 62 | if err, ok := req.Error.(awserr.Error); ok { 63 | aerr, ok := err.OrigErr().(awserr.Error) 64 | if ok && aerr.Code() == ErrCodeResponseTimeout { 65 | req.Error = aerr 66 | } 67 | } 68 | } 69 | 70 | // WithResponseReadTimeout is a request option that will wrap the body in a timeout read closer. 71 | // This will allow for per read timeouts. If a timeout occurred, we will return the 72 | // ErrCodeResponseTimeout. 73 | // 74 | // svc.PutObjectWithContext(ctx, params, request.WithTimeoutReadCloser(30 * time.Second) 75 | func WithResponseReadTimeout(duration time.Duration) Option { 76 | return func(r *Request) { 77 | 78 | var timeoutHandler = NamedHandler{ 79 | HandlerResponseTimeout, 80 | func(req *Request) { 81 | req.HTTPResponse.Body = &timeoutReadCloser{ 82 | reader: req.HTTPResponse.Body, 83 | duration: duration, 84 | } 85 | }} 86 | 87 | // remove the handler so we are not stomping over any new durations. 88 | r.Handlers.Send.RemoveByName(HandlerResponseTimeout) 89 | r.Handlers.Send.PushBackNamed(timeoutHandler) 90 | 91 | r.Handlers.Unmarshal.PushBack(adaptToResponseTimeoutError) 92 | r.Handlers.UnmarshalError.PushBack(adaptToResponseTimeoutError) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/session/cabundle_transport.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package session 4 | 5 | import ( 6 | "net" 7 | "net/http" 8 | "time" 9 | ) 10 | 11 | // Transport that should be used when a custom CA bundle is specified with the 12 | // SDK. 13 | func getCABundleTransport() *http.Transport { 14 | return &http.Transport{ 15 | Proxy: http.ProxyFromEnvironment, 16 | DialContext: (&net.Dialer{ 17 | Timeout: 30 * time.Second, 18 | KeepAlive: 30 * time.Second, 19 | DualStack: true, 20 | }).DialContext, 21 | MaxIdleConns: 100, 22 | IdleConnTimeout: 90 * time.Second, 23 | TLSHandshakeTimeout: 10 * time.Second, 24 | ExpectContinueTimeout: 1 * time.Second, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/session/cabundle_transport_1_5.go: -------------------------------------------------------------------------------- 1 | // +build !go1.6,go1.5 2 | 3 | package session 4 | 5 | import ( 6 | "net" 7 | "net/http" 8 | "time" 9 | ) 10 | 11 | // Transport that should be used when a custom CA bundle is specified with the 12 | // SDK. 13 | func getCABundleTransport() *http.Transport { 14 | return &http.Transport{ 15 | Proxy: http.ProxyFromEnvironment, 16 | Dial: (&net.Dialer{ 17 | Timeout: 30 * time.Second, 18 | KeepAlive: 30 * time.Second, 19 | }).Dial, 20 | TLSHandshakeTimeout: 10 * time.Second, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/session/cabundle_transport_1_6.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7,go1.6 2 | 3 | package session 4 | 5 | import ( 6 | "net" 7 | "net/http" 8 | "time" 9 | ) 10 | 11 | // Transport that should be used when a custom CA bundle is specified with the 12 | // SDK. 13 | func getCABundleTransport() *http.Transport { 14 | return &http.Transport{ 15 | Proxy: http.ProxyFromEnvironment, 16 | Dial: (&net.Dialer{ 17 | Timeout: 30 * time.Second, 18 | KeepAlive: 30 * time.Second, 19 | }).Dial, 20 | TLSHandshakeTimeout: 10 * time.Second, 21 | ExpectContinueTimeout: 1 * time.Second, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /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/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/url.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package aws 4 | 5 | import "net/url" 6 | 7 | // URLHostname will extract the Hostname without port from the URL value. 8 | // 9 | // Wrapper of net/url#URL.Hostname for backwards Go version compatibility. 10 | func URLHostname(url *url.URL) string { 11 | return url.Hostname() 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/aws/url_1_7.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package aws 4 | 5 | import ( 6 | "net/url" 7 | "strings" 8 | ) 9 | 10 | // URLHostname will extract the Hostname without port from the URL value. 11 | // 12 | // Copy of Go 1.8's net/url#URL.Hostname functionality. 13 | func URLHostname(url *url.URL) string { 14 | return stripPort(url.Host) 15 | 16 | } 17 | 18 | // stripPort is copy of Go 1.8 url#URL.Hostname functionality. 19 | // https://golang.org/src/net/url/url.go 20 | func stripPort(hostport string) string { 21 | colon := strings.IndexByte(hostport, ':') 22 | if colon == -1 { 23 | return hostport 24 | } 25 | if i := strings.IndexByte(hostport, ']'); i != -1 { 26 | return strings.TrimPrefix(hostport[:i], "[") 27 | } 28 | return hostport[:colon] 29 | } 30 | -------------------------------------------------------------------------------- /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.25.14" 9 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/ast.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | // ASTKind represents different states in the parse table 4 | // and the type of AST that is being constructed 5 | type ASTKind int 6 | 7 | // ASTKind* is used in the parse table to transition between 8 | // the different states 9 | const ( 10 | ASTKindNone = ASTKind(iota) 11 | ASTKindStart 12 | ASTKindExpr 13 | ASTKindEqualExpr 14 | ASTKindStatement 15 | ASTKindSkipStatement 16 | ASTKindExprStatement 17 | ASTKindSectionStatement 18 | ASTKindNestedSectionStatement 19 | ASTKindCompletedNestedSectionStatement 20 | ASTKindCommentStatement 21 | ASTKindCompletedSectionStatement 22 | ) 23 | 24 | func (k ASTKind) String() string { 25 | switch k { 26 | case ASTKindNone: 27 | return "none" 28 | case ASTKindStart: 29 | return "start" 30 | case ASTKindExpr: 31 | return "expr" 32 | case ASTKindStatement: 33 | return "stmt" 34 | case ASTKindSectionStatement: 35 | return "section_stmt" 36 | case ASTKindExprStatement: 37 | return "expr_stmt" 38 | case ASTKindCommentStatement: 39 | return "comment" 40 | case ASTKindNestedSectionStatement: 41 | return "nested_section_stmt" 42 | case ASTKindCompletedSectionStatement: 43 | return "completed_stmt" 44 | case ASTKindSkipStatement: 45 | return "skip" 46 | default: 47 | return "" 48 | } 49 | } 50 | 51 | // AST interface allows us to determine what kind of node we 52 | // are on and casting may not need to be necessary. 53 | // 54 | // The root is always the first node in Children 55 | type AST struct { 56 | Kind ASTKind 57 | Root Token 58 | RootToken bool 59 | Children []AST 60 | } 61 | 62 | func newAST(kind ASTKind, root AST, children ...AST) AST { 63 | return AST{ 64 | Kind: kind, 65 | Children: append([]AST{root}, children...), 66 | } 67 | } 68 | 69 | func newASTWithRootToken(kind ASTKind, root Token, children ...AST) AST { 70 | return AST{ 71 | Kind: kind, 72 | Root: root, 73 | RootToken: true, 74 | Children: children, 75 | } 76 | } 77 | 78 | // AppendChild will append to the list of children an AST has. 79 | func (a *AST) AppendChild(child AST) { 80 | a.Children = append(a.Children, child) 81 | } 82 | 83 | // GetRoot will return the root AST which can be the first entry 84 | // in the children list or a token. 85 | func (a *AST) GetRoot() AST { 86 | if a.RootToken { 87 | return *a 88 | } 89 | 90 | if len(a.Children) == 0 { 91 | return AST{} 92 | } 93 | 94 | return a.Children[0] 95 | } 96 | 97 | // GetChildren will return the current AST's list of children 98 | func (a *AST) GetChildren() []AST { 99 | if len(a.Children) == 0 { 100 | return []AST{} 101 | } 102 | 103 | if a.RootToken { 104 | return a.Children 105 | } 106 | 107 | return a.Children[1:] 108 | } 109 | 110 | // SetChildren will set and override all children of the AST. 111 | func (a *AST) SetChildren(children []AST) { 112 | if a.RootToken { 113 | a.Children = children 114 | } else { 115 | a.Children = append(a.Children[:1], children...) 116 | } 117 | } 118 | 119 | // Start is used to indicate the starting state of the parse table. 120 | var Start = newAST(ASTKindStart, AST{}) 121 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/comma_token.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | var commaRunes = []rune(",") 4 | 5 | func isComma(b rune) bool { 6 | return b == ',' 7 | } 8 | 9 | func newCommaToken() Token { 10 | return newToken(TokenComma, commaRunes, NoneType) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/comment_token.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | // isComment will return whether or not the next byte(s) is a 4 | // comment. 5 | func isComment(b []rune) bool { 6 | if len(b) == 0 { 7 | return false 8 | } 9 | 10 | switch b[0] { 11 | case ';': 12 | return true 13 | case '#': 14 | return true 15 | } 16 | 17 | return false 18 | } 19 | 20 | // newCommentToken will create a comment token and 21 | // return how many bytes were read. 22 | func newCommentToken(b []rune) (Token, int, error) { 23 | i := 0 24 | for ; i < len(b); i++ { 25 | if b[i] == '\n' { 26 | break 27 | } 28 | 29 | if len(b)-i > 2 && b[i] == '\r' && b[i+1] == '\n' { 30 | break 31 | } 32 | } 33 | 34 | return newToken(TokenComment, b[:i], NoneType), i, nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/doc.go: -------------------------------------------------------------------------------- 1 | // Package ini is an LL(1) parser for configuration files. 2 | // 3 | // Example: 4 | // sections, err := ini.OpenFile("/path/to/file") 5 | // if err != nil { 6 | // panic(err) 7 | // } 8 | // 9 | // profile := "foo" 10 | // section, ok := sections.GetSection(profile) 11 | // if !ok { 12 | // fmt.Printf("section %q could not be found", profile) 13 | // } 14 | // 15 | // Below is the BNF that describes this parser 16 | // Grammar: 17 | // stmt -> value stmt' 18 | // stmt' -> epsilon | op stmt 19 | // value -> number | string | boolean | quoted_string 20 | // 21 | // section -> [ section' 22 | // section' -> value section_close 23 | // section_close -> ] 24 | // 25 | // SkipState will skip (NL WS)+ 26 | // 27 | // comment -> # comment' | ; comment' 28 | // comment' -> epsilon | value 29 | package ini 30 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/empty_token.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | // emptyToken is used to satisfy the Token interface 4 | var emptyToken = newToken(TokenNone, []rune{}, NoneType) 5 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/expression.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | // newExpression will return an expression AST. 4 | // Expr represents an expression 5 | // 6 | // grammar: 7 | // expr -> string | number 8 | func newExpression(tok Token) AST { 9 | return newASTWithRootToken(ASTKindExpr, tok) 10 | } 11 | 12 | func newEqualExpr(left AST, tok Token) AST { 13 | return newASTWithRootToken(ASTKindEqualExpr, tok, left) 14 | } 15 | 16 | // EqualExprKey will return a LHS value in the equal expr 17 | func EqualExprKey(ast AST) string { 18 | children := ast.GetChildren() 19 | if len(children) == 0 || ast.Kind != ASTKindEqualExpr { 20 | return "" 21 | } 22 | 23 | return string(children[0].Root.Raw()) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package ini 4 | 5 | import ( 6 | "bytes" 7 | ) 8 | 9 | func Fuzz(data []byte) int { 10 | b := bytes.NewReader(data) 11 | 12 | if _, err := Parse(b); err != nil { 13 | return 0 14 | } 15 | 16 | return 1 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/ini.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | import ( 4 | "io" 5 | "os" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | ) 9 | 10 | // OpenFile takes a path to a given file, and will open and parse 11 | // that file. 12 | func OpenFile(path string) (Sections, error) { 13 | f, err := os.Open(path) 14 | if err != nil { 15 | return Sections{}, awserr.New(ErrCodeUnableToReadFile, "unable to open file", err) 16 | } 17 | defer f.Close() 18 | 19 | return Parse(f) 20 | } 21 | 22 | // Parse will parse the given file using the shared config 23 | // visitor. 24 | func Parse(f io.Reader) (Sections, error) { 25 | tree, err := ParseAST(f) 26 | if err != nil { 27 | return Sections{}, err 28 | } 29 | 30 | v := NewDefaultVisitor() 31 | if err = Walk(tree, v); err != nil { 32 | return Sections{}, err 33 | } 34 | 35 | return v.Sections, nil 36 | } 37 | 38 | // ParseBytes will parse the given bytes and return the parsed sections. 39 | func ParseBytes(b []byte) (Sections, error) { 40 | tree, err := ParseASTBytes(b) 41 | if err != nil { 42 | return Sections{}, err 43 | } 44 | 45 | v := NewDefaultVisitor() 46 | if err = Walk(tree, v); err != nil { 47 | return Sections{}, err 48 | } 49 | 50 | return v.Sections, nil 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/newline_token.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | func isNewline(b []rune) bool { 4 | if len(b) == 0 { 5 | return false 6 | } 7 | 8 | if b[0] == '\n' { 9 | return true 10 | } 11 | 12 | if len(b) < 2 { 13 | return false 14 | } 15 | 16 | return b[0] == '\r' && b[1] == '\n' 17 | } 18 | 19 | func newNewlineToken(b []rune) (Token, int, error) { 20 | i := 1 21 | if b[0] == '\r' && isNewline(b[1:]) { 22 | i++ 23 | } 24 | 25 | if !isNewline([]rune(b[:i])) { 26 | return emptyToken, 0, NewParseError("invalid new line token") 27 | } 28 | 29 | return newToken(TokenNL, b[:i], NoneType), i, nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/number_helper.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "strconv" 7 | ) 8 | 9 | const ( 10 | none = numberFormat(iota) 11 | binary 12 | octal 13 | decimal 14 | hex 15 | exponent 16 | ) 17 | 18 | type numberFormat int 19 | 20 | // numberHelper is used to dictate what format a number is in 21 | // and what to do for negative values. Since -1e-4 is a valid 22 | // number, we cannot just simply check for duplicate negatives. 23 | type numberHelper struct { 24 | numberFormat numberFormat 25 | 26 | negative bool 27 | negativeExponent bool 28 | } 29 | 30 | func (b numberHelper) Exists() bool { 31 | return b.numberFormat != none 32 | } 33 | 34 | func (b numberHelper) IsNegative() bool { 35 | return b.negative || b.negativeExponent 36 | } 37 | 38 | func (b *numberHelper) Determine(c rune) error { 39 | if b.Exists() { 40 | return NewParseError(fmt.Sprintf("multiple number formats: 0%v", string(c))) 41 | } 42 | 43 | switch c { 44 | case 'b': 45 | b.numberFormat = binary 46 | case 'o': 47 | b.numberFormat = octal 48 | case 'x': 49 | b.numberFormat = hex 50 | case 'e', 'E': 51 | b.numberFormat = exponent 52 | case '-': 53 | if b.numberFormat != exponent { 54 | b.negative = true 55 | } else { 56 | b.negativeExponent = true 57 | } 58 | case '.': 59 | b.numberFormat = decimal 60 | default: 61 | return NewParseError(fmt.Sprintf("invalid number character: %v", string(c))) 62 | } 63 | 64 | return nil 65 | } 66 | 67 | func (b numberHelper) CorrectByte(c rune) bool { 68 | switch { 69 | case b.numberFormat == binary: 70 | if !isBinaryByte(c) { 71 | return false 72 | } 73 | case b.numberFormat == octal: 74 | if !isOctalByte(c) { 75 | return false 76 | } 77 | case b.numberFormat == hex: 78 | if !isHexByte(c) { 79 | return false 80 | } 81 | case b.numberFormat == decimal: 82 | if !isDigit(c) { 83 | return false 84 | } 85 | case b.numberFormat == exponent: 86 | if !isDigit(c) { 87 | return false 88 | } 89 | case b.negativeExponent: 90 | if !isDigit(c) { 91 | return false 92 | } 93 | case b.negative: 94 | if !isDigit(c) { 95 | return false 96 | } 97 | default: 98 | if !isDigit(c) { 99 | return false 100 | } 101 | } 102 | 103 | return true 104 | } 105 | 106 | func (b numberHelper) Base() int { 107 | switch b.numberFormat { 108 | case binary: 109 | return 2 110 | case octal: 111 | return 8 112 | case hex: 113 | return 16 114 | default: 115 | return 10 116 | } 117 | } 118 | 119 | func (b numberHelper) String() string { 120 | buf := bytes.Buffer{} 121 | i := 0 122 | 123 | switch b.numberFormat { 124 | case binary: 125 | i++ 126 | buf.WriteString(strconv.Itoa(i) + ": binary format\n") 127 | case octal: 128 | i++ 129 | buf.WriteString(strconv.Itoa(i) + ": octal format\n") 130 | case hex: 131 | i++ 132 | buf.WriteString(strconv.Itoa(i) + ": hex format\n") 133 | case exponent: 134 | i++ 135 | buf.WriteString(strconv.Itoa(i) + ": exponent format\n") 136 | default: 137 | i++ 138 | buf.WriteString(strconv.Itoa(i) + ": integer format\n") 139 | } 140 | 141 | if b.negative { 142 | i++ 143 | buf.WriteString(strconv.Itoa(i) + ": negative format\n") 144 | } 145 | 146 | if b.negativeExponent { 147 | i++ 148 | buf.WriteString(strconv.Itoa(i) + ": negative exponent format\n") 149 | } 150 | 151 | return buf.String() 152 | } 153 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/op_tokens.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var ( 8 | equalOp = []rune("=") 9 | equalColonOp = []rune(":") 10 | ) 11 | 12 | func isOp(b []rune) bool { 13 | if len(b) == 0 { 14 | return false 15 | } 16 | 17 | switch b[0] { 18 | case '=': 19 | return true 20 | case ':': 21 | return true 22 | default: 23 | return false 24 | } 25 | } 26 | 27 | func newOpToken(b []rune) (Token, int, error) { 28 | tok := Token{} 29 | 30 | switch b[0] { 31 | case '=': 32 | tok = newToken(TokenOp, equalOp, NoneType) 33 | case ':': 34 | tok = newToken(TokenOp, equalColonOp, NoneType) 35 | default: 36 | return tok, 0, NewParseError(fmt.Sprintf("unexpected op type, %v", b[0])) 37 | } 38 | return tok, 1, nil 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/parse_error.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | import "fmt" 4 | 5 | const ( 6 | // ErrCodeParseError is returned when a parsing error 7 | // has occurred. 8 | ErrCodeParseError = "INIParseError" 9 | ) 10 | 11 | // ParseError is an error which is returned during any part of 12 | // the parsing process. 13 | type ParseError struct { 14 | msg string 15 | } 16 | 17 | // NewParseError will return a new ParseError where message 18 | // is the description of the error. 19 | func NewParseError(message string) *ParseError { 20 | return &ParseError{ 21 | msg: message, 22 | } 23 | } 24 | 25 | // Code will return the ErrCodeParseError 26 | func (err *ParseError) Code() string { 27 | return ErrCodeParseError 28 | } 29 | 30 | // Message returns the error's message 31 | func (err *ParseError) Message() string { 32 | return err.msg 33 | } 34 | 35 | // OrigError return nothing since there will never be any 36 | // original error. 37 | func (err *ParseError) OrigError() error { 38 | return nil 39 | } 40 | 41 | func (err *ParseError) Error() string { 42 | return fmt.Sprintf("%s: %s", err.Code(), err.Message()) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/parse_stack.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | ) 7 | 8 | // ParseStack is a stack that contains a container, the stack portion, 9 | // and the list which is the list of ASTs that have been successfully 10 | // parsed. 11 | type ParseStack struct { 12 | top int 13 | container []AST 14 | list []AST 15 | index int 16 | } 17 | 18 | func newParseStack(sizeContainer, sizeList int) ParseStack { 19 | return ParseStack{ 20 | container: make([]AST, sizeContainer), 21 | list: make([]AST, sizeList), 22 | } 23 | } 24 | 25 | // Pop will return and truncate the last container element. 26 | func (s *ParseStack) Pop() AST { 27 | s.top-- 28 | return s.container[s.top] 29 | } 30 | 31 | // Push will add the new AST to the container 32 | func (s *ParseStack) Push(ast AST) { 33 | s.container[s.top] = ast 34 | s.top++ 35 | } 36 | 37 | // MarkComplete will append the AST to the list of completed statements 38 | func (s *ParseStack) MarkComplete(ast AST) { 39 | s.list[s.index] = ast 40 | s.index++ 41 | } 42 | 43 | // List will return the completed statements 44 | func (s ParseStack) List() []AST { 45 | return s.list[:s.index] 46 | } 47 | 48 | // Len will return the length of the container 49 | func (s *ParseStack) Len() int { 50 | return s.top 51 | } 52 | 53 | func (s ParseStack) String() string { 54 | buf := bytes.Buffer{} 55 | for i, node := range s.list { 56 | buf.WriteString(fmt.Sprintf("%d: %v\n", i+1, node)) 57 | } 58 | 59 | return buf.String() 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/sep_tokens.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var ( 8 | emptyRunes = []rune{} 9 | ) 10 | 11 | func isSep(b []rune) bool { 12 | if len(b) == 0 { 13 | return false 14 | } 15 | 16 | switch b[0] { 17 | case '[', ']': 18 | return true 19 | default: 20 | return false 21 | } 22 | } 23 | 24 | var ( 25 | openBrace = []rune("[") 26 | closeBrace = []rune("]") 27 | ) 28 | 29 | func newSepToken(b []rune) (Token, int, error) { 30 | tok := Token{} 31 | 32 | switch b[0] { 33 | case '[': 34 | tok = newToken(TokenSep, openBrace, NoneType) 35 | case ']': 36 | tok = newToken(TokenSep, closeBrace, NoneType) 37 | default: 38 | return tok, 0, NewParseError(fmt.Sprintf("unexpected sep type, %v", b[0])) 39 | } 40 | return tok, 1, nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/skipper.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | // skipper is used to skip certain blocks of an ini file. 4 | // Currently skipper is used to skip nested blocks of ini 5 | // files. See example below 6 | // 7 | // [ foo ] 8 | // nested = ; this section will be skipped 9 | // a=b 10 | // c=d 11 | // bar=baz ; this will be included 12 | type skipper struct { 13 | shouldSkip bool 14 | TokenSet bool 15 | prevTok Token 16 | } 17 | 18 | func newSkipper() skipper { 19 | return skipper{ 20 | prevTok: emptyToken, 21 | } 22 | } 23 | 24 | func (s *skipper) ShouldSkip(tok Token) bool { 25 | // should skip state will be modified only if previous token was new line (NL); 26 | // and the current token is not WhiteSpace (WS). 27 | if s.shouldSkip && 28 | s.prevTok.Type() == TokenNL && 29 | tok.Type() != TokenWS { 30 | s.Continue() 31 | return false 32 | } 33 | s.prevTok = tok 34 | return s.shouldSkip 35 | } 36 | 37 | func (s *skipper) Skip() { 38 | s.shouldSkip = true 39 | } 40 | 41 | func (s *skipper) Continue() { 42 | s.shouldSkip = false 43 | // empty token is assigned as we return to default state, when should skip is false 44 | s.prevTok = emptyToken 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/statement.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | // Statement is an empty AST mostly used for transitioning states. 4 | func newStatement() AST { 5 | return newAST(ASTKindStatement, AST{}) 6 | } 7 | 8 | // SectionStatement represents a section AST 9 | func newSectionStatement(tok Token) AST { 10 | return newASTWithRootToken(ASTKindSectionStatement, tok) 11 | } 12 | 13 | // ExprStatement represents a completed expression AST 14 | func newExprStatement(ast AST) AST { 15 | return newAST(ASTKindExprStatement, ast) 16 | } 17 | 18 | // CommentStatement represents a comment in the ini definition. 19 | // 20 | // grammar: 21 | // comment -> #comment' | ;comment' 22 | // comment' -> epsilon | value 23 | func newCommentStatement(tok Token) AST { 24 | return newAST(ASTKindCommentStatement, newExpression(tok)) 25 | } 26 | 27 | // CompletedSectionStatement represents a completed section 28 | func newCompletedSectionStatement(ast AST) AST { 29 | return newAST(ASTKindCompletedSectionStatement, ast) 30 | } 31 | 32 | // SkipStatement is used to skip whole statements 33 | func newSkipStatement(ast AST) AST { 34 | return newAST(ASTKindSkipStatement, ast) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/walker.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | // Walk will traverse the AST using the v, the Visitor. 4 | func Walk(tree []AST, v Visitor) error { 5 | for _, node := range tree { 6 | switch node.Kind { 7 | case ASTKindExpr, 8 | ASTKindExprStatement: 9 | 10 | if err := v.VisitExpr(node); err != nil { 11 | return err 12 | } 13 | case ASTKindStatement, 14 | ASTKindCompletedSectionStatement, 15 | ASTKindNestedSectionStatement, 16 | ASTKindCompletedNestedSectionStatement: 17 | 18 | if err := v.VisitStatement(node); err != nil { 19 | return err 20 | } 21 | } 22 | } 23 | 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/ini/ws_token.go: -------------------------------------------------------------------------------- 1 | package ini 2 | 3 | import ( 4 | "unicode" 5 | ) 6 | 7 | // isWhitespace will return whether or not the character is 8 | // a whitespace character. 9 | // 10 | // Whitespace is defined as a space or tab. 11 | func isWhitespace(c rune) bool { 12 | return unicode.IsSpace(c) && c != '\n' && c != '\r' 13 | } 14 | 15 | func newWSToken(b []rune) (Token, int, error) { 16 | i := 0 17 | for ; i < len(b); i++ { 18 | if !isWhitespace(b[i]) { 19 | break 20 | } 21 | } 22 | 23 | return newToken(TokenWS, b[:i], NoneType), i, nil 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkio/byte.go: -------------------------------------------------------------------------------- 1 | package sdkio 2 | 3 | const ( 4 | // Byte is 8 bits 5 | Byte int64 = 1 6 | // KibiByte (KiB) is 1024 Bytes 7 | KibiByte = Byte * 1024 8 | // MebiByte (MiB) is 1024 KiB 9 | MebiByte = KibiByte * 1024 10 | // GibiByte (GiB) is 1024 MiB 11 | GibiByte = MebiByte * 1024 12 | ) 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkio/io_go1.6.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package sdkio 4 | 5 | // Copy of Go 1.7 io package's Seeker constants. 6 | const ( 7 | SeekStart = 0 // seek relative to the origin of the file 8 | SeekCurrent = 1 // seek relative to the current offset 9 | SeekEnd = 2 // seek relative to the end 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkio/io_go1.7.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package sdkio 4 | 5 | import "io" 6 | 7 | // Alias for Go 1.7 io package Seeker constants 8 | const ( 9 | SeekStart = io.SeekStart // seek relative to the origin of the file 10 | SeekCurrent = io.SeekCurrent // seek relative to the current offset 11 | SeekEnd = io.SeekEnd // seek relative to the end 12 | ) 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package sdkmath 4 | 5 | import "math" 6 | 7 | // Round returns the nearest integer, rounding half away from zero. 8 | // 9 | // Special cases are: 10 | // Round(±0) = ±0 11 | // Round(±Inf) = ±Inf 12 | // Round(NaN) = NaN 13 | func Round(x float64) float64 { 14 | return math.Round(x) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor_go1.9.go: -------------------------------------------------------------------------------- 1 | // +build !go1.10 2 | 3 | package sdkmath 4 | 5 | import "math" 6 | 7 | // Copied from the Go standard library's (Go 1.12) math/floor.go for use in 8 | // Go version prior to Go 1.10. 9 | const ( 10 | uvone = 0x3FF0000000000000 11 | mask = 0x7FF 12 | shift = 64 - 11 - 1 13 | bias = 1023 14 | signMask = 1 << 63 15 | fracMask = 1<= 0.5 { 33 | // return t + Copysign(1, x) 34 | // } 35 | // return t 36 | // } 37 | bits := math.Float64bits(x) 38 | e := uint(bits>>shift) & mask 39 | if e < bias { 40 | // Round abs(x) < 1 including denormals. 41 | bits &= signMask // +-0 42 | if e == bias-1 { 43 | bits |= uvone // +-1 44 | } 45 | } else if e < bias+shift { 46 | // Round any abs(x) >= 1 containing a fractional component [0,1). 47 | // 48 | // Numbers with larger exponents are returned unchanged since they 49 | // must be either an integer, infinity, or NaN. 50 | const half = 1 << (shift - 1) 51 | e -= bias 52 | bits += half >> e 53 | bits &^= fracMask >> e 54 | } 55 | return math.Float64frombits(bits) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkrand/locked_source.go: -------------------------------------------------------------------------------- 1 | package sdkrand 2 | 3 | import ( 4 | "math/rand" 5 | "sync" 6 | "time" 7 | ) 8 | 9 | // lockedSource is a thread-safe implementation of rand.Source 10 | type lockedSource struct { 11 | lk sync.Mutex 12 | src rand.Source 13 | } 14 | 15 | func (r *lockedSource) Int63() (n int64) { 16 | r.lk.Lock() 17 | n = r.src.Int63() 18 | r.lk.Unlock() 19 | return 20 | } 21 | 22 | func (r *lockedSource) Seed(seed int64) { 23 | r.lk.Lock() 24 | r.src.Seed(seed) 25 | r.lk.Unlock() 26 | } 27 | 28 | // SeededRand is a new RNG using a thread safe implementation of rand.Source 29 | var SeededRand = rand.New(&lockedSource{src: rand.NewSource(time.Now().UnixNano())}) 30 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkrand/read.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package sdkrand 4 | 5 | import "math/rand" 6 | 7 | // Read provides the stub for math.Rand.Read method support for go version's 8 | // 1.6 and greater. 9 | func Read(r *rand.Rand, p []byte) (int, error) { 10 | return r.Read(p) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkrand/read_1_5.go: -------------------------------------------------------------------------------- 1 | // +build !go1.6 2 | 3 | package sdkrand 4 | 5 | import "math/rand" 6 | 7 | // Read backfills Go 1.6's math.Rand.Reader for Go 1.5 8 | func Read(r *rand.Rand, p []byte) (n int, err error) { 9 | // Copy of Go standard libraries math package's read function not added to 10 | // standard library until Go 1.6. 11 | var pos int8 12 | var val int64 13 | for n = 0; n < len(p); n++ { 14 | if pos == 0 { 15 | val = r.Int63() 16 | pos = 7 17 | } 18 | p[n] = byte(val) 19 | val >>= 8 20 | pos-- 21 | } 22 | 23 | return n, err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/sdkuri/path.go: -------------------------------------------------------------------------------- 1 | package sdkuri 2 | 3 | import ( 4 | "path" 5 | "strings" 6 | ) 7 | 8 | // PathJoin will join the elements of the path delimited by the "/" 9 | // character. Similar to path.Join with the exception the trailing "/" 10 | // character is preserved if present. 11 | func PathJoin(elems ...string) string { 12 | if len(elems) == 0 { 13 | return "" 14 | } 15 | 16 | hasTrailing := strings.HasSuffix(elems[len(elems)-1], "/") 17 | str := path.Join(elems...) 18 | if hasTrailing && str != "/" { 19 | str += "/" 20 | } 21 | 22 | return str 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/shareddefaults/ecs_container.go: -------------------------------------------------------------------------------- 1 | package shareddefaults 2 | 3 | const ( 4 | // ECSCredsProviderEnvVar is an environmental variable key used to 5 | // determine which path needs to be hit. 6 | ECSCredsProviderEnvVar = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI" 7 | ) 8 | 9 | // ECSContainerCredentialsURI is the endpoint to retrieve container 10 | // credentials. This can be overridden to test to ensure the credential process 11 | // is behaving correctly. 12 | var ECSContainerCredentialsURI = "http://169.254.170.2" 13 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/internal/shareddefaults/shared_config.go: -------------------------------------------------------------------------------- 1 | package shareddefaults 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "runtime" 7 | ) 8 | 9 | // SharedCredentialsFilename returns the SDK's default file path 10 | // for the shared credentials file. 11 | // 12 | // Builds the shared config file path based on the OS's platform. 13 | // 14 | // - Linux/Unix: $HOME/.aws/credentials 15 | // - Windows: %USERPROFILE%\.aws\credentials 16 | func SharedCredentialsFilename() string { 17 | return filepath.Join(UserHomeDir(), ".aws", "credentials") 18 | } 19 | 20 | // SharedConfigFilename returns the SDK's default file path for 21 | // the shared config file. 22 | // 23 | // Builds the shared config file path based on the OS's platform. 24 | // 25 | // - Linux/Unix: $HOME/.aws/config 26 | // - Windows: %USERPROFILE%\.aws\config 27 | func SharedConfigFilename() string { 28 | return filepath.Join(UserHomeDir(), ".aws", "config") 29 | } 30 | 31 | // UserHomeDir returns the home directory for the user the process is 32 | // running under. 33 | func UserHomeDir() string { 34 | if runtime.GOOS == "windows" { // Windows 35 | return os.Getenv("USERPROFILE") 36 | } 37 | 38 | // *nix 39 | return os.Getenv("HOME") 40 | } 41 | -------------------------------------------------------------------------------- /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(request.ErrCodeSerialization, 25 | "failed encoding EC2 Query request", err) 26 | } 27 | 28 | if !r.IsPresigned() { 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/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 | 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 ec2query protocol requests 14 | var UnmarshalHandler = request.NamedHandler{Name: "awssdk.ec2query.Unmarshal", Fn: Unmarshal} 15 | 16 | // UnmarshalMetaHandler is a named request handler for unmarshaling ec2query protocol request metadata 17 | var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.ec2query.UnmarshalMeta", Fn: UnmarshalMeta} 18 | 19 | // UnmarshalErrorHandler is a named request handler for unmarshaling ec2query protocol request errors 20 | var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.ec2query.UnmarshalError", Fn: UnmarshalError} 21 | 22 | // Unmarshal unmarshals a response body for the EC2 protocol. 23 | func Unmarshal(r *request.Request) { 24 | defer r.HTTPResponse.Body.Close() 25 | if r.DataFilled() { 26 | decoder := xml.NewDecoder(r.HTTPResponse.Body) 27 | err := xmlutil.UnmarshalXML(r.Data, decoder, "") 28 | if err != nil { 29 | r.Error = awserr.NewRequestFailure( 30 | awserr.New(request.ErrCodeSerialization, 31 | "failed decoding EC2 Query response", err), 32 | r.HTTPResponse.StatusCode, 33 | r.RequestID, 34 | ) 35 | return 36 | } 37 | } 38 | } 39 | 40 | // UnmarshalMeta unmarshals response headers for the EC2 protocol. 41 | func UnmarshalMeta(r *request.Request) { 42 | r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") 43 | if r.RequestID == "" { 44 | // Alternative version of request id in the header 45 | r.RequestID = r.HTTPResponse.Header.Get("X-Amz-Request-Id") 46 | } 47 | } 48 | 49 | type xmlErrorResponse struct { 50 | XMLName xml.Name `xml:"Response"` 51 | Code string `xml:"Errors>Error>Code"` 52 | Message string `xml:"Errors>Error>Message"` 53 | RequestID string `xml:"RequestID"` 54 | } 55 | 56 | // UnmarshalError unmarshals a response error for the EC2 protocol. 57 | func UnmarshalError(r *request.Request) { 58 | defer r.HTTPResponse.Body.Close() 59 | 60 | var respErr xmlErrorResponse 61 | err := xmlutil.UnmarshalXMLError(&respErr, r.HTTPResponse.Body) 62 | if err != nil { 63 | r.Error = awserr.NewRequestFailure( 64 | awserr.New(request.ErrCodeSerialization, 65 | "failed to unmarshal error message", err), 66 | r.HTTPResponse.StatusCode, 67 | r.RequestID, 68 | ) 69 | return 70 | } 71 | 72 | r.Error = awserr.NewRequestFailure( 73 | awserr.New(respErr.Code, respErr.Message, nil), 74 | r.HTTPResponse.StatusCode, 75 | respErr.RequestID, 76 | ) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/host.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/aws/aws-sdk-go/aws/request" 7 | ) 8 | 9 | // ValidateEndpointHostHandler is a request handler that will validate the 10 | // request endpoint's hosts is a valid RFC 3986 host. 11 | var ValidateEndpointHostHandler = request.NamedHandler{ 12 | Name: "awssdk.protocol.ValidateEndpointHostHandler", 13 | Fn: func(r *request.Request) { 14 | err := ValidateEndpointHost(r.Operation.Name, r.HTTPRequest.URL.Host) 15 | if err != nil { 16 | r.Error = err 17 | } 18 | }, 19 | } 20 | 21 | // ValidateEndpointHost validates that the host string passed in is a valid RFC 22 | // 3986 host. Returns error if the host is not valid. 23 | func ValidateEndpointHost(opName, host string) error { 24 | paramErrs := request.ErrInvalidParams{Context: opName} 25 | labels := strings.Split(host, ".") 26 | 27 | for i, label := range labels { 28 | if i == len(labels)-1 && len(label) == 0 { 29 | // Allow trailing dot for FQDN hosts. 30 | continue 31 | } 32 | 33 | if !ValidHostLabel(label) { 34 | paramErrs.Add(request.NewErrParamFormat( 35 | "endpoint host label", "[a-zA-Z0-9-]{1,63}", label)) 36 | } 37 | } 38 | 39 | if len(host) > 255 { 40 | paramErrs.Add(request.NewErrParamMaxLen( 41 | "endpoint host", 255, host, 42 | )) 43 | } 44 | 45 | if paramErrs.Len() > 0 { 46 | return paramErrs 47 | } 48 | return nil 49 | } 50 | 51 | // ValidHostLabel returns if the label is a valid RFC 3986 host label. 52 | func ValidHostLabel(label string) bool { 53 | if l := len(label); l == 0 || l > 63 { 54 | return false 55 | } 56 | for _, r := range label { 57 | switch { 58 | case r >= '0' && r <= '9': 59 | case r >= 'A' && r <= 'Z': 60 | case r >= 'a' && r <= 'z': 61 | case r == '-': 62 | default: 63 | return false 64 | } 65 | } 66 | 67 | return true 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/host_prefix.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/request" 8 | ) 9 | 10 | // HostPrefixHandlerName is the handler name for the host prefix request 11 | // handler. 12 | const HostPrefixHandlerName = "awssdk.endpoint.HostPrefixHandler" 13 | 14 | // NewHostPrefixHandler constructs a build handler 15 | func NewHostPrefixHandler(prefix string, labelsFn func() map[string]string) request.NamedHandler { 16 | builder := HostPrefixBuilder{ 17 | Prefix: prefix, 18 | LabelsFn: labelsFn, 19 | } 20 | 21 | return request.NamedHandler{ 22 | Name: HostPrefixHandlerName, 23 | Fn: builder.Build, 24 | } 25 | } 26 | 27 | // HostPrefixBuilder provides the request handler to expand and prepend 28 | // the host prefix into the operation's request endpoint host. 29 | type HostPrefixBuilder struct { 30 | Prefix string 31 | LabelsFn func() map[string]string 32 | } 33 | 34 | // Build updates the passed in Request with the HostPrefix template expanded. 35 | func (h HostPrefixBuilder) Build(r *request.Request) { 36 | if aws.BoolValue(r.Config.DisableEndpointHostPrefix) { 37 | return 38 | } 39 | 40 | var labels map[string]string 41 | if h.LabelsFn != nil { 42 | labels = h.LabelsFn() 43 | } 44 | 45 | prefix := h.Prefix 46 | for name, value := range labels { 47 | prefix = strings.Replace(prefix, "{"+name+"}", value, -1) 48 | } 49 | 50 | r.HTTPRequest.URL.Host = prefix + r.HTTPRequest.URL.Host 51 | if len(r.HTTPRequest.Host) > 0 { 52 | r.HTTPRequest.Host = prefix + r.HTTPRequest.Host 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /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/jsonvalue.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/json" 6 | "fmt" 7 | "strconv" 8 | 9 | "github.com/aws/aws-sdk-go/aws" 10 | ) 11 | 12 | // EscapeMode is the mode that should be use for escaping a value 13 | type EscapeMode uint 14 | 15 | // The modes for escaping a value before it is marshaled, and unmarshaled. 16 | const ( 17 | NoEscape EscapeMode = iota 18 | Base64Escape 19 | QuotedEscape 20 | ) 21 | 22 | // EncodeJSONValue marshals the value into a JSON string, and optionally base64 23 | // encodes the string before returning it. 24 | // 25 | // Will panic if the escape mode is unknown. 26 | func EncodeJSONValue(v aws.JSONValue, escape EscapeMode) (string, error) { 27 | b, err := json.Marshal(v) 28 | if err != nil { 29 | return "", err 30 | } 31 | 32 | switch escape { 33 | case NoEscape: 34 | return string(b), nil 35 | case Base64Escape: 36 | return base64.StdEncoding.EncodeToString(b), nil 37 | case QuotedEscape: 38 | return strconv.Quote(string(b)), nil 39 | } 40 | 41 | panic(fmt.Sprintf("EncodeJSONValue called with unknown EscapeMode, %v", escape)) 42 | } 43 | 44 | // DecodeJSONValue will attempt to decode the string input as a JSONValue. 45 | // Optionally decoding base64 the value first before JSON unmarshaling. 46 | // 47 | // Will panic if the escape mode is unknown. 48 | func DecodeJSONValue(v string, escape EscapeMode) (aws.JSONValue, error) { 49 | var b []byte 50 | var err error 51 | 52 | switch escape { 53 | case NoEscape: 54 | b = []byte(v) 55 | case Base64Escape: 56 | b, err = base64.StdEncoding.DecodeString(v) 57 | case QuotedEscape: 58 | var u string 59 | u, err = strconv.Unquote(v) 60 | b = []byte(u) 61 | default: 62 | panic(fmt.Sprintf("DecodeJSONValue called with unknown EscapeMode, %v", escape)) 63 | } 64 | 65 | if err != nil { 66 | return nil, err 67 | } 68 | 69 | m := aws.JSONValue{} 70 | err = json.Unmarshal(b, &m) 71 | if err != nil { 72 | return nil, err 73 | } 74 | 75 | return m, nil 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/payload.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | "net/http" 7 | 8 | "github.com/aws/aws-sdk-go/aws" 9 | "github.com/aws/aws-sdk-go/aws/client/metadata" 10 | "github.com/aws/aws-sdk-go/aws/request" 11 | ) 12 | 13 | // PayloadUnmarshaler provides the interface for unmarshaling a payload's 14 | // reader into a SDK shape. 15 | type PayloadUnmarshaler interface { 16 | UnmarshalPayload(io.Reader, interface{}) error 17 | } 18 | 19 | // HandlerPayloadUnmarshal implements the PayloadUnmarshaler from a 20 | // HandlerList. This provides the support for unmarshaling a payload reader to 21 | // a shape without needing a SDK request first. 22 | type HandlerPayloadUnmarshal struct { 23 | Unmarshalers request.HandlerList 24 | } 25 | 26 | // UnmarshalPayload unmarshals the io.Reader payload into the SDK shape using 27 | // the Unmarshalers HandlerList provided. Returns an error if unable 28 | // unmarshaling fails. 29 | func (h HandlerPayloadUnmarshal) UnmarshalPayload(r io.Reader, v interface{}) error { 30 | req := &request.Request{ 31 | HTTPRequest: &http.Request{}, 32 | HTTPResponse: &http.Response{ 33 | StatusCode: 200, 34 | Header: http.Header{}, 35 | Body: ioutil.NopCloser(r), 36 | }, 37 | Data: v, 38 | } 39 | 40 | h.Unmarshalers.Run(req) 41 | 42 | return req.Error 43 | } 44 | 45 | // PayloadMarshaler provides the interface for marshaling a SDK shape into and 46 | // io.Writer. 47 | type PayloadMarshaler interface { 48 | MarshalPayload(io.Writer, interface{}) error 49 | } 50 | 51 | // HandlerPayloadMarshal implements the PayloadMarshaler from a HandlerList. 52 | // This provides support for marshaling a SDK shape into an io.Writer without 53 | // needing a SDK request first. 54 | type HandlerPayloadMarshal struct { 55 | Marshalers request.HandlerList 56 | } 57 | 58 | // MarshalPayload marshals the SDK shape into the io.Writer using the 59 | // Marshalers HandlerList provided. Returns an error if unable if marshal 60 | // fails. 61 | func (h HandlerPayloadMarshal) MarshalPayload(w io.Writer, v interface{}) error { 62 | req := request.New( 63 | aws.Config{}, 64 | metadata.ClientInfo{}, 65 | request.Handlers{}, 66 | nil, 67 | &request.Operation{HTTPMethod: "GET"}, 68 | v, 69 | nil, 70 | ) 71 | 72 | h.Marshalers.Run(req) 73 | 74 | if req.Error != nil { 75 | return req.Error 76 | } 77 | 78 | io.Copy(w, req.GetBody()) 79 | 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /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(request.ErrCodeSerialization, "failed encoding Query request", err) 25 | return 26 | } 27 | 28 | if !r.IsPresigned() { 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.NewRequestFailure( 27 | awserr.New(request.ErrCodeSerialization, "failed decoding Query response", err), 28 | r.HTTPResponse.StatusCode, 29 | r.RequestID, 30 | ) 31 | return 32 | } 33 | } 34 | } 35 | 36 | // UnmarshalMeta unmarshals header response values for an AWS Query service. 37 | func UnmarshalMeta(r *request.Request) { 38 | r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/private/protocol/query/unmarshal_error.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "encoding/xml" 5 | "fmt" 6 | 7 | "github.com/aws/aws-sdk-go/aws/awserr" 8 | "github.com/aws/aws-sdk-go/aws/request" 9 | "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" 10 | ) 11 | 12 | // UnmarshalErrorHandler is a name request handler to unmarshal request errors 13 | var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.query.UnmarshalError", Fn: UnmarshalError} 14 | 15 | type xmlErrorResponse struct { 16 | Code string `xml:"Error>Code"` 17 | Message string `xml:"Error>Message"` 18 | RequestID string `xml:"RequestId"` 19 | } 20 | 21 | type xmlResponseError struct { 22 | xmlErrorResponse 23 | } 24 | 25 | func (e *xmlResponseError) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { 26 | const svcUnavailableTagName = "ServiceUnavailableException" 27 | const errorResponseTagName = "ErrorResponse" 28 | 29 | switch start.Name.Local { 30 | case svcUnavailableTagName: 31 | e.Code = svcUnavailableTagName 32 | e.Message = "service is unavailable" 33 | return d.Skip() 34 | 35 | case errorResponseTagName: 36 | return d.DecodeElement(&e.xmlErrorResponse, &start) 37 | 38 | default: 39 | return fmt.Errorf("unknown error response tag, %v", start) 40 | } 41 | } 42 | 43 | // UnmarshalError unmarshals an error response for an AWS Query service. 44 | func UnmarshalError(r *request.Request) { 45 | defer r.HTTPResponse.Body.Close() 46 | 47 | var respErr xmlResponseError 48 | err := xmlutil.UnmarshalXMLError(&respErr, r.HTTPResponse.Body) 49 | if err != nil { 50 | r.Error = awserr.NewRequestFailure( 51 | awserr.New(request.ErrCodeSerialization, 52 | "failed to unmarshal error message", err), 53 | r.HTTPResponse.StatusCode, 54 | r.RequestID, 55 | ) 56 | return 57 | } 58 | 59 | reqID := respErr.RequestID 60 | if len(reqID) == 0 { 61 | reqID = r.RequestID 62 | } 63 | 64 | r.Error = awserr.NewRequestFailure( 65 | awserr.New(respErr.Code, respErr.Message, nil), 66 | r.HTTPResponse.StatusCode, 67 | reqID, 68 | ) 69 | } 70 | -------------------------------------------------------------------------------- /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/timestamp.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "math" 5 | "strconv" 6 | "time" 7 | 8 | "github.com/aws/aws-sdk-go/internal/sdkmath" 9 | ) 10 | 11 | // Names of time formats supported by the SDK 12 | const ( 13 | RFC822TimeFormatName = "rfc822" 14 | ISO8601TimeFormatName = "iso8601" 15 | UnixTimeFormatName = "unixTimestamp" 16 | ) 17 | 18 | // Time formats supported by the SDK 19 | // Output time is intended to not contain decimals 20 | const ( 21 | // RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT 22 | RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT" 23 | 24 | // This format is used for output time without seconds precision 25 | RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT" 26 | 27 | // RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z 28 | ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z" 29 | 30 | // This format is used for output time without seconds precision 31 | ISO8601OutputTimeFormat = "2006-01-02T15:04:05Z" 32 | ) 33 | 34 | // IsKnownTimestampFormat returns if the timestamp format name 35 | // is know to the SDK's protocols. 36 | func IsKnownTimestampFormat(name string) bool { 37 | switch name { 38 | case RFC822TimeFormatName: 39 | fallthrough 40 | case ISO8601TimeFormatName: 41 | fallthrough 42 | case UnixTimeFormatName: 43 | return true 44 | default: 45 | return false 46 | } 47 | } 48 | 49 | // FormatTime returns a string value of the time. 50 | func FormatTime(name string, t time.Time) string { 51 | t = t.UTC() 52 | 53 | switch name { 54 | case RFC822TimeFormatName: 55 | return t.Format(RFC822OutputTimeFormat) 56 | case ISO8601TimeFormatName: 57 | return t.Format(ISO8601OutputTimeFormat) 58 | case UnixTimeFormatName: 59 | return strconv.FormatInt(t.Unix(), 10) 60 | default: 61 | panic("unknown timestamp format name, " + name) 62 | } 63 | } 64 | 65 | // ParseTime attempts to parse the time given the format. Returns 66 | // the time if it was able to be parsed, and fails otherwise. 67 | func ParseTime(formatName, value string) (time.Time, error) { 68 | switch formatName { 69 | case RFC822TimeFormatName: 70 | return time.Parse(RFC822TimeFormat, value) 71 | case ISO8601TimeFormatName: 72 | return time.Parse(ISO8601TimeFormat, value) 73 | case UnixTimeFormatName: 74 | v, err := strconv.ParseFloat(value, 64) 75 | _, dec := math.Modf(v) 76 | dec = sdkmath.Round(dec*1e3) / 1e3 //Rounds 0.1229999 to 0.123 77 | if err != nil { 78 | return time.Time{}, err 79 | } 80 | return time.Unix(int64(v), int64(dec*(1e9))), nil 81 | default: 82 | panic("unknown timestamp format name, " + formatName) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /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/xml/xmlutil/sort.go: -------------------------------------------------------------------------------- 1 | package xmlutil 2 | 3 | import ( 4 | "encoding/xml" 5 | "strings" 6 | ) 7 | 8 | type xmlAttrSlice []xml.Attr 9 | 10 | func (x xmlAttrSlice) Len() int { 11 | return len(x) 12 | } 13 | 14 | func (x xmlAttrSlice) Less(i, j int) bool { 15 | spaceI, spaceJ := x[i].Name.Space, x[j].Name.Space 16 | localI, localJ := x[i].Name.Local, x[j].Name.Local 17 | valueI, valueJ := x[i].Value, x[j].Value 18 | 19 | spaceCmp := strings.Compare(spaceI, spaceJ) 20 | localCmp := strings.Compare(localI, localJ) 21 | valueCmp := strings.Compare(valueI, valueJ) 22 | 23 | if spaceCmp == -1 || (spaceCmp == 0 && (localCmp == -1 || (localCmp == 0 && valueCmp == -1))) { 24 | return true 25 | } 26 | 27 | return false 28 | } 29 | 30 | func (x xmlAttrSlice) Swap(i, j int) { 31 | x[i], x[j] = x[j], x[i] 32 | } 33 | -------------------------------------------------------------------------------- /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/client" 9 | "github.com/aws/aws-sdk-go/aws/endpoints" 10 | "github.com/aws/aws-sdk-go/aws/request" 11 | ) 12 | 13 | const ( 14 | // customRetryerMinRetryDelay sets min retry delay 15 | customRetryerMinRetryDelay = 1 * time.Second 16 | 17 | // customRetryerMaxRetryDelay sets max retry delay 18 | customRetryerMaxRetryDelay = 8 * time.Second 19 | ) 20 | 21 | func init() { 22 | initRequest = func(r *request.Request) { 23 | if r.Operation.Name == opCopySnapshot { // fill the PresignedURL parameter 24 | r.Handlers.Build.PushFront(fillPresignedURL) 25 | } 26 | 27 | // only set the retryer on request if config doesn't have a retryer 28 | if r.Config.Retryer == nil && (r.Operation.Name == opModifyNetworkInterfaceAttribute || r.Operation.Name == opAssignPrivateIpAddresses) { 29 | r.Retryer = client.DefaultRetryer{ 30 | NumMaxRetries: client.DefaultRetryerMaxNumRetries, 31 | MinRetryDelay: customRetryerMinRetryDelay, 32 | MinThrottleDelay: customRetryerMinRetryDelay, 33 | MaxRetryDelay: customRetryerMaxRetryDelay, 34 | MaxThrottleDelay: customRetryerMaxRetryDelay, 35 | } 36 | } 37 | } 38 | } 39 | 40 | func fillPresignedURL(r *request.Request) { 41 | if !r.ParamsFilled() { 42 | return 43 | } 44 | 45 | origParams := r.Params.(*CopySnapshotInput) 46 | 47 | // Stop if PresignedURL/DestinationRegion is set 48 | if origParams.PresignedUrl != nil || origParams.DestinationRegion != nil { 49 | return 50 | } 51 | 52 | origParams.DestinationRegion = r.Config.Region 53 | newParams := awsutil.CopyOf(r.Params).(*CopySnapshotInput) 54 | 55 | // Create a new request based on the existing request. We will use this to 56 | // presign the CopySnapshot request against the source region. 57 | cfg := r.Config.Copy(aws.NewConfig(). 58 | WithEndpoint(""). 59 | WithRegion(aws.StringValue(origParams.SourceRegion))) 60 | 61 | clientInfo := r.ClientInfo 62 | resolved, err := r.Config.EndpointResolver.EndpointFor( 63 | clientInfo.ServiceName, aws.StringValue(cfg.Region), 64 | func(opt *endpoints.Options) { 65 | opt.DisableSSL = aws.BoolValue(cfg.DisableSSL) 66 | opt.UseDualStack = aws.BoolValue(cfg.UseDualStack) 67 | }, 68 | ) 69 | if err != nil { 70 | r.Error = err 71 | return 72 | } 73 | 74 | clientInfo.Endpoint = resolved.URL 75 | clientInfo.SigningRegion = resolved.SigningRegion 76 | 77 | // Presign a CopySnapshot request with modified params 78 | req := request.New(*cfg, clientInfo, r.Handlers, r.Retryer, r.Operation, newParams, r.Data) 79 | url, err := req.Presign(5 * time.Minute) // 5 minutes should be enough. 80 | if err != nil { // bubble error back up to original request 81 | r.Error = err 82 | return 83 | } 84 | 85 | // We have our URL, set it on params 86 | origParams.PresignedUrl = &url 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/ec2/doc.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | // Package ec2 provides the client and types for making API 4 | // requests to Amazon Elastic Compute Cloud. 5 | // 6 | // Amazon Elastic Compute Cloud (Amazon EC2) provides secure and resizable computing 7 | // capacity in the AWS cloud. Using Amazon EC2 eliminates the need to invest 8 | // in hardware up front, so you can develop and deploy applications faster. 9 | // 10 | // To learn more, see the following resources: 11 | // 12 | // * Amazon EC2: AmazonEC2 product page (http://aws.amazon.com/ec2), Amazon 13 | // EC2 documentation (http://aws.amazon.com/documentation/ec2) 14 | // 15 | // * Amazon EBS: Amazon EBS product page (http://aws.amazon.com/ebs), Amazon 16 | // EBS documentation (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html) 17 | // 18 | // * Amazon VPC: Amazon VPC product page (http://aws.amazon.com/vpc), Amazon 19 | // VPC documentation (http://aws.amazon.com/documentation/vpc) 20 | // 21 | // * AWS VPN: AWS VPN product page (http://aws.amazon.com/vpn), AWS VPN documentation 22 | // (http://aws.amazon.com/documentation/vpn) 23 | // 24 | // See https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15 for more information on this service. 25 | // 26 | // See ec2 package documentation for more information. 27 | // https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/ 28 | // 29 | // Using the Client 30 | // 31 | // To contact Amazon Elastic Compute Cloud with the SDK use the New function to create 32 | // a new service client. With that client you can make API requests to the service. 33 | // These clients are safe to use concurrently. 34 | // 35 | // See the SDK's documentation for more information on how to use the SDK. 36 | // https://docs.aws.amazon.com/sdk-for-go/api/ 37 | // 38 | // See aws.Config documentation for more information on configuring SDK clients. 39 | // https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config 40 | // 41 | // See the Amazon Elastic Compute Cloud client EC2 for more 42 | // information on creating client for this service. 43 | // https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#New 44 | package ec2 45 | -------------------------------------------------------------------------------- /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/ec2/service.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package ec2 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/ec2query" 12 | ) 13 | 14 | // EC2 provides the API operation methods for making requests to 15 | // Amazon Elastic Compute Cloud. See this package's package overview docs 16 | // for details on the service. 17 | // 18 | // EC2 methods are safe to use concurrently. It is not safe to 19 | // modify mutate any of the struct's properties though. 20 | type EC2 struct { 21 | *client.Client 22 | } 23 | 24 | // Used for custom client initialization logic 25 | var initClient func(*client.Client) 26 | 27 | // Used for custom request initialization logic 28 | var initRequest func(*request.Request) 29 | 30 | // Service information constants 31 | const ( 32 | ServiceName = "ec2" // Name of service. 33 | EndpointsID = ServiceName // ID to lookup a service endpoint with. 34 | ServiceID = "EC2" // ServiceID is a unique identifer of a specific service. 35 | ) 36 | 37 | // New creates a new instance of the EC2 client with a session. 38 | // If additional configuration is needed for the client instance use the optional 39 | // aws.Config parameter to add your extra config. 40 | // 41 | // Example: 42 | // // Create a EC2 client from just a session. 43 | // svc := ec2.New(mySession) 44 | // 45 | // // Create a EC2 client with additional configuration 46 | // svc := ec2.New(mySession, aws.NewConfig().WithRegion("us-west-2")) 47 | func New(p client.ConfigProvider, cfgs ...*aws.Config) *EC2 { 48 | c := p.ClientConfig(EndpointsID, cfgs...) 49 | return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName) 50 | } 51 | 52 | // newClient creates, initializes and returns a new service client instance. 53 | func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *EC2 { 54 | svc := &EC2{ 55 | Client: client.New( 56 | cfg, 57 | metadata.ClientInfo{ 58 | ServiceName: ServiceName, 59 | ServiceID: ServiceID, 60 | SigningName: signingName, 61 | SigningRegion: signingRegion, 62 | Endpoint: endpoint, 63 | APIVersion: "2016-11-15", 64 | }, 65 | handlers, 66 | ), 67 | } 68 | 69 | // Handlers 70 | svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) 71 | svc.Handlers.Build.PushBackNamed(ec2query.BuildHandler) 72 | svc.Handlers.Unmarshal.PushBackNamed(ec2query.UnmarshalHandler) 73 | svc.Handlers.UnmarshalMeta.PushBackNamed(ec2query.UnmarshalMetaHandler) 74 | svc.Handlers.UnmarshalError.PushBackNamed(ec2query.UnmarshalErrorHandler) 75 | 76 | // Run custom client initialization if present 77 | if initClient != nil { 78 | initClient(svc.Client) 79 | } 80 | 81 | return svc 82 | } 83 | 84 | // newRequest creates a new request for a EC2 operation and runs any 85 | // custom request initialization. 86 | func (c *EC2) newRequest(op *request.Operation, params, data interface{}) *request.Request { 87 | req := c.NewRequest(op, params, data) 88 | 89 | // Run custom request initialization if present 90 | if initRequest != nil { 91 | initRequest(req) 92 | } 93 | 94 | return req 95 | } 96 | -------------------------------------------------------------------------------- /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 = customizeRequest 7 | } 8 | 9 | func customizeRequest(r *request.Request) { 10 | r.RetryErrorCodes = append(r.RetryErrorCodes, ErrCodeIDPCommunicationErrorException) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/sts/errors.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package sts 4 | 5 | const ( 6 | 7 | // ErrCodeExpiredTokenException for service response error code 8 | // "ExpiredTokenException". 9 | // 10 | // The web identity token that was passed is expired or is not valid. Get a 11 | // new identity token from the identity provider and then retry the request. 12 | ErrCodeExpiredTokenException = "ExpiredTokenException" 13 | 14 | // ErrCodeIDPCommunicationErrorException for service response error code 15 | // "IDPCommunicationError". 16 | // 17 | // The request could not be fulfilled because the non-AWS identity provider 18 | // (IDP) that was asked to verify the incoming identity token could not be reached. 19 | // This is often a transient error caused by network conditions. Retry the request 20 | // a limited number of times so that you don't exceed the request rate. If the 21 | // error persists, the non-AWS identity provider might be down or not responding. 22 | ErrCodeIDPCommunicationErrorException = "IDPCommunicationError" 23 | 24 | // ErrCodeIDPRejectedClaimException for service response error code 25 | // "IDPRejectedClaim". 26 | // 27 | // The identity provider (IdP) reported that authentication failed. This might 28 | // be because the claim is invalid. 29 | // 30 | // If this error is returned for the AssumeRoleWithWebIdentity operation, it 31 | // can also mean that the claim has expired or has been explicitly revoked. 32 | ErrCodeIDPRejectedClaimException = "IDPRejectedClaim" 33 | 34 | // ErrCodeInvalidAuthorizationMessageException for service response error code 35 | // "InvalidAuthorizationMessageException". 36 | // 37 | // The error returned if the message passed to DecodeAuthorizationMessage was 38 | // invalid. This can happen if the token contains invalid characters, such as 39 | // linebreaks. 40 | ErrCodeInvalidAuthorizationMessageException = "InvalidAuthorizationMessageException" 41 | 42 | // ErrCodeInvalidIdentityTokenException for service response error code 43 | // "InvalidIdentityToken". 44 | // 45 | // The web identity token that was passed could not be validated by AWS. Get 46 | // a new identity token from the identity provider and then retry the request. 47 | ErrCodeInvalidIdentityTokenException = "InvalidIdentityToken" 48 | 49 | // ErrCodeMalformedPolicyDocumentException for service response error code 50 | // "MalformedPolicyDocument". 51 | // 52 | // The request was rejected because the policy document was malformed. The error 53 | // message describes the specific error. 54 | ErrCodeMalformedPolicyDocumentException = "MalformedPolicyDocument" 55 | 56 | // ErrCodePackedPolicyTooLargeException for service response error code 57 | // "PackedPolicyTooLarge". 58 | // 59 | // The request was rejected because the policy document was too large. The error 60 | // message describes how big the policy document is, in packed form, as a percentage 61 | // of what the API allows. 62 | ErrCodePackedPolicyTooLargeException = "PackedPolicyTooLarge" 63 | 64 | // ErrCodeRegionDisabledException for service response error code 65 | // "RegionDisabledException". 66 | // 67 | // STS is not activated in the requested region for the account that is being 68 | // asked to generate credentials. The account administrator must use the IAM 69 | // console to activate STS in that region. For more information, see Activating 70 | // and Deactivating AWS STS in an AWS Region (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html) 71 | // in the IAM User Guide. 72 | ErrCodeRegionDisabledException = "RegionDisabledException" 73 | ) 74 | -------------------------------------------------------------------------------- /vendor/github.com/aws/aws-sdk-go/service/sts/service.go: -------------------------------------------------------------------------------- 1 | // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 | 3 | package sts 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/query" 12 | ) 13 | 14 | // STS provides the API operation methods for making requests to 15 | // AWS Security Token Service. See this package's package overview docs 16 | // for details on the service. 17 | // 18 | // STS methods are safe to use concurrently. It is not safe to 19 | // modify mutate any of the struct's properties though. 20 | type STS struct { 21 | *client.Client 22 | } 23 | 24 | // Used for custom client initialization logic 25 | var initClient func(*client.Client) 26 | 27 | // Used for custom request initialization logic 28 | var initRequest func(*request.Request) 29 | 30 | // Service information constants 31 | const ( 32 | ServiceName = "sts" // Name of service. 33 | EndpointsID = ServiceName // ID to lookup a service endpoint with. 34 | ServiceID = "STS" // ServiceID is a unique identifer of a specific service. 35 | ) 36 | 37 | // New creates a new instance of the STS client with a session. 38 | // If additional configuration is needed for the client instance use the optional 39 | // aws.Config parameter to add your extra config. 40 | // 41 | // Example: 42 | // // Create a STS client from just a session. 43 | // svc := sts.New(mySession) 44 | // 45 | // // Create a STS client with additional configuration 46 | // svc := sts.New(mySession, aws.NewConfig().WithRegion("us-west-2")) 47 | func New(p client.ConfigProvider, cfgs ...*aws.Config) *STS { 48 | c := p.ClientConfig(EndpointsID, cfgs...) 49 | return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName) 50 | } 51 | 52 | // newClient creates, initializes and returns a new service client instance. 53 | func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *STS { 54 | svc := &STS{ 55 | Client: client.New( 56 | cfg, 57 | metadata.ClientInfo{ 58 | ServiceName: ServiceName, 59 | ServiceID: ServiceID, 60 | SigningName: signingName, 61 | SigningRegion: signingRegion, 62 | Endpoint: endpoint, 63 | APIVersion: "2011-06-15", 64 | }, 65 | handlers, 66 | ), 67 | } 68 | 69 | // Handlers 70 | svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) 71 | svc.Handlers.Build.PushBackNamed(query.BuildHandler) 72 | svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler) 73 | svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler) 74 | svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler) 75 | 76 | // Run custom client initialization if present 77 | if initClient != nil { 78 | initClient(svc.Client) 79 | } 80 | 81 | return svc 82 | } 83 | 84 | // newRequest creates a new request for a STS operation and runs any 85 | // custom request initialization. 86 | func (c *STS) newRequest(op *request.Operation, params, data interface{}) *request.Request { 87 | req := c.NewRequest(op, params, data) 88 | 89 | // Run custom request initialization if present 90 | if initRequest != nil { 91 | initRequest(req) 92 | } 93 | 94 | return req 95 | } 96 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Peter Bourgon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/json_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "encoding" 5 | "encoding/json" 6 | "fmt" 7 | "io" 8 | "reflect" 9 | ) 10 | 11 | type jsonLogger struct { 12 | io.Writer 13 | } 14 | 15 | // NewJSONLogger returns a Logger that encodes keyvals to the Writer as a 16 | // single JSON object. Each log event produces no more than one call to 17 | // w.Write. The passed Writer must be safe for concurrent use by multiple 18 | // goroutines if the returned Logger will be used concurrently. 19 | func NewJSONLogger(w io.Writer) Logger { 20 | return &jsonLogger{w} 21 | } 22 | 23 | func (l *jsonLogger) Log(keyvals ...interface{}) error { 24 | n := (len(keyvals) + 1) / 2 // +1 to handle case when len is odd 25 | m := make(map[string]interface{}, n) 26 | for i := 0; i < len(keyvals); i += 2 { 27 | k := keyvals[i] 28 | var v interface{} = ErrMissingValue 29 | if i+1 < len(keyvals) { 30 | v = keyvals[i+1] 31 | } 32 | merge(m, k, v) 33 | } 34 | return json.NewEncoder(l.Writer).Encode(m) 35 | } 36 | 37 | func merge(dst map[string]interface{}, k, v interface{}) { 38 | var key string 39 | switch x := k.(type) { 40 | case string: 41 | key = x 42 | case fmt.Stringer: 43 | key = safeString(x) 44 | default: 45 | key = fmt.Sprint(x) 46 | } 47 | 48 | // We want json.Marshaler and encoding.TextMarshaller to take priority over 49 | // err.Error() and v.String(). But json.Marshall (called later) does that by 50 | // default so we force a no-op if it's one of those 2 case. 51 | switch x := v.(type) { 52 | case json.Marshaler: 53 | case encoding.TextMarshaler: 54 | case error: 55 | v = safeError(x) 56 | case fmt.Stringer: 57 | v = safeString(x) 58 | } 59 | 60 | dst[key] = v 61 | } 62 | 63 | func safeString(str fmt.Stringer) (s string) { 64 | defer func() { 65 | if panicVal := recover(); panicVal != nil { 66 | if v := reflect.ValueOf(str); v.Kind() == reflect.Ptr && v.IsNil() { 67 | s = "NULL" 68 | } else { 69 | panic(panicVal) 70 | } 71 | } 72 | }() 73 | s = str.String() 74 | return 75 | } 76 | 77 | func safeError(err error) (s interface{}) { 78 | defer func() { 79 | if panicVal := recover(); panicVal != nil { 80 | if v := reflect.ValueOf(err); v.Kind() == reflect.Ptr && v.IsNil() { 81 | s = nil 82 | } else { 83 | panic(panicVal) 84 | } 85 | } 86 | }() 87 | s = err.Error() 88 | return 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/level/doc.go: -------------------------------------------------------------------------------- 1 | // Package level implements leveled logging on top of package log. To use the 2 | // level package, create a logger as per normal in your func main, and wrap it 3 | // with level.NewFilter. 4 | // 5 | // var logger log.Logger 6 | // logger = log.NewLogfmtLogger(os.Stderr) 7 | // logger = level.NewFilter(logger, level.AllowInfoAndAbove()) // <-- 8 | // logger = log.With(logger, "ts", log.DefaultTimestampUTC) 9 | // 10 | // Then, at the callsites, use one of the level.Debug, Info, Warn, or Error 11 | // helper methods to emit leveled log events. 12 | // 13 | // logger.Log("foo", "bar") // as normal, no level 14 | // level.Debug(logger).Log("request_id", reqID, "trace_data", trace.Get()) 15 | // if value > 100 { 16 | // level.Error(logger).Log("value", value) 17 | // } 18 | // 19 | // NewFilter allows precise control over what happens when a log event is 20 | // emitted without a level key, or if a squelched level is used. Check the 21 | // Option functions for details. 22 | package level 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/logfmt_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "sync" 7 | 8 | "github.com/go-logfmt/logfmt" 9 | ) 10 | 11 | type logfmtEncoder struct { 12 | *logfmt.Encoder 13 | buf bytes.Buffer 14 | } 15 | 16 | func (l *logfmtEncoder) Reset() { 17 | l.Encoder.Reset() 18 | l.buf.Reset() 19 | } 20 | 21 | var logfmtEncoderPool = sync.Pool{ 22 | New: func() interface{} { 23 | var enc logfmtEncoder 24 | enc.Encoder = logfmt.NewEncoder(&enc.buf) 25 | return &enc 26 | }, 27 | } 28 | 29 | type logfmtLogger struct { 30 | w io.Writer 31 | } 32 | 33 | // NewLogfmtLogger returns a logger that encodes keyvals to the Writer in 34 | // logfmt format. Each log event produces no more than one call to w.Write. 35 | // The passed Writer must be safe for concurrent use by multiple goroutines if 36 | // the returned Logger will be used concurrently. 37 | func NewLogfmtLogger(w io.Writer) Logger { 38 | return &logfmtLogger{w} 39 | } 40 | 41 | func (l logfmtLogger) Log(keyvals ...interface{}) error { 42 | enc := logfmtEncoderPool.Get().(*logfmtEncoder) 43 | enc.Reset() 44 | defer logfmtEncoderPool.Put(enc) 45 | 46 | if err := enc.EncodeKeyvals(keyvals...); err != nil { 47 | return err 48 | } 49 | 50 | // Add newline to the end of the buffer 51 | if err := enc.EndRecord(); err != nil { 52 | return err 53 | } 54 | 55 | // The Logger interface requires implementations to be safe for concurrent 56 | // use by multiple goroutines. For this implementation that means making 57 | // only one call to l.w.Write() for each call to Log. 58 | if _, err := l.w.Write(enc.buf.Bytes()); err != nil { 59 | return err 60 | } 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/nop_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | type nopLogger struct{} 4 | 5 | // NewNopLogger returns a logger that doesn't do anything. 6 | func NewNopLogger() Logger { return nopLogger{} } 7 | 8 | func (nopLogger) Log(...interface{}) error { return nil } 9 | -------------------------------------------------------------------------------- /vendor/github.com/go-kit/kit/log/value.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/go-stack/stack" 7 | ) 8 | 9 | // A Valuer generates a log value. When passed to With or WithPrefix in a 10 | // value element (odd indexes), it represents a dynamic value which is re- 11 | // evaluated with each log event. 12 | type Valuer func() interface{} 13 | 14 | // bindValues replaces all value elements (odd indexes) containing a Valuer 15 | // with their generated value. 16 | func bindValues(keyvals []interface{}) { 17 | for i := 1; i < len(keyvals); i += 2 { 18 | if v, ok := keyvals[i].(Valuer); ok { 19 | keyvals[i] = v() 20 | } 21 | } 22 | } 23 | 24 | // containsValuer returns true if any of the value elements (odd indexes) 25 | // contain a Valuer. 26 | func containsValuer(keyvals []interface{}) bool { 27 | for i := 1; i < len(keyvals); i += 2 { 28 | if _, ok := keyvals[i].(Valuer); ok { 29 | return true 30 | } 31 | } 32 | return false 33 | } 34 | 35 | // Timestamp returns a timestamp Valuer. It invokes the t function to get the 36 | // time; unless you are doing something tricky, pass time.Now. 37 | // 38 | // Most users will want to use DefaultTimestamp or DefaultTimestampUTC, which 39 | // are TimestampFormats that use the RFC3339Nano format. 40 | func Timestamp(t func() time.Time) Valuer { 41 | return func() interface{} { return t() } 42 | } 43 | 44 | // TimestampFormat returns a timestamp Valuer with a custom time format. It 45 | // invokes the t function to get the time to format; unless you are doing 46 | // something tricky, pass time.Now. The layout string is passed to 47 | // Time.Format. 48 | // 49 | // Most users will want to use DefaultTimestamp or DefaultTimestampUTC, which 50 | // are TimestampFormats that use the RFC3339Nano format. 51 | func TimestampFormat(t func() time.Time, layout string) Valuer { 52 | return func() interface{} { 53 | return timeFormat{ 54 | time: t(), 55 | layout: layout, 56 | } 57 | } 58 | } 59 | 60 | // A timeFormat represents an instant in time and a layout used when 61 | // marshaling to a text format. 62 | type timeFormat struct { 63 | time time.Time 64 | layout string 65 | } 66 | 67 | func (tf timeFormat) String() string { 68 | return tf.time.Format(tf.layout) 69 | } 70 | 71 | // MarshalText implements encoding.TextMarshaller. 72 | func (tf timeFormat) MarshalText() (text []byte, err error) { 73 | // The following code adapted from the standard library time.Time.Format 74 | // method. Using the same undocumented magic constant to extend the size 75 | // of the buffer as seen there. 76 | b := make([]byte, 0, len(tf.layout)+10) 77 | b = tf.time.AppendFormat(b, tf.layout) 78 | return b, nil 79 | } 80 | 81 | // Caller returns a Valuer that returns a file and line from a specified depth 82 | // in the callstack. Users will probably want to use DefaultCaller. 83 | func Caller(depth int) Valuer { 84 | return func() interface{} { return stack.Caller(depth) } 85 | } 86 | 87 | var ( 88 | // DefaultTimestamp is a Valuer that returns the current wallclock time, 89 | // respecting time zones, when bound. 90 | DefaultTimestamp = TimestampFormat(time.Now, time.RFC3339Nano) 91 | 92 | // DefaultTimestampUTC is a Valuer that returns the current time in UTC 93 | // when bound. 94 | DefaultTimestampUTC = TimestampFormat( 95 | func() time.Time { return time.Now().UTC() }, 96 | time.RFC3339Nano, 97 | ) 98 | 99 | // DefaultCaller is a Valuer that returns the file and line where the Log 100 | // method was invoked. It can only be used with log.With. 101 | DefaultCaller = Caller(3) 102 | ) 103 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/.gitignore: -------------------------------------------------------------------------------- 1 | _testdata/ 2 | _testdata2/ 3 | logfmt-fuzz.zip 4 | logfmt.test.exe 5 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.3 5 | - 1.4 6 | - 1.5 7 | - 1.6 8 | - tip 9 | 10 | before_install: 11 | - go get github.com/mattn/goveralls 12 | - go get golang.org/x/tools/cmd/cover 13 | 14 | script: 15 | - goveralls -service=travis-ci 16 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 go-logfmt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/go-logfmt/logfmt?status.svg)](https://godoc.org/github.com/go-logfmt/logfmt) 2 | [![Go Report Card](https://goreportcard.com/badge/go-logfmt/logfmt)](https://goreportcard.com/report/go-logfmt/logfmt) 3 | [![TravisCI](https://travis-ci.org/go-logfmt/logfmt.svg?branch=master)](https://travis-ci.org/go-logfmt/logfmt) 4 | [![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=master) 5 | 6 | # logfmt 7 | 8 | Package logfmt implements utilities to marshal and unmarshal data in the [logfmt 9 | format](https://brandur.org/logfmt). It provides an API similar to 10 | [encoding/json](http://golang.org/pkg/encoding/json/) and 11 | [encoding/xml](http://golang.org/pkg/encoding/xml/). 12 | 13 | The logfmt format was first documented by Brandur Leach in [this 14 | article](https://brandur.org/logfmt). The format has not been formally 15 | standardized. The most authoritative public specification to date has been the 16 | documentation of a Go Language [package](http://godoc.org/github.com/kr/logfmt) 17 | written by Blake Mizerany and Keith Rarick. 18 | 19 | ## Goals 20 | 21 | This project attempts to conform as closely as possible to the prior art, while 22 | also removing ambiguity where necessary to provide well behaved encoder and 23 | decoder implementations. 24 | 25 | ## Non-goals 26 | 27 | This project does not attempt to formally standardize the logfmt format. In the 28 | event that logfmt is standardized this project would take conforming to the 29 | standard as a goal. 30 | 31 | ## Versioning 32 | 33 | Package logfmt publishes releases via [semver](http://semver.org/) compatible Git tags prefixed with a single 'v'. 34 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/doc.go: -------------------------------------------------------------------------------- 1 | // Package logfmt implements utilities to marshal and unmarshal data in the 2 | // logfmt format. The logfmt format records key/value pairs in a way that 3 | // balances readability for humans and simplicity of computer parsing. It is 4 | // most commonly used as a more human friendly alternative to JSON for 5 | // structured logging. 6 | package logfmt 7 | -------------------------------------------------------------------------------- /vendor/github.com/go-logfmt/logfmt/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package logfmt 4 | 5 | import ( 6 | "bufio" 7 | "bytes" 8 | "fmt" 9 | "io" 10 | "reflect" 11 | 12 | kr "github.com/kr/logfmt" 13 | ) 14 | 15 | // Fuzz checks reserialized data matches 16 | func Fuzz(data []byte) int { 17 | parsed, err := parse(data) 18 | if err != nil { 19 | return 0 20 | } 21 | var w1 bytes.Buffer 22 | if err = write(parsed, &w1); err != nil { 23 | panic(err) 24 | } 25 | parsed, err = parse(w1.Bytes()) 26 | if err != nil { 27 | panic(err) 28 | } 29 | var w2 bytes.Buffer 30 | if err = write(parsed, &w2); err != nil { 31 | panic(err) 32 | } 33 | if !bytes.Equal(w1.Bytes(), w2.Bytes()) { 34 | panic(fmt.Sprintf("reserialized data does not match:\n%q\n%q\n", w1.Bytes(), w2.Bytes())) 35 | } 36 | return 1 37 | } 38 | 39 | // FuzzVsKR checks go-logfmt/logfmt against kr/logfmt 40 | func FuzzVsKR(data []byte) int { 41 | parsed, err := parse(data) 42 | parsedKR, errKR := parseKR(data) 43 | 44 | // github.com/go-logfmt/logfmt is a stricter parser. It returns errors for 45 | // more inputs than github.com/kr/logfmt. Ignore any inputs that have a 46 | // stict error. 47 | if err != nil { 48 | return 0 49 | } 50 | 51 | // Fail if the more forgiving parser finds an error not found by the 52 | // stricter parser. 53 | if errKR != nil { 54 | panic(fmt.Sprintf("unmatched error: %v", errKR)) 55 | } 56 | 57 | if !reflect.DeepEqual(parsed, parsedKR) { 58 | panic(fmt.Sprintf("parsers disagree:\n%+v\n%+v\n", parsed, parsedKR)) 59 | } 60 | return 1 61 | } 62 | 63 | type kv struct { 64 | k, v []byte 65 | } 66 | 67 | func parse(data []byte) ([][]kv, error) { 68 | var got [][]kv 69 | dec := NewDecoder(bytes.NewReader(data)) 70 | for dec.ScanRecord() { 71 | var kvs []kv 72 | for dec.ScanKeyval() { 73 | kvs = append(kvs, kv{dec.Key(), dec.Value()}) 74 | } 75 | got = append(got, kvs) 76 | } 77 | return got, dec.Err() 78 | } 79 | 80 | func parseKR(data []byte) ([][]kv, error) { 81 | var ( 82 | s = bufio.NewScanner(bytes.NewReader(data)) 83 | err error 84 | h saveHandler 85 | got [][]kv 86 | ) 87 | for err == nil && s.Scan() { 88 | h.kvs = nil 89 | err = kr.Unmarshal(s.Bytes(), &h) 90 | got = append(got, h.kvs) 91 | } 92 | if err == nil { 93 | err = s.Err() 94 | } 95 | return got, err 96 | } 97 | 98 | type saveHandler struct { 99 | kvs []kv 100 | } 101 | 102 | func (h *saveHandler) HandleLogfmt(key, val []byte) error { 103 | if len(key) == 0 { 104 | key = nil 105 | } 106 | if len(val) == 0 { 107 | val = nil 108 | } 109 | h.kvs = append(h.kvs, kv{key, val}) 110 | return nil 111 | } 112 | 113 | func write(recs [][]kv, w io.Writer) error { 114 | enc := NewEncoder(w) 115 | for _, rec := range recs { 116 | for _, f := range rec { 117 | if err := enc.EncodeKeyval(f.k, f.v); err != nil { 118 | return err 119 | } 120 | } 121 | if err := enc.EndRecord(); err != nil { 122 | return err 123 | } 124 | } 125 | return nil 126 | } 127 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.7 5 | - 1.8 6 | - 1.9 7 | - tip 8 | 9 | before_install: 10 | - go get github.com/mattn/goveralls 11 | 12 | script: 13 | - goveralls -service=travis-ci 14 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Chris Hines 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/go-stack/stack?status.svg)](https://godoc.org/github.com/go-stack/stack) 2 | [![Go Report Card](https://goreportcard.com/badge/go-stack/stack)](https://goreportcard.com/report/go-stack/stack) 3 | [![TravisCI](https://travis-ci.org/go-stack/stack.svg?branch=master)](https://travis-ci.org/go-stack/stack) 4 | [![Coverage Status](https://coveralls.io/repos/github/go-stack/stack/badge.svg?branch=master)](https://coveralls.io/github/go-stack/stack?branch=master) 5 | 6 | # stack 7 | 8 | Package stack implements utilities to capture, manipulate, and format call 9 | stacks. It provides a simpler API than package runtime. 10 | 11 | The implementation takes care of the minutia and special cases of interpreting 12 | the program counter (pc) values returned by runtime.Callers. 13 | 14 | ## Versioning 15 | 16 | Package stack publishes releases via [semver](http://semver.org/) compatible Git 17 | tags prefixed with a single 'v'. The master branch always contains the latest 18 | release. The develop branch contains unreleased commits. 19 | 20 | ## Formatting 21 | 22 | Package stack's types implement fmt.Formatter, which provides a simple and 23 | flexible way to declaratively configure formatting when used with logging or 24 | error tracking packages. 25 | 26 | ```go 27 | func DoTheThing() { 28 | c := stack.Caller(0) 29 | log.Print(c) // "source.go:10" 30 | log.Printf("%+v", c) // "pkg/path/source.go:10" 31 | log.Printf("%n", c) // "DoTheThing" 32 | 33 | s := stack.Trace().TrimRuntime() 34 | log.Print(s) // "[source.go:15 caller.go:42 main.go:14]" 35 | } 36 | ``` 37 | 38 | See the docs for all of the supported formatting options. 39 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.3 7 | - go: 1.4 8 | - go: 1.5 9 | - go: 1.6 10 | - go: tip 11 | 12 | install: 13 | - go get golang.org/x/tools/cmd/vet 14 | 15 | script: 16 | - go get -t -v ./... 17 | - diff -u <(echo -n) <(gofmt -d .) 18 | - go tool vet . 19 | - go test -v -race ./... 20 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package context stores values shared during a request lifetime. 7 | 8 | For example, a router can set variables extracted from the URL and later 9 | application handlers can access those values, or it can be used to store 10 | sessions values to be saved at the end of a request. There are several 11 | others common uses. 12 | 13 | The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: 14 | 15 | http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 16 | 17 | Here's the basic usage: first define the keys that you will need. The key 18 | type is interface{} so a key can be of any type that supports equality. 19 | Here we define a key using a custom int type to avoid name collisions: 20 | 21 | package foo 22 | 23 | import ( 24 | "github.com/gorilla/context" 25 | ) 26 | 27 | type key int 28 | 29 | const MyKey key = 0 30 | 31 | Then set a variable. Variables are bound to an http.Request object, so you 32 | need a request instance to set a value: 33 | 34 | context.Set(r, MyKey, "bar") 35 | 36 | The application can later access the variable using the same key you provided: 37 | 38 | func MyHandler(w http.ResponseWriter, r *http.Request) { 39 | // val is "bar". 40 | val := context.Get(r, foo.MyKey) 41 | 42 | // returns ("bar", true) 43 | val, ok := context.GetOk(r, foo.MyKey) 44 | // ... 45 | } 46 | 47 | And that's all about the basic usage. We discuss some other ideas below. 48 | 49 | Any type can be stored in the context. To enforce a given type, make the key 50 | private and wrap Get() and Set() to accept and return values of a specific 51 | type: 52 | 53 | type key int 54 | 55 | const mykey key = 0 56 | 57 | // GetMyKey returns a value for this package from the request values. 58 | func GetMyKey(r *http.Request) SomeType { 59 | if rv := context.Get(r, mykey); rv != nil { 60 | return rv.(SomeType) 61 | } 62 | return nil 63 | } 64 | 65 | // SetMyKey sets a value for this package in the request values. 66 | func SetMyKey(r *http.Request, val SomeType) { 67 | context.Set(r, mykey, val) 68 | } 69 | 70 | Variables must be cleared at the end of a request, to remove all values 71 | that were stored. This can be done in an http.Handler, after a request was 72 | served. Just call Clear() passing the request: 73 | 74 | context.Clear(r) 75 | 76 | ...or use ClearHandler(), which conveniently wraps an http.Handler to clear 77 | variables at the end of a request lifetime. 78 | 79 | The Routers from the packages gorilla/mux and gorilla/pat call Clear() 80 | so if you are using either of them you don't need to clear the context manually. 81 | */ 82 | package context 83 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.4 7 | - go: 1.5 8 | - go: 1.6 9 | - go: 1.7 10 | - go: 1.8 11 | - go: tip 12 | allow_failures: 13 | - go: tip 14 | 15 | script: 16 | - go get -t -v ./... 17 | - diff -u <(echo -n) <(gofmt -d .) 18 | - go vet $(go list ./... | grep -v /vendor/) 19 | - go test -v -race ./... 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 The Gorilla Handlers Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/README.md: -------------------------------------------------------------------------------- 1 | gorilla/handlers 2 | ================ 3 | [![GoDoc](https://godoc.org/github.com/gorilla/handlers?status.svg)](https://godoc.org/github.com/gorilla/handlers) [![Build Status](https://travis-ci.org/gorilla/handlers.svg?branch=master)](https://travis-ci.org/gorilla/handlers) 4 | [![Sourcegraph](https://sourcegraph.com/github.com/gorilla/handlers/-/badge.svg)](https://sourcegraph.com/github.com/gorilla/handlers?badge) 5 | 6 | 7 | Package handlers is a collection of handlers (aka "HTTP middleware") for use 8 | with Go's `net/http` package (or any framework supporting `http.Handler`), including: 9 | 10 | * [**LoggingHandler**](https://godoc.org/github.com/gorilla/handlers#LoggingHandler) for logging HTTP requests in the Apache [Common Log 11 | Format](http://httpd.apache.org/docs/2.2/logs.html#common). 12 | * [**CombinedLoggingHandler**](https://godoc.org/github.com/gorilla/handlers#CombinedLoggingHandler) for logging HTTP requests in the Apache [Combined Log 13 | Format](http://httpd.apache.org/docs/2.2/logs.html#combined) commonly used by 14 | both Apache and nginx. 15 | * [**CompressHandler**](https://godoc.org/github.com/gorilla/handlers#CompressHandler) for gzipping responses. 16 | * [**ContentTypeHandler**](https://godoc.org/github.com/gorilla/handlers#ContentTypeHandler) for validating requests against a list of accepted 17 | content types. 18 | * [**MethodHandler**](https://godoc.org/github.com/gorilla/handlers#MethodHandler) for matching HTTP methods against handlers in a 19 | `map[string]http.Handler` 20 | * [**ProxyHeaders**](https://godoc.org/github.com/gorilla/handlers#ProxyHeaders) for populating `r.RemoteAddr` and `r.URL.Scheme` based on the 21 | `X-Forwarded-For`, `X-Real-IP`, `X-Forwarded-Proto` and RFC7239 `Forwarded` 22 | headers when running a Go server behind a HTTP reverse proxy. 23 | * [**CanonicalHost**](https://godoc.org/github.com/gorilla/handlers#CanonicalHost) for re-directing to the preferred host when handling multiple 24 | domains (i.e. multiple CNAME aliases). 25 | * [**RecoveryHandler**](https://godoc.org/github.com/gorilla/handlers#RecoveryHandler) for recovering from unexpected panics. 26 | 27 | Other handlers are documented [on the Gorilla 28 | website](http://www.gorillatoolkit.org/pkg/handlers). 29 | 30 | ## Example 31 | 32 | A simple example using `handlers.LoggingHandler` and `handlers.CompressHandler`: 33 | 34 | ```go 35 | import ( 36 | "net/http" 37 | "github.com/gorilla/handlers" 38 | ) 39 | 40 | func main() { 41 | r := http.NewServeMux() 42 | 43 | // Only log requests to our admin dashboard to stdout 44 | r.Handle("/admin", handlers.LoggingHandler(os.Stdout, http.HandlerFunc(ShowAdminDashboard))) 45 | r.HandleFunc("/", ShowIndex) 46 | 47 | // Wrap our server with our gzip handler to gzip compress all responses. 48 | http.ListenAndServe(":8000", handlers.CompressHandler(r)) 49 | } 50 | ``` 51 | 52 | ## License 53 | 54 | BSD licensed. See the included LICENSE file for details. 55 | 56 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/canonical.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "net/http" 5 | "net/url" 6 | "strings" 7 | ) 8 | 9 | type canonical struct { 10 | h http.Handler 11 | domain string 12 | code int 13 | } 14 | 15 | // CanonicalHost is HTTP middleware that re-directs requests to the canonical 16 | // domain. It accepts a domain and a status code (e.g. 301 or 302) and 17 | // re-directs clients to this domain. The existing request path is maintained. 18 | // 19 | // Note: If the provided domain is considered invalid by url.Parse or otherwise 20 | // returns an empty scheme or host, clients are not re-directed. 21 | // 22 | // Example: 23 | // 24 | // r := mux.NewRouter() 25 | // canonical := handlers.CanonicalHost("http://www.gorillatoolkit.org", 302) 26 | // r.HandleFunc("/route", YourHandler) 27 | // 28 | // log.Fatal(http.ListenAndServe(":7000", canonical(r))) 29 | // 30 | func CanonicalHost(domain string, code int) func(h http.Handler) http.Handler { 31 | fn := func(h http.Handler) http.Handler { 32 | return canonical{h, domain, code} 33 | } 34 | 35 | return fn 36 | } 37 | 38 | func (c canonical) ServeHTTP(w http.ResponseWriter, r *http.Request) { 39 | dest, err := url.Parse(c.domain) 40 | if err != nil { 41 | // Call the next handler if the provided domain fails to parse. 42 | c.h.ServeHTTP(w, r) 43 | return 44 | } 45 | 46 | if dest.Scheme == "" || dest.Host == "" { 47 | // Call the next handler if the scheme or host are empty. 48 | // Note that url.Parse won't fail on in this case. 49 | c.h.ServeHTTP(w, r) 50 | return 51 | } 52 | 53 | if !strings.EqualFold(cleanHost(r.Host), dest.Host) { 54 | // Re-build the destination URL 55 | dest := dest.Scheme + "://" + dest.Host + r.URL.Path 56 | if r.URL.RawQuery != "" { 57 | dest += "?" + r.URL.RawQuery 58 | } 59 | http.Redirect(w, r, dest, c.code) 60 | return 61 | } 62 | 63 | c.h.ServeHTTP(w, r) 64 | } 65 | 66 | // cleanHost cleans invalid Host headers by stripping anything after '/' or ' '. 67 | // This is backported from Go 1.5 (in response to issue #11206) and attempts to 68 | // mitigate malformed Host headers that do not match the format in RFC7230. 69 | func cleanHost(in string) string { 70 | if i := strings.IndexAny(in, " /"); i != -1 { 71 | return in[:i] 72 | } 73 | return in 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package handlers is a collection of handlers (aka "HTTP middleware") for use 3 | with Go's net/http package (or any framework supporting http.Handler). 4 | 5 | The package includes handlers for logging in standardised formats, compressing 6 | HTTP responses, validating content types and other useful tools for manipulating 7 | requests and responses. 8 | */ 9 | package handlers 10 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/handlers_go18.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package handlers 4 | 5 | import ( 6 | "fmt" 7 | "net/http" 8 | ) 9 | 10 | type loggingResponseWriter interface { 11 | commonLoggingResponseWriter 12 | http.Pusher 13 | } 14 | 15 | func (l *responseLogger) Push(target string, opts *http.PushOptions) error { 16 | p, ok := l.w.(http.Pusher) 17 | if !ok { 18 | return fmt.Errorf("responseLogger does not implement http.Pusher") 19 | } 20 | return p.Push(target, opts) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/handlers_pre18.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package handlers 4 | 5 | type loggingResponseWriter interface { 6 | commonLoggingResponseWriter 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/handlers/recovery.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "runtime/debug" 7 | ) 8 | 9 | // RecoveryHandlerLogger is an interface used by the recovering handler to print logs. 10 | type RecoveryHandlerLogger interface { 11 | Println(...interface{}) 12 | } 13 | 14 | type recoveryHandler struct { 15 | handler http.Handler 16 | logger RecoveryHandlerLogger 17 | printStack bool 18 | } 19 | 20 | // RecoveryOption provides a functional approach to define 21 | // configuration for a handler; such as setting the logging 22 | // whether or not to print strack traces on panic. 23 | type RecoveryOption func(http.Handler) 24 | 25 | func parseRecoveryOptions(h http.Handler, opts ...RecoveryOption) http.Handler { 26 | for _, option := range opts { 27 | option(h) 28 | } 29 | 30 | return h 31 | } 32 | 33 | // RecoveryHandler is HTTP middleware that recovers from a panic, 34 | // logs the panic, writes http.StatusInternalServerError, and 35 | // continues to the next handler. 36 | // 37 | // Example: 38 | // 39 | // r := mux.NewRouter() 40 | // r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 41 | // panic("Unexpected error!") 42 | // }) 43 | // 44 | // http.ListenAndServe(":1123", handlers.RecoveryHandler()(r)) 45 | func RecoveryHandler(opts ...RecoveryOption) func(h http.Handler) http.Handler { 46 | return func(h http.Handler) http.Handler { 47 | r := &recoveryHandler{handler: h} 48 | return parseRecoveryOptions(r, opts...) 49 | } 50 | } 51 | 52 | // RecoveryLogger is a functional option to override 53 | // the default logger 54 | func RecoveryLogger(logger RecoveryHandlerLogger) RecoveryOption { 55 | return func(h http.Handler) { 56 | r := h.(*recoveryHandler) 57 | r.logger = logger 58 | } 59 | } 60 | 61 | // PrintRecoveryStack is a functional option to enable 62 | // or disable printing stack traces on panic. 63 | func PrintRecoveryStack(print bool) RecoveryOption { 64 | return func(h http.Handler) { 65 | r := h.(*recoveryHandler) 66 | r.printStack = print 67 | } 68 | } 69 | 70 | func (h recoveryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { 71 | defer func() { 72 | if err := recover(); err != nil { 73 | w.WriteHeader(http.StatusInternalServerError) 74 | h.log(err) 75 | } 76 | }() 77 | 78 | h.handler.ServeHTTP(w, req) 79 | } 80 | 81 | func (h recoveryHandler) log(v ...interface{}) { 82 | if h.logger != nil { 83 | h.logger.Println(v...) 84 | } else { 85 | log.Println(v...) 86 | } 87 | 88 | if h.printStack { 89 | debug.PrintStack() 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.5 7 | - go: 1.6 8 | - go: 1.7 9 | - go: 1.8 10 | - go: 1.9 11 | - go: tip 12 | allow_failures: 13 | - go: tip 14 | 15 | install: 16 | - # Skip 17 | 18 | script: 19 | - go get -t -v ./... 20 | - diff -u <(echo -n) <(gofmt -d .) 21 | - go tool vet . 22 | - go test -v -race ./... 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_gorilla.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "net/http" 7 | 8 | "github.com/gorilla/context" 9 | ) 10 | 11 | func contextGet(r *http.Request, key interface{}) interface{} { 12 | return context.Get(r, key) 13 | } 14 | 15 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 16 | if val == nil { 17 | return r 18 | } 19 | 20 | context.Set(r, key, val) 21 | return r 22 | } 23 | 24 | func contextClear(r *http.Request) { 25 | context.Clear(r) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_native.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "context" 7 | "net/http" 8 | ) 9 | 10 | func contextGet(r *http.Request, key interface{}) interface{} { 11 | return r.Context().Value(key) 12 | } 13 | 14 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 15 | if val == nil { 16 | return r 17 | } 18 | 19 | return r.WithContext(context.WithValue(r.Context(), key, val)) 20 | } 21 | 22 | func contextClear(r *http.Request) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/.gitignore: -------------------------------------------------------------------------------- 1 | /jpgo 2 | jmespath-fuzz.zip 3 | cpu.out 4 | go-jmespath.test 5 | -------------------------------------------------------------------------------- /vendor/github.com/jmespath/go-jmespath/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | sudo: false 4 | 5 | go: 6 | - 1.4 7 | 8 | install: go get -v -t ./... 9 | script: make test 10 | -------------------------------------------------------------------------------- /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/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/kr/logfmt/.gitignore: -------------------------------------------------------------------------------- 1 | *.test 2 | *.swp 3 | *.prof 4 | -------------------------------------------------------------------------------- /vendor/github.com/kr/logfmt/Readme: -------------------------------------------------------------------------------- 1 | Go package for parsing (and, eventually, generating) 2 | log lines in the logfmt style. 3 | 4 | See http://godoc.org/github.com/kr/logfmt for format, and other documentation and examples. 5 | 6 | Copyright (C) 2013 Keith Rarick, Blake Mizerany 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 13 | -------------------------------------------------------------------------------- /vendor/github.com/kr/logfmt/scanner.go: -------------------------------------------------------------------------------- 1 | package logfmt 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | var ErrUnterminatedString = errors.New("logfmt: unterminated string") 9 | 10 | func gotoScanner(data []byte, h Handler) (err error) { 11 | saveError := func(e error) { 12 | if err == nil { 13 | err = e 14 | } 15 | } 16 | 17 | var c byte 18 | var i int 19 | var m int 20 | var key []byte 21 | var val []byte 22 | var ok bool 23 | var esc bool 24 | 25 | garbage: 26 | if i == len(data) { 27 | return 28 | } 29 | 30 | c = data[i] 31 | switch { 32 | case c > ' ' && c != '"' && c != '=': 33 | key, val = nil, nil 34 | m = i 35 | i++ 36 | goto key 37 | default: 38 | i++ 39 | goto garbage 40 | } 41 | 42 | key: 43 | if i >= len(data) { 44 | if m >= 0 { 45 | key = data[m:i] 46 | saveError(h.HandleLogfmt(key, nil)) 47 | } 48 | return 49 | } 50 | 51 | c = data[i] 52 | switch { 53 | case c > ' ' && c != '"' && c != '=': 54 | i++ 55 | goto key 56 | case c == '=': 57 | key = data[m:i] 58 | i++ 59 | goto equal 60 | default: 61 | key = data[m:i] 62 | i++ 63 | saveError(h.HandleLogfmt(key, nil)) 64 | goto garbage 65 | } 66 | 67 | equal: 68 | if i >= len(data) { 69 | if m >= 0 { 70 | i-- 71 | key = data[m:i] 72 | saveError(h.HandleLogfmt(key, nil)) 73 | } 74 | return 75 | } 76 | 77 | c = data[i] 78 | switch { 79 | case c > ' ' && c != '"' && c != '=': 80 | m = i 81 | i++ 82 | goto ivalue 83 | case c == '"': 84 | m = i 85 | i++ 86 | esc = false 87 | goto qvalue 88 | default: 89 | if key != nil { 90 | saveError(h.HandleLogfmt(key, val)) 91 | } 92 | i++ 93 | goto garbage 94 | } 95 | 96 | ivalue: 97 | if i >= len(data) { 98 | if m >= 0 { 99 | val = data[m:i] 100 | saveError(h.HandleLogfmt(key, val)) 101 | } 102 | return 103 | } 104 | 105 | c = data[i] 106 | switch { 107 | case c > ' ' && c != '"' && c != '=': 108 | i++ 109 | goto ivalue 110 | default: 111 | val = data[m:i] 112 | saveError(h.HandleLogfmt(key, val)) 113 | i++ 114 | goto garbage 115 | } 116 | 117 | qvalue: 118 | if i >= len(data) { 119 | if m >= 0 { 120 | saveError(ErrUnterminatedString) 121 | } 122 | return 123 | } 124 | 125 | c = data[i] 126 | switch c { 127 | case '\\': 128 | i += 2 129 | esc = true 130 | goto qvalue 131 | case '"': 132 | i++ 133 | val = data[m:i] 134 | if esc { 135 | val, ok = unquoteBytes(val) 136 | if !ok { 137 | saveError(fmt.Errorf("logfmt: error unquoting bytes %q", string(val))) 138 | goto garbage 139 | } 140 | } else { 141 | val = val[1 : len(val)-1] 142 | } 143 | saveError(h.HandleLogfmt(key, val)) 144 | goto garbage 145 | default: 146 | i++ 147 | goto qvalue 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /vendor/github.com/kr/logfmt/unquote.go: -------------------------------------------------------------------------------- 1 | package logfmt 2 | 3 | import ( 4 | "strconv" 5 | "unicode" 6 | "unicode/utf16" 7 | "unicode/utf8" 8 | ) 9 | 10 | // Taken from Go's encoding/json 11 | 12 | // Copyright 2010 The Go Authors. All rights reserved. 13 | // Use of this source code is governed by a BSD-style 14 | // license that can be found in the LICENSE file. 15 | 16 | // getu4 decodes \uXXXX from the beginning of s, returning the hex value, 17 | // or it returns -1. 18 | func getu4(s []byte) rune { 19 | if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { 20 | return -1 21 | } 22 | r, err := strconv.ParseUint(string(s[2:6]), 16, 64) 23 | if err != nil { 24 | return -1 25 | } 26 | return rune(r) 27 | } 28 | 29 | // unquote converts a quoted JSON string literal s into an actual string t. 30 | // The rules are different than for Go, so cannot use strconv.Unquote. 31 | func unquote(s []byte) (t string, ok bool) { 32 | s, ok = unquoteBytes(s) 33 | t = string(s) 34 | return 35 | } 36 | 37 | func unquoteBytes(s []byte) (t []byte, ok bool) { 38 | if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' { 39 | return 40 | } 41 | s = s[1 : len(s)-1] 42 | 43 | // Check for unusual characters. If there are none, 44 | // then no unquoting is needed, so return a slice of the 45 | // original bytes. 46 | r := 0 47 | for r < len(s) { 48 | c := s[r] 49 | if c == '\\' || c == '"' || c < ' ' { 50 | break 51 | } 52 | if c < utf8.RuneSelf { 53 | r++ 54 | continue 55 | } 56 | rr, size := utf8.DecodeRune(s[r:]) 57 | if rr == utf8.RuneError && size == 1 { 58 | break 59 | } 60 | r += size 61 | } 62 | if r == len(s) { 63 | return s, true 64 | } 65 | 66 | b := make([]byte, len(s)+2*utf8.UTFMax) 67 | w := copy(b, s[0:r]) 68 | for r < len(s) { 69 | // Out of room? Can only happen if s is full of 70 | // malformed UTF-8 and we're replacing each 71 | // byte with RuneError. 72 | if w >= len(b)-2*utf8.UTFMax { 73 | nb := make([]byte, (len(b)+utf8.UTFMax)*2) 74 | copy(nb, b[0:w]) 75 | b = nb 76 | } 77 | switch c := s[r]; { 78 | case c == '\\': 79 | r++ 80 | if r >= len(s) { 81 | return 82 | } 83 | switch s[r] { 84 | default: 85 | return 86 | case '"', '\\', '/', '\'': 87 | b[w] = s[r] 88 | r++ 89 | w++ 90 | case 'b': 91 | b[w] = '\b' 92 | r++ 93 | w++ 94 | case 'f': 95 | b[w] = '\f' 96 | r++ 97 | w++ 98 | case 'n': 99 | b[w] = '\n' 100 | r++ 101 | w++ 102 | case 'r': 103 | b[w] = '\r' 104 | r++ 105 | w++ 106 | case 't': 107 | b[w] = '\t' 108 | r++ 109 | w++ 110 | case 'u': 111 | r-- 112 | rr := getu4(s[r:]) 113 | if rr < 0 { 114 | return 115 | } 116 | r += 6 117 | if utf16.IsSurrogate(rr) { 118 | rr1 := getu4(s[r:]) 119 | if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { 120 | // A valid pair; consume. 121 | r += 6 122 | w += utf8.EncodeRune(b[w:], dec) 123 | break 124 | } 125 | // Invalid surrogate; fall back to replacement rune. 126 | rr = unicode.ReplacementChar 127 | } 128 | w += utf8.EncodeRune(b[w:], rr) 129 | } 130 | 131 | // Quote, control characters are invalid. 132 | case c == '"', c < ' ': 133 | return 134 | 135 | // ASCII 136 | case c < utf8.RuneSelf: 137 | b[w] = c 138 | r++ 139 | w++ 140 | 141 | // Coerce to well-formed UTF-8. 142 | default: 143 | rr, size := utf8.DecodeRune(s[r:]) 144 | r += size 145 | w += utf8.EncodeRune(b[w:], rr) 146 | } 147 | } 148 | return b[0:w], true 149 | } 150 | -------------------------------------------------------------------------------- /vendor/github.com/oklog/oklog/pkg/group/group.go: -------------------------------------------------------------------------------- 1 | // Package group implements an actor-runner with deterministic teardown. It is 2 | // somewhat similar to package errgroup, except it does not require actor 3 | // goroutines to understand context semantics. This makes it suitable for use 4 | // in more circumstances; for example, goroutines which are handling 5 | // connections from net.Listeners, or scanning input from a closable io.Reader. 6 | package group 7 | 8 | // Group collects actors (functions) and runs them concurrently. 9 | // When one actor (function) returns, all actors are interrupted. 10 | // The zero value of a Group is useful. 11 | type Group struct { 12 | actors []actor 13 | } 14 | 15 | // Add an actor (function) to the group. Each actor must be pre-emptable by an 16 | // interrupt function. That is, if interrupt is invoked, execute should return. 17 | // Also, it must be safe to call interrupt even after execute has returned. 18 | // 19 | // The first actor (function) to return interrupts all running actors. 20 | // The error is passed to the interrupt functions, and is returned by Run. 21 | func (g *Group) Add(execute func() error, interrupt func(error)) { 22 | g.actors = append(g.actors, actor{execute, interrupt}) 23 | } 24 | 25 | // Run all actors (functions) concurrently. 26 | // When the first actor returns, all others are interrupted. 27 | // Run only returns when all actors have exited. 28 | // Run returns the error returned by the first exiting actor. 29 | func (g *Group) Run() error { 30 | if len(g.actors) == 0 { 31 | return nil 32 | } 33 | 34 | // Run each actor. 35 | errors := make(chan error, len(g.actors)) 36 | for _, a := range g.actors { 37 | go func(a actor) { 38 | errors <- a.execute() 39 | }(a) 40 | } 41 | 42 | // Wait for the first actor to stop. 43 | err := <-errors 44 | 45 | // Signal all actors to stop. 46 | for _, a := range g.actors { 47 | a.interrupt(err) 48 | } 49 | 50 | // Wait for all actors to stop. 51 | for i := 1; i < cap(errors); i++ { 52 | <-errors 53 | } 54 | 55 | // Return the original error. 56 | return err 57 | } 58 | 59 | type actor struct { 60 | execute func() error 61 | interrupt func(error) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/aws/aws-sdk-go v1.25.14 2 | github.com/aws/aws-sdk-go/aws 3 | github.com/aws/aws-sdk-go/aws/awserr 4 | github.com/aws/aws-sdk-go/aws/awsutil 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/corehandlers 8 | github.com/aws/aws-sdk-go/aws/credentials 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/credentials/processcreds 12 | github.com/aws/aws-sdk-go/aws/credentials/stscreds 13 | github.com/aws/aws-sdk-go/aws/csm 14 | github.com/aws/aws-sdk-go/aws/defaults 15 | github.com/aws/aws-sdk-go/aws/ec2metadata 16 | github.com/aws/aws-sdk-go/aws/endpoints 17 | github.com/aws/aws-sdk-go/aws/request 18 | github.com/aws/aws-sdk-go/aws/session 19 | github.com/aws/aws-sdk-go/aws/signer/v4 20 | github.com/aws/aws-sdk-go/internal/ini 21 | github.com/aws/aws-sdk-go/internal/sdkio 22 | github.com/aws/aws-sdk-go/internal/sdkmath 23 | github.com/aws/aws-sdk-go/internal/sdkrand 24 | github.com/aws/aws-sdk-go/internal/sdkuri 25 | github.com/aws/aws-sdk-go/internal/shareddefaults 26 | github.com/aws/aws-sdk-go/private/protocol 27 | github.com/aws/aws-sdk-go/private/protocol/ec2query 28 | github.com/aws/aws-sdk-go/private/protocol/json/jsonutil 29 | github.com/aws/aws-sdk-go/private/protocol/query 30 | github.com/aws/aws-sdk-go/private/protocol/query/queryutil 31 | github.com/aws/aws-sdk-go/private/protocol/rest 32 | github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil 33 | github.com/aws/aws-sdk-go/service/ec2 34 | github.com/aws/aws-sdk-go/service/ec2/ec2iface 35 | github.com/aws/aws-sdk-go/service/sts 36 | github.com/aws/aws-sdk-go/service/sts/stsiface 37 | # github.com/go-kit/kit v0.6.0 38 | github.com/go-kit/kit/log 39 | github.com/go-kit/kit/log/level 40 | # github.com/go-logfmt/logfmt v0.3.0 41 | github.com/go-logfmt/logfmt 42 | # github.com/go-stack/stack v1.7.0 43 | github.com/go-stack/stack 44 | # github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f 45 | github.com/gorilla/context 46 | # github.com/gorilla/handlers v1.3.0 47 | github.com/gorilla/handlers 48 | # github.com/gorilla/mux v1.6.0 49 | github.com/gorilla/mux 50 | # github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af 51 | github.com/jmespath/go-jmespath 52 | # github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 53 | github.com/kr/logfmt 54 | # github.com/oklog/oklog v0.2.2 55 | github.com/oklog/oklog/pkg/group 56 | -------------------------------------------------------------------------------- /version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intuit, Inc. All rights reserved. 2 | // Use of this source code is governed the MIT license 3 | // that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | const version = "2.6.0" 8 | --------------------------------------------------------------------------------