summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-03-13 16:43:00 -0400
committerGitHub <noreply@github.com>2017-03-13 16:43:00 -0400
commit24496cd0b278352b44e9411d924185e306fa346b (patch)
tree171f670e432b02309d0963fae811aec079fc128e /vendor
parent3b081bda080eceeb05c63e74cf2803821f1330ab (diff)
downloadchat-24496cd0b278352b44e9411d924185e306fa346b.tar.gz
chat-24496cd0b278352b44e9411d924185e306fa346b.tar.bz2
chat-24496cd0b278352b44e9411d924185e306fa346b.zip
Removing goamz (#5753)
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/goamz/goamz/.gitignore1
-rw-r--r--vendor/github.com/goamz/goamz/.lbox1
-rw-r--r--vendor/github.com/goamz/goamz/.travis.yml32
-rw-r--r--vendor/github.com/goamz/goamz/CHANGES.md5
-rw-r--r--vendor/github.com/goamz/goamz/LICENSE185
-rw-r--r--vendor/github.com/goamz/goamz/README.md64
-rw-r--r--vendor/github.com/goamz/goamz/autoscaling/autoscaling.go1768
-rw-r--r--vendor/github.com/goamz/goamz/autoscaling/autoscaling_test.go1180
-rw-r--r--vendor/github.com/goamz/goamz/autoscaling/responses_test.go627
-rw-r--r--vendor/github.com/goamz/goamz/aws/attempt.go74
-rw-r--r--vendor/github.com/goamz/goamz/aws/attempt_test.go58
-rw-r--r--vendor/github.com/goamz/goamz/aws/aws.go435
-rw-r--r--vendor/github.com/goamz/goamz/aws/aws_test.go211
-rw-r--r--vendor/github.com/goamz/goamz/aws/client.go124
-rw-r--r--vendor/github.com/goamz/goamz/aws/client_test.go121
-rw-r--r--vendor/github.com/goamz/goamz/aws/export_test.go29
-rw-r--r--vendor/github.com/goamz/goamz/aws/regions.go300
-rw-r--r--vendor/github.com/goamz/goamz/aws/sign.go357
-rw-r--r--vendor/github.com/goamz/goamz/aws/sign_test.go540
-rw-r--r--vendor/github.com/goamz/goamz/cloudformation/cloudformation.go837
-rw-r--r--vendor/github.com/goamz/goamz/cloudformation/cloudformation_test.go653
-rw-r--r--vendor/github.com/goamz/goamz/cloudformation/responses_test.go371
-rw-r--r--vendor/github.com/goamz/goamz/cloudfront/cloudfront.go135
-rw-r--r--vendor/github.com/goamz/goamz/cloudfront/cloudfront_test.go52
-rw-r--r--vendor/github.com/goamz/goamz/cloudfront/testdata/key.pem15
-rw-r--r--vendor/github.com/goamz/goamz/cloudfront/testdata/key.pub6
-rw-r--r--vendor/github.com/goamz/goamz/cloudwatch/ChangeLog7
-rw-r--r--vendor/github.com/goamz/goamz/cloudwatch/README.md109
-rw-r--r--vendor/github.com/goamz/goamz/cloudwatch/cloudwatch.go404
-rw-r--r--vendor/github.com/goamz/goamz/cloudwatch/cloudwatch_test.go132
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/.gitignore1
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/Makefile13
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/README.md27
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/attribute.go185
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/const.go11
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/dynamodb.go142
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/dynamodb_test.go166
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/item.go351
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/item_test.go446
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/marshaller.go626
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/marshaller_test.go283
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/query.go111
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/query_builder.go362
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/query_builder_test.go380
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/scan.go51
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/stream.go307
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/stream_test.go198
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/table.go259
-rwxr-xr-xvendor/github.com/goamz/goamz/dynamodb/table_test.go79
-rw-r--r--vendor/github.com/goamz/goamz/dynamodb/update_item.go94
-rw-r--r--vendor/github.com/goamz/goamz/ec2/ec2.go2267
-rw-r--r--vendor/github.com/goamz/goamz/ec2/ec2_test.go1280
-rw-r--r--vendor/github.com/goamz/goamz/ec2/ec2i_test.go204
-rw-r--r--vendor/github.com/goamz/goamz/ec2/ec2t_test.go581
-rw-r--r--vendor/github.com/goamz/goamz/ec2/ec2test/filter.go84
-rw-r--r--vendor/github.com/goamz/goamz/ec2/ec2test/server.go993
-rw-r--r--vendor/github.com/goamz/goamz/ec2/export_test.go22
-rw-r--r--vendor/github.com/goamz/goamz/ec2/responses_test.go1084
-rw-r--r--vendor/github.com/goamz/goamz/ec2/sign.go45
-rw-r--r--vendor/github.com/goamz/goamz/ec2/sign_test.go68
-rw-r--r--vendor/github.com/goamz/goamz/ec2/vpc.go399
-rw-r--r--vendor/github.com/goamz/goamz/ec2/vpc_test.go224
-rw-r--r--vendor/github.com/goamz/goamz/ecs/ecs.go1075
-rw-r--r--vendor/github.com/goamz/goamz/ecs/ecs_test.go806
-rw-r--r--vendor/github.com/goamz/goamz/ecs/responses_test.go637
-rw-r--r--vendor/github.com/goamz/goamz/elb/elb.go435
-rw-r--r--vendor/github.com/goamz/goamz/elb/elb_test.go369
-rw-r--r--vendor/github.com/goamz/goamz/elb/elbi_test.go308
-rw-r--r--vendor/github.com/goamz/goamz/elb/elbt_test.go243
-rw-r--r--vendor/github.com/goamz/goamz/elb/elbtest/server.go551
-rw-r--r--vendor/github.com/goamz/goamz/elb/export_test.go9
-rw-r--r--vendor/github.com/goamz/goamz/elb/response_test.go234
-rw-r--r--vendor/github.com/goamz/goamz/elb/sign.go35
-rw-r--r--vendor/github.com/goamz/goamz/elb/sign_test.go66
-rw-r--r--vendor/github.com/goamz/goamz/elb/suite_test.go119
-rw-r--r--vendor/github.com/goamz/goamz/exp/mturk/example_test.go66
-rw-r--r--vendor/github.com/goamz/goamz/exp/mturk/export_test.go9
-rw-r--r--vendor/github.com/goamz/goamz/exp/mturk/mturk.go480
-rw-r--r--vendor/github.com/goamz/goamz/exp/mturk/mturk_test.go170
-rw-r--r--vendor/github.com/goamz/goamz/exp/mturk/responses_test.go36
-rw-r--r--vendor/github.com/goamz/goamz/exp/mturk/sign.go22
-rw-r--r--vendor/github.com/goamz/goamz/exp/mturk/sign_test.go19
-rw-r--r--vendor/github.com/goamz/goamz/exp/sdb/export_test.go9
-rw-r--r--vendor/github.com/goamz/goamz/exp/sdb/responses_test.go120
-rw-r--r--vendor/github.com/goamz/goamz/exp/sdb/sdb.go413
-rw-r--r--vendor/github.com/goamz/goamz/exp/sdb/sdb_test.go219
-rw-r--r--vendor/github.com/goamz/goamz/exp/sdb/sign.go54
-rw-r--r--vendor/github.com/goamz/goamz/exp/sdb/sign_test.go29
-rw-r--r--vendor/github.com/goamz/goamz/exp/ses/ses.go149
-rw-r--r--vendor/github.com/goamz/goamz/exp/ses/ses_test.go69
-rw-r--r--vendor/github.com/goamz/goamz/exp/ses/ses_types.go160
-rw-r--r--vendor/github.com/goamz/goamz/exp/ses/sign.go26
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/Makefile21
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/README1
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/endpoint.go132
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/permissions.go51
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/platform.go135
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/responses_test.go317
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/sign.go72
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/sns.go113
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/sns_test.go455
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/subscription.go165
-rw-r--r--vendor/github.com/goamz/goamz/exp/sns/topic.go104
-rw-r--r--vendor/github.com/goamz/goamz/iam/iam.go643
-rw-r--r--vendor/github.com/goamz/goamz/iam/iam_test.go450
-rw-r--r--vendor/github.com/goamz/goamz/iam/iami_test.go209
-rw-r--r--vendor/github.com/goamz/goamz/iam/iamt_test.go39
-rw-r--r--vendor/github.com/goamz/goamz/iam/iamtest/server.go432
-rw-r--r--vendor/github.com/goamz/goamz/iam/responses_test.go261
-rw-r--r--vendor/github.com/goamz/goamz/iam/sign.go38
-rw-r--r--vendor/github.com/goamz/goamz/rds/rds.go96
-rw-r--r--vendor/github.com/goamz/goamz/rds/rds_test.go77
-rw-r--r--vendor/github.com/goamz/goamz/rds/responses_test.go57
-rw-r--r--vendor/github.com/goamz/goamz/rds/types.go388
-rw-r--r--vendor/github.com/goamz/goamz/route53/route53.go254
-rw-r--r--vendor/github.com/goamz/goamz/s3/export_test.go17
-rw-r--r--vendor/github.com/goamz/goamz/s3/multi.go439
-rw-r--r--vendor/github.com/goamz/goamz/s3/multi_test.go373
-rw-r--r--vendor/github.com/goamz/goamz/s3/responses_test.go202
-rw-r--r--vendor/github.com/goamz/goamz/s3/s3.go1164
-rw-r--r--vendor/github.com/goamz/goamz/s3/s3_test.go427
-rw-r--r--vendor/github.com/goamz/goamz/s3/s3i_test.go590
-rw-r--r--vendor/github.com/goamz/goamz/s3/s3t_test.go83
-rw-r--r--vendor/github.com/goamz/goamz/s3/s3test/server.go642
-rw-r--r--vendor/github.com/goamz/goamz/s3/sign.go141
-rw-r--r--vendor/github.com/goamz/goamz/s3/sign_test.go132
-rw-r--r--vendor/github.com/goamz/goamz/sqs/Makefile20
-rw-r--r--vendor/github.com/goamz/goamz/sqs/README.md38
-rw-r--r--vendor/github.com/goamz/goamz/sqs/responses_test.go196
-rw-r--r--vendor/github.com/goamz/goamz/sqs/sqs.go585
-rw-r--r--vendor/github.com/goamz/goamz/sqs/sqs_test.go414
-rw-r--r--vendor/github.com/goamz/goamz/sqs/suite_test.go145
-rw-r--r--vendor/github.com/goamz/goamz/sts/responses_test.go84
-rw-r--r--vendor/github.com/goamz/goamz/sts/sts.go273
-rw-r--r--vendor/github.com/goamz/goamz/sts/sts_test.go151
-rw-r--r--vendor/github.com/goamz/goamz/testutil/http.go180
-rw-r--r--vendor/github.com/goamz/goamz/testutil/suite.go31
137 files changed, 0 insertions, 37950 deletions
diff --git a/vendor/github.com/goamz/goamz/.gitignore b/vendor/github.com/goamz/goamz/.gitignore
deleted file mode 100644
index 1377554eb..000000000
--- a/vendor/github.com/goamz/goamz/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.swp
diff --git a/vendor/github.com/goamz/goamz/.lbox b/vendor/github.com/goamz/goamz/.lbox
deleted file mode 100644
index 75e124512..000000000
--- a/vendor/github.com/goamz/goamz/.lbox
+++ /dev/null
@@ -1 +0,0 @@
-propose -for=lp:goamz -cr
diff --git a/vendor/github.com/goamz/goamz/.travis.yml b/vendor/github.com/goamz/goamz/.travis.yml
deleted file mode 100644
index 3c26b1759..000000000
--- a/vendor/github.com/goamz/goamz/.travis.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-language: go
-
-go:
- - 1.1
- - 1.2
- - 1.3
- - 1.4
- - tip
-
-before_script:
- - FIXED=$(go fmt ./... | wc -l); if [ $FIXED -gt 0 ]; then echo "gofmt - $FIXED file(s) not formatted correctly, please run gofmt to fix this." && exit 1; fi
-
-script:
- - go test -v ./autoscaling/
- - go test -v ./aws/
- - go test -v ./cloudformation/
- - go test -v ./cloudfront/
- - go test -v ./cloudwatch/
- - go test -v ./dynamodb/
- - go test -v ./ec2/
- - go test -v ./ecs/
- - go test -v ./elb/
- - go test -v ./iam/
- - go test -v ./rds/
- - go test -v ./route53/
- - go test -v ./s3/
- - go test -v ./sqs/
- - go test -v ./sts/
- - go test -v ./exp/mturk/
- - go test -v ./exp/sdb/
- # - go test -v ./exp/ses/
- # - go test -v ./exp/sns/
diff --git a/vendor/github.com/goamz/goamz/CHANGES.md b/vendor/github.com/goamz/goamz/CHANGES.md
deleted file mode 100644
index 3d047b896..000000000
--- a/vendor/github.com/goamz/goamz/CHANGES.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Changes in this fork
-
-* Added CNNorth Region
-* Change SignV2 to SignV4
-* V4Signer.canonicalQueryString empty value must append "=" \ No newline at end of file
diff --git a/vendor/github.com/goamz/goamz/LICENSE b/vendor/github.com/goamz/goamz/LICENSE
deleted file mode 100644
index 53320c352..000000000
--- a/vendor/github.com/goamz/goamz/LICENSE
+++ /dev/null
@@ -1,185 +0,0 @@
-This software is licensed under the LGPLv3, included below.
-
-As a special exception to the GNU Lesser General Public License version 3
-("LGPL3"), the copyright holders of this Library give you permission to
-convey to a third party a Combined Work that links statically or dynamically
-to this Library without providing any Minimal Corresponding Source or
-Minimal Application Code as set out in 4d or providing the installation
-information set out in section 4e, provided that you comply with the other
-provisions of LGPL3 and provided that you meet, for the Application the
-terms and conditions of the license(s) which apply to the Application.
-
-Except as stated in this special exception, the provisions of LGPL3 will
-continue to comply in full to this Library. If you modify this Library, you
-may apply this exception to your version of this Library, but you are not
-obliged to do so. If you do not wish to do so, delete this exception
-statement from your version. This exception does not (and cannot) modify any
-license terms which apply to the Application, with which you must still
-comply.
-
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/vendor/github.com/goamz/goamz/README.md b/vendor/github.com/goamz/goamz/README.md
deleted file mode 100644
index e1b617484..000000000
--- a/vendor/github.com/goamz/goamz/README.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# goamz - An Amazon Library for Go
-
-[![Build Status](http://travis-ci.org/goamz/goamz.png?branch=master)](https://travis-ci.org/goamz/goamz)
-
-The _goamz_ package enables Go programs to interact with Amazon Web Services.
-
-This is a fork of the version [developed within Canonical](https://wiki.ubuntu.com/goamz) with additional functionality and services from [a number of contributors](https://github.com/goamz/goamz/contributors)!
-
-The API of AWS is very comprehensive, though, and goamz doesn't even scratch the surface of it. That said, it's fairly well tested, and is the foundation in which further calls can easily be integrated. We'll continue extending the API as necessary - Pull Requests are _very_ welcome!
-
-The following packages are available at the moment:
-
-```
-github.com/goamz/goamz/autoscaling
-github.com/goamz/goamz/aws
-github.com/goamz/goamz/cloudformation
-github.com/goamz/goamz/cloudfront
-github.com/goamz/goamz/cloudwatch
-github.com/goamz/goamz/dynamodb
-github.com/goamz/goamz/ecs
-github.com/goamz/goamz/ec2
-github.com/goamz/goamz/elb
-github.com/goamz/goamz/iam
-github.com/goamz/goamz/rds
-github.com/goamz/goamz/route53
-github.com/goamz/goamz/s3
-github.com/goamz/goamz/sqs
-github.com/goamz/goamz/sts
-
-github.com/goamz/goamz/exp/mturk
-github.com/goamz/goamz/exp/sdb
-github.com/goamz/goamz/exp/sns
-```
-
-Packages under `exp/` are still in an experimental or unfinished/unpolished state.
-
-## API documentation
-
-The API documentation is currently available at:
-
-[http://godoc.org/github.com/goamz/goamz](http://godoc.org/github.com/goamz/goamz)
-
-## How to build and install goamz
-
-Just use `go get` with any of the available packages. For example:
-
-* `$ go get github.com/goamz/goamz/ec2`
-* `$ go get github.com/goamz/goamz/s3`
-
-## Running tests
-
-To run tests, first install gocheck with:
-
-`$ go get gopkg.in/check.v1`
-
-Then run go test as usual:
-
-`$ go test github.com/goamz/goamz/...`
-
-_Note:_ running all tests with the command `go test ./...` will currently fail as tests do not tear down their HTTP listeners.
-
-If you want to run integration tests (costs money), set up the EC2 environment variables as usual, and run:
-
-$ gotest -i
diff --git a/vendor/github.com/goamz/goamz/autoscaling/autoscaling.go b/vendor/github.com/goamz/goamz/autoscaling/autoscaling.go
deleted file mode 100644
index 8e9f8ab02..000000000
--- a/vendor/github.com/goamz/goamz/autoscaling/autoscaling.go
+++ /dev/null
@@ -1,1768 +0,0 @@
-//
-// autoscaling: This package provides types and functions to interact with the AWS Auto Scale API
-//
-// Depends on https://wiki.ubuntu.com/goamz
-//
-
-package autoscaling
-
-import (
- "encoding/base64"
- "encoding/xml"
- "fmt"
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "sort"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-const debug = false
-
-var timeNow = time.Now
-
-// AutoScaling contains the details of the AWS region to perform operations against.
-type AutoScaling struct {
- aws.Auth
- aws.Region
-}
-
-// New creates a new AutoScaling Client.
-func New(auth aws.Auth, region aws.Region) *AutoScaling {
- return &AutoScaling{auth, region}
-}
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-// Error encapsulates an error returned by the AWS Auto Scaling API.
-//
-// See http://goo.gl/VZGuC for more details.
-type Error struct {
- // HTTP status code (200, 403, ...)
- StatusCode int
- // AutoScaling error code ("UnsupportedOperation", ...)
- Code string
- // The error type
- Type string
- // The human-oriented error message
- Message string
- RequestId string `xml:"RequestID"`
-}
-
-func (err *Error) Error() string {
- if err.Code == "" {
- return err.Message
- }
-
- return fmt.Sprintf("%s (%s)", err.Message, err.Code)
-}
-
-type xmlErrors struct {
- RequestId string `xml:"RequestId"`
- Errors []Error `xml:"Error"`
-}
-
-func (as *AutoScaling) query(params map[string]string, resp interface{}) error {
- params["Version"] = "2011-01-01"
- data := strings.NewReader(multimap(params).Encode())
-
- hreq, err := http.NewRequest("POST", as.Region.AutoScalingEndpoint+"/", data)
- if err != nil {
- return err
- }
-
- hreq.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
-
- token := as.Auth.Token()
- if token != "" {
- hreq.Header.Set("X-Amz-Security-Token", token)
- }
-
- signer := aws.NewV4Signer(as.Auth, "autoscaling", as.Region)
- signer.Sign(hreq)
-
- if debug {
- log.Printf("%v -> {\n", hreq)
- }
- r, err := http.DefaultClient.Do(hreq)
-
- if err != nil {
- log.Printf("Error calling Amazon %v", err)
- return err
- }
-
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("response:\n")
- log.Printf("%v\n}\n", string(dump))
- }
- if r.StatusCode != 200 {
- return buildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-func buildError(r *http.Response) error {
- var (
- err Error
- errors xmlErrors
- )
- xml.NewDecoder(r.Body).Decode(&errors)
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
-
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-func makeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-func addParamsList(params map[string]string, label string, ids []string) {
- for i, id := range ids {
- params[label+"."+strconv.Itoa(i+1)] = id
- }
-}
-
-// ----------------------------------------------------------------------------
-// Filtering helper.
-
-// Filter builds filtering parameters to be used in an autoscaling query which supports
-// filtering. For example:
-//
-// filter := NewFilter()
-// filter.Add("architecture", "i386")
-// filter.Add("launch-index", "0")
-// resp, err := as.DescribeTags(filter,nil,nil)
-//
-type Filter struct {
- m map[string][]string
-}
-
-// NewFilter creates a new Filter.
-func NewFilter() *Filter {
- return &Filter{make(map[string][]string)}
-}
-
-// Add appends a filtering parameter with the given name and value(s).
-func (f *Filter) Add(name string, value ...string) {
- f.m[name] = append(f.m[name], value...)
-}
-
-func (f *Filter) addParams(params map[string]string) {
- if f != nil {
- a := make([]string, len(f.m))
- i := 0
- for k := range f.m {
- a[i] = k
- i++
- }
- sort.StringSlice(a).Sort()
- for i, k := range a {
- prefix := "Filters.member." + strconv.Itoa(i+1)
- params[prefix+".Name"] = k
- for j, v := range f.m[k] {
- params[prefix+".Values.member."+strconv.Itoa(j+1)] = v
- }
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// Auto Scaling base types and related functions.
-
-// SimpleResp is the basic response from most actions.
-type SimpleResp struct {
- XMLName xml.Name
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// EnabledMetric encapsulates a metric associated with an Auto Scaling Group
-//
-// See http://goo.gl/hXiH17 for more details
-type EnabledMetric struct {
- Granularity string `xml:"Granularity"` // The granularity of the enabled metric.
- Metric string `xml:"Metric"` // The name of the enabled metric.
-}
-
-// Instance encapsulates an instance type as returned by the Auto Scaling API
-//
-// See http://goo.gl/NwBxGh and http://goo.gl/OuoqhS for more details.
-type Instance struct {
- // General instance information
- AutoScalingGroupName string `xml:"AutoScalingGroupName"`
- AvailabilityZone string `xml:"AvailabilityZone"`
- HealthStatus string `xml:"HealthStatus"`
- InstanceId string `xml:"InstanceId"`
- LaunchConfigurationName string `xml:"LaunchConfigurationName"`
- LifecycleState string `xml:"LifecycleState"`
-}
-
-// SuspenedProcess encapsulates an Auto Scaling process that has been suspended
-//
-// See http://goo.gl/iObPgF for more details
-type SuspendedProcess struct {
- ProcessName string `xml:"ProcessName"`
- SuspensionReason string `xml:"SuspensionReason"`
-}
-
-// Tag encapsulates tag applied to an Auto Scaling group.
-//
-// See http://goo.gl/MG1hqs for more details
-type Tag struct {
- Key string `xml:"Key"`
- PropagateAtLaunch bool `xml:"PropagateAtLaunch"` // Specifies whether the new tag will be applied to instances launched after the tag is created
- ResourceId string `xml:"ResourceId"` // the name of the Auto Scaling group - not required if creating ASG
- ResourceType string `xml:"ResourceType"` // currently only auto-scaling-group is supported - not required if creating ASG
- Value string `xml:"Value"`
-}
-
-// AutoScalingGroup encapsulates an Auto Scaling Group object
-//
-// See http://goo.gl/fJdYhg for more details.
-type AutoScalingGroup struct {
- AutoScalingGroupARN string `xml:"AutoScalingGroupARN"`
- AutoScalingGroupName string `xml:"AutoScalingGroupName"`
- AvailabilityZones []string `xml:"AvailabilityZones>member"`
- CreatedTime time.Time `xml:"CreatedTime"`
- DefaultCooldown int `xml:"DefaultCooldown"`
- DesiredCapacity int `xml:"DesiredCapacity"`
- EnabledMetrics []EnabledMetric `xml:"EnabledMetric>member"`
- HealthCheckGracePeriod int `xml:"HealthCheckGracePeriod"`
- HealthCheckType string `xml:"HealthCheckType"`
- Instances []Instance `xml:"Instances>member"`
- LaunchConfigurationName string `xml:"LaunchConfigurationName"`
- LoadBalancerNames []string `xml:"LoadBalancerNames>member"`
- MaxSize int `xml:"MaxSize"`
- MinSize int `xml:"MinSize"`
- PlacementGroup string `xml:"PlacementGroup"`
- Status string `xml:"Status"`
- SuspendedProcesses []SuspendedProcess `xml:"SuspendedProcesses>member"`
- Tags []Tag `xml:"Tags>member"`
- TerminationPolicies []string `xml:"TerminationPolicies>member"`
- VPCZoneIdentifier string `xml:"VPCZoneIdentifier"`
-}
-
-// CreateAutoScalingGroupParams type encapsulates options for the respective request.
-//
-// See http://goo.gl/3S13Bv for more details.
-type CreateAutoScalingGroupParams struct {
- AutoScalingGroupName string
- AvailabilityZones []string
- DefaultCooldown int
- DesiredCapacity int
- HealthCheckGracePeriod int
- HealthCheckType string
- InstanceId string
- LaunchConfigurationName string
- LoadBalancerNames []string
- MaxSize int
- MinSize int
- PlacementGroup string
- Tags []Tag
- TerminationPolicies []string
- VPCZoneIdentifier string
-}
-
-// AttachInstances Attach running instances to an autoscaling group
-//
-// See http://goo.gl/zDZbuQ for more details.
-func (as *AutoScaling) AttachInstances(name string, instanceIds []string) (resp *SimpleResp, err error) {
- params := makeParams("AttachInstances")
- params["AutoScalingGroupName"] = name
-
- for i, id := range instanceIds {
- key := fmt.Sprintf("InstanceIds.member.%d", i+1)
- params[key] = id
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// CreateAutoScalingGroup creates an Auto Scaling Group on AWS
-//
-// Required params: AutoScalingGroupName, MinSize, MaxSize
-//
-// See http://goo.gl/3S13Bv for more details.
-func (as *AutoScaling) CreateAutoScalingGroup(options *CreateAutoScalingGroupParams) (
- resp *SimpleResp, err error) {
- params := makeParams("CreateAutoScalingGroup")
-
- params["AutoScalingGroupName"] = options.AutoScalingGroupName
- params["MaxSize"] = strconv.Itoa(options.MaxSize)
- params["MinSize"] = strconv.Itoa(options.MinSize)
- params["DesiredCapacity"] = strconv.Itoa(options.DesiredCapacity)
-
- if options.DefaultCooldown > 0 {
- params["DefaultCooldown"] = strconv.Itoa(options.DefaultCooldown)
- }
- if options.HealthCheckGracePeriod > 0 {
- params["HealthCheckGracePeriod"] = strconv.Itoa(options.HealthCheckGracePeriod)
- }
- if options.HealthCheckType != "" {
- params["HealthCheckType"] = options.HealthCheckType
- }
- if options.InstanceId != "" {
- params["InstanceId"] = options.InstanceId
- }
- if options.LaunchConfigurationName != "" {
- params["LaunchConfigurationName"] = options.LaunchConfigurationName
- }
- if options.PlacementGroup != "" {
- params["PlacementGroup"] = options.PlacementGroup
- }
- if options.VPCZoneIdentifier != "" {
- params["VPCZoneIdentifier"] = options.VPCZoneIdentifier
- }
- if len(options.LoadBalancerNames) > 0 {
- addParamsList(params, "LoadBalancerNames.member", options.LoadBalancerNames)
- }
- if len(options.AvailabilityZones) > 0 {
- addParamsList(params, "AvailabilityZones.member", options.AvailabilityZones)
- }
- if len(options.TerminationPolicies) > 0 {
- addParamsList(params, "TerminationPolicies.member", options.TerminationPolicies)
- }
- for i, t := range options.Tags {
- key := "Tags.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "Key")] = t.Key
- params[fmt.Sprintf(key, index, "Value")] = t.Value
- params[fmt.Sprintf(key, index, "PropagateAtLaunch")] = strconv.FormatBool(t.PropagateAtLaunch)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// EBS represents the AWS EBS volume data type
-//
-// See http://goo.gl/nDUL2h for more details
-type EBS struct {
- DeleteOnTermination bool `xml:"DeleteOnTermination"`
- Iops int `xml:"Iops"`
- SnapshotId string `xml:"SnapshotId"`
- VolumeSize int `xml:"VolumeSize"`
- VolumeType string `xml:"VolumeType"`
-}
-
-// BlockDeviceMapping represents the association of a block device with ebs volume.
-//
-// See http://goo.gl/wEGwkU for more details.
-type BlockDeviceMapping struct {
- DeviceName string `xml:"DeviceName"`
- Ebs EBS `xml:"Ebs"`
- NoDevice bool `xml:"NoDevice"`
- VirtualName string `xml:"VirtualName"`
-}
-
-// InstanceMonitoring data type
-//
-// See http://goo.gl/TfaPwz for more details
-type InstanceMonitoring struct {
- Enabled bool `xml:"Enabled"`
-}
-
-// LaunchConfiguration encapsulates the LaunchConfiguration Data Type
-//
-// See http://goo.gl/TOJunp
-type LaunchConfiguration struct {
- AssociatePublicIpAddress bool `xml:"AssociatePublicIpAddress"`
- BlockDeviceMappings []BlockDeviceMapping `xml:"BlockDeviceMappings>member"`
- CreatedTime time.Time `xml:"CreatedTime"`
- EbsOptimized bool `xml:"EbsOptimized"`
- IamInstanceProfile string `xml:"IamInstanceProfile"`
- ImageId string `xml:"ImageId"`
- InstanceId string `xml:"InstanceId"`
- InstanceMonitoring InstanceMonitoring `xml:"InstanceMonitoring"`
- InstanceType string `xml:"InstanceType"`
- KernelId string `xml:"KernelId"`
- KeyName string `xml:"KeyName"`
- LaunchConfigurationARN string `xml:"LaunchConfigurationARN"`
- LaunchConfigurationName string `xml:"LaunchConfigurationName"`
- RamdiskId string `xml:"RamdiskId"`
- SecurityGroups []string `xml:"SecurityGroups>member"`
- SpotPrice string `xml:"SpotPrice"`
- UserData string `xml:"UserData"`
-}
-
-// CreateLaunchConfiguration creates a launch configuration
-//
-// Required params: AutoScalingGroupName, MinSize, MaxSize
-//
-// See http://goo.gl/8e0BSF for more details.
-func (as *AutoScaling) CreateLaunchConfiguration(lc *LaunchConfiguration) (
- resp *SimpleResp, err error) {
-
- var b64 = base64.StdEncoding
-
- params := makeParams("CreateLaunchConfiguration")
- params["LaunchConfigurationName"] = lc.LaunchConfigurationName
-
- if lc.AssociatePublicIpAddress {
- params["AssociatePublicIpAddress"] = strconv.FormatBool(lc.AssociatePublicIpAddress)
- }
- if lc.EbsOptimized {
- params["EbsOptimized"] = strconv.FormatBool(lc.EbsOptimized)
- }
- if lc.IamInstanceProfile != "" {
- params["IamInstanceProfile"] = lc.IamInstanceProfile
- }
- if lc.ImageId != "" {
- params["ImageId"] = lc.ImageId
- }
- if lc.InstanceId != "" {
- params["InstanceId"] = lc.InstanceId
- }
- if lc.InstanceMonitoring != (InstanceMonitoring{}) {
- params["InstanceMonitoring.Enabled"] = strconv.FormatBool(lc.InstanceMonitoring.Enabled)
- }
- if lc.InstanceType != "" {
- params["InstanceType"] = lc.InstanceType
- }
- if lc.KernelId != "" {
- params["KernelId"] = lc.KernelId
- }
- if lc.KeyName != "" {
- params["KeyName"] = lc.KeyName
- }
- if lc.RamdiskId != "" {
- params["RamdiskId"] = lc.RamdiskId
- }
- if lc.SpotPrice != "" {
- params["SpotPrice"] = lc.SpotPrice
- }
- if lc.UserData != "" {
- params["UserData"] = b64.EncodeToString([]byte(lc.UserData))
- }
-
- // Add our block device mappings
- for i, bdm := range lc.BlockDeviceMappings {
- key := "BlockDeviceMappings.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "DeviceName")] = bdm.DeviceName
- params[fmt.Sprintf(key, index, "VirtualName")] = bdm.VirtualName
-
- if bdm.NoDevice {
- params[fmt.Sprintf(key, index, "NoDevice")] = "true"
- }
-
- if bdm.Ebs != (EBS{}) {
- key := "BlockDeviceMappings.member.%d.Ebs.%s"
-
- // Defaults to true
- params[fmt.Sprintf(key, index, "DeleteOnTermination")] = strconv.FormatBool(bdm.Ebs.DeleteOnTermination)
-
- if bdm.Ebs.Iops > 0 {
- params[fmt.Sprintf(key, index, "Iops")] = strconv.Itoa(bdm.Ebs.Iops)
- }
- if bdm.Ebs.SnapshotId != "" {
- params[fmt.Sprintf(key, index, "SnapshotId")] = bdm.Ebs.SnapshotId
- }
- if bdm.Ebs.VolumeSize > 0 {
- params[fmt.Sprintf(key, index, "VolumeSize")] = strconv.Itoa(bdm.Ebs.VolumeSize)
- }
- if bdm.Ebs.VolumeType != "" {
- params[fmt.Sprintf(key, index, "VolumeType")] = bdm.Ebs.VolumeType
- }
- }
- }
-
- if len(lc.SecurityGroups) > 0 {
- addParamsList(params, "SecurityGroups.member", lc.SecurityGroups)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// CreateOrUpdateTags creates or updates Auto Scaling Group Tags
-//
-// See http://goo.gl/e1UIXb for more details.
-func (as *AutoScaling) CreateOrUpdateTags(tags []Tag) (resp *SimpleResp, err error) {
- params := makeParams("CreateOrUpdateTags")
-
- for i, t := range tags {
- key := "Tags.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "Key")] = t.Key
- params[fmt.Sprintf(key, index, "Value")] = t.Value
- params[fmt.Sprintf(key, index, "PropagateAtLaunch")] = strconv.FormatBool(t.PropagateAtLaunch)
- params[fmt.Sprintf(key, index, "ResourceId")] = t.ResourceId
- if t.ResourceType != "" {
- params[fmt.Sprintf(key, index, "ResourceType")] = t.ResourceType
- } else {
- params[fmt.Sprintf(key, index, "ResourceType")] = "auto-scaling-group"
- }
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-type CompleteLifecycleActionParams struct {
- AutoScalingGroupName string
- LifecycleActionResult string
- LifecycleActionToken string
- LifecycleHookName string
-}
-
-// CompleteLifecycleAction completes the lifecycle action for the associated token initiated under the given lifecycle hook with the specified result.
-//
-// Part of the basic sequence for adding a lifecycle hook to an Auto Scaling group:
-// 1) Create a notification target (SQS queue || SNS Topic)
-// 2) Create an IAM role to allow the ASG topublish lifecycle notifications to the designated SQS queue or SNS topic
-// 3) Create the lifecycle hook. You can create a hook that acts when instances launch or when instances terminate
-// 4) If necessary, record the lifecycle action heartbeat to keep the instance in a pending state
-// 5) ***Complete the lifecycle action***
-//
-// See http://goo.gl/k4fl0p for more details
-func (as *AutoScaling) CompleteLifecycleAction(options *CompleteLifecycleActionParams) (
- resp *SimpleResp, err error) {
- params := makeParams("CompleteLifecycleAction")
-
- params["AutoScalingGroupName"] = options.AutoScalingGroupName
- params["LifecycleActionResult"] = options.LifecycleActionResult
- params["LifecycleActionToken"] = options.LifecycleActionToken
- params["LifecycleHookName"] = options.LifecycleHookName
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteAutoScalingGroup deletes an Auto Scaling Group
-//
-// See http://goo.gl/us7VSffor for more details.
-func (as *AutoScaling) DeleteAutoScalingGroup(asgName string, forceDelete bool) (
- resp *SimpleResp, err error) {
- params := makeParams("DeleteAutoScalingGroup")
- params["AutoScalingGroupName"] = asgName
-
- if forceDelete {
- params["ForceDelete"] = "true"
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteLaunchConfiguration deletes a Launch Configuration
-//
-// See http://goo.gl/xksfyR for more details.
-func (as *AutoScaling) DeleteLaunchConfiguration(name string) (resp *SimpleResp, err error) {
- params := makeParams("DeleteLaunchConfiguration")
- params["LaunchConfigurationName"] = name
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteLifecycleHook eletes the specified lifecycle hook.
-// If there are any outstanding lifecycle actions, they are completed first
-//
-// See http://goo.gl/MwX1vG for more details.
-func (as *AutoScaling) DeleteLifecycleHook(asgName, lifecycleHookName string) (resp *SimpleResp, err error) {
- params := makeParams("DeleteLifecycleHook")
- params["AutoScalingGroupName"] = asgName
- params["LifecycleHookName"] = lifecycleHookName
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteNotificationConfiguration deletes notifications created by PutNotificationConfiguration.
-//
-// See http://goo.gl/jTqoYz for more details
-func (as *AutoScaling) DeleteNotificationConfiguration(asgName string, topicARN string) (
- resp *SimpleResp, err error) {
- params := makeParams("DeleteNotificationConfiguration")
- params["AutoScalingGroupName"] = asgName
- params["TopicARN"] = topicARN
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeletePolicy deletes a policy created by PutScalingPolicy.
-//
-// policyName might be the policy name or ARN
-//
-// See http://goo.gl/aOQPH2 for more details
-func (as *AutoScaling) DeletePolicy(asgName string, policyName string) (resp *SimpleResp, err error) {
- params := makeParams("DeletePolicy")
- params["AutoScalingGroupName"] = asgName
- params["PolicyName"] = policyName
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteScheduledAction deletes a scheduled action previously created using the PutScheduledUpdateGroupAction.
-//
-// See http://goo.gl/Zss9CH for more details
-func (as *AutoScaling) DeleteScheduledAction(asgName string, scheduledActionName string) (resp *SimpleResp, err error) {
- params := makeParams("DeleteScheduledAction")
- params["AutoScalingGroupName"] = asgName
- params["ScheduledActionName"] = scheduledActionName
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteTags deletes autoscaling group tags
-//
-// See http://goo.gl/o8HzAk for more details.
-func (as *AutoScaling) DeleteTags(tags []Tag) (resp *SimpleResp, err error) {
- params := makeParams("DeleteTags")
-
- for i, t := range tags {
- key := "Tags.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "Key")] = t.Key
- params[fmt.Sprintf(key, index, "Value")] = t.Value
- params[fmt.Sprintf(key, index, "PropagateAtLaunch")] = strconv.FormatBool(t.PropagateAtLaunch)
- params[fmt.Sprintf(key, index, "ResourceId")] = t.ResourceId
- params[fmt.Sprintf(key, index, "ResourceType")] = "auto-scaling-group"
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-//DescribeAccountLimits response wrapper
-//
-// See http://goo.gl/tKsMN0 for more details.
-type DescribeAccountLimitsResp struct {
- MaxNumberOfAutoScalingGroups int `xml:"DescribeAccountLimitsResult>MaxNumberOfAutoScalingGroups"`
- MaxNumberOfLaunchConfigurations int `xml:"DescribeAccountLimitsResult>MaxNumberOfLaunchConfigurations"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeAccountLimits - Returns the limits for the Auto Scaling resources currently allowed for your AWS account.
-//
-// See http://goo.gl/tKsMN0 for more details.
-func (as *AutoScaling) DescribeAccountLimits() (resp *DescribeAccountLimitsResp, err error) {
- params := makeParams("DescribeAccountLimits")
-
- resp = new(DescribeAccountLimitsResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// AdjustmentType specifies whether the PutScalingPolicy ScalingAdjustment parameter is an absolute number or a percentage of the current capacity.
-//
-// See http://goo.gl/tCFqeL for more details
-type AdjustmentType struct {
- AdjustmentType string //Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.
-}
-
-//DescribeAdjustmentTypes response wrapper
-//
-// See http://goo.gl/hGx3Pc for more details.
-type DescribeAdjustmentTypesResp struct {
- AdjustmentTypes []AdjustmentType `xml:"DescribeAdjustmentTypesResult>AdjustmentTypes>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeAdjustmentTypes returns policy adjustment types for use in the PutScalingPolicy action.
-//
-// See http://goo.gl/hGx3Pc for more details.
-func (as *AutoScaling) DescribeAdjustmentTypes() (resp *DescribeAdjustmentTypesResp, err error) {
- params := makeParams("DescribeAdjustmentTypes")
-
- resp = new(DescribeAdjustmentTypesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeAutoScalingGroups response wrapper
-//
-// See http://goo.gl/nW74Ut for more details.
-type DescribeAutoScalingGroupsResp struct {
- AutoScalingGroups []AutoScalingGroup `xml:"DescribeAutoScalingGroupsResult>AutoScalingGroups>member"`
- NextToken string `xml:"DescribeAutoScalingGroupsResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeAutoScalingGroups returns a full description of each Auto Scaling group in the given list
-// If no autoscaling groups are provided, returns the details of all autoscaling groups
-// Supports pagination by using the returned "NextToken" parameter for subsequent calls
-//
-// See http://goo.gl/nW74Ut for more details.
-func (as *AutoScaling) DescribeAutoScalingGroups(names []string, maxRecords int, nextToken string) (
- resp *DescribeAutoScalingGroupsResp, err error) {
- params := makeParams("DescribeAutoScalingGroups")
-
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
- if len(names) > 0 {
- addParamsList(params, "AutoScalingGroupNames.member", names)
- }
-
- resp = new(DescribeAutoScalingGroupsResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeAutoScalingInstances response wrapper
-//
-// See http://goo.gl/ckzORt for more details.
-type DescribeAutoScalingInstancesResp struct {
- AutoScalingInstances []Instance `xml:"DescribeAutoScalingInstancesResult>AutoScalingInstances>member"`
- NextToken string `xml:"DescribeAutoScalingInstancesResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeAutoScalingInstances returns a description of each Auto Scaling instance in the InstanceIds list.
-// If a list is not provided, the service returns the full details of all instances up to a maximum of 50
-// By default, the service returns a list of 20 items.
-// Supports pagination by using the returned "NextToken" parameter for subsequent calls
-//
-// See http://goo.gl/ckzORt for more details.
-func (as *AutoScaling) DescribeAutoScalingInstances(ids []string, maxRecords int, nextToken string) (
- resp *DescribeAutoScalingInstancesResp, err error) {
- params := makeParams("DescribeAutoScalingInstances")
-
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
- if len(ids) > 0 {
- addParamsList(params, "InstanceIds.member", ids)
- }
-
- resp = new(DescribeAutoScalingInstancesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeAutoScalingNotificationTypes response wrapper
-//
-// See http://goo.gl/pmLIoE for more details.
-type DescribeAutoScalingNotificationTypesResp struct {
- AutoScalingNotificationTypes []string `xml:"DescribeAutoScalingNotificationTypesResult>AutoScalingNotificationTypes>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeAutoScalingNotificationTypes returns a list of all notification types that are supported by Auto Scaling
-//
-// See http://goo.gl/pmLIoE for more details.
-func (as *AutoScaling) DescribeAutoScalingNotificationTypes() (resp *DescribeAutoScalingNotificationTypesResp, err error) {
- params := makeParams("DescribeAutoScalingNotificationTypes")
-
- resp = new(DescribeAutoScalingNotificationTypesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeLaunchConfigurationResp defines the basic response structure for launch configuration
-// requests
-//
-// See http://goo.gl/y31YYE for more details.
-type DescribeLaunchConfigurationsResp struct {
- LaunchConfigurations []LaunchConfiguration `xml:"DescribeLaunchConfigurationsResult>LaunchConfigurations>member"`
- NextToken string `xml:"DescribeLaunchConfigurationsResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeLaunchConfigurations returns details about the launch configurations supplied in
-// the list. If the list is nil, information is returned about all launch configurations in the
-// region.
-//
-// See http://goo.gl/y31YYE for more details.
-func (as *AutoScaling) DescribeLaunchConfigurations(names []string, maxRecords int, nextToken string) (
- resp *DescribeLaunchConfigurationsResp, err error) {
- params := makeParams("DescribeLaunchConfigurations")
-
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
- if len(names) > 0 {
- addParamsList(params, "LaunchConfigurationNames.member", names)
- }
-
- resp = new(DescribeLaunchConfigurationsResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
-
- return resp, nil
-}
-
-// DescribeLifecycleHookTypesResult wraps a DescribeLifecycleHookTypes response
-//
-// See http://goo.gl/qiAH31 for more details.
-type DescribeLifecycleHookTypesResult struct {
- LifecycleHookTypes []string `xml:"DescribeLifecycleHookTypesResult>LifecycleHookTypes>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeLifecycleHookTypes describes the available types of lifecycle hooks
-//
-// See http://goo.gl/E9IBtY for more information
-func (as *AutoScaling) DescribeLifecycleHookTypes() (
- resp *DescribeLifecycleHookTypesResult, err error) {
- params := makeParams("DescribeLifecycleHookTypes")
-
- resp = new(DescribeLifecycleHookTypesResult)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// LifecycleHook represents a lifecyclehook object
-//
-// See http://goo.gl/j62Iqu for more information
-type LifecycleHook struct {
- AutoScalingGroupName string `xml:"AutoScalingGroupName"`
- DefaultResult string `xml:"DefaultResult"`
- GlobalTimeout int `xml:"GlobalTimeout"`
- HeartbeatTimeout int `xml:"HeartbeatTimeout"`
- LifecycleHookName string `xml:"LifecycleHookName"`
- LifecycleTransition string `xml:"LifecycleTransition"`
- NotificationMetadata string `xml:"NotificationMetadata"`
- NotificationTargetARN string `xml:"NotificationTargetARN"`
- RoleARN string `xml:"RoleARN"`
-}
-
-// DescribeLifecycleHooks wraps a DescribeLifecycleHooks response
-//
-// See http://goo.gl/wQkWiz for more details.
-type DescribeLifecycleHooksResult struct {
- LifecycleHooks []string `xml:"DescribeLifecycleHooksResult>LifecycleHooks>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeLifecycleHooks describes the lifecycle hooks that currently belong to the specified Auto Scaling group
-//
-// See http://goo.gl/wQkWiz for more information
-func (as *AutoScaling) DescribeLifecycleHooks(asgName string, hookNames []string) (
- resp *DescribeLifecycleHooksResult, err error) {
- params := makeParams("DescribeLifecycleHooks")
- params["AutoScalingGroupName"] = asgName
-
- if len(hookNames) > 0 {
- addParamsList(params, "LifecycleHookNames.member", hookNames)
- }
-
- resp = new(DescribeLifecycleHooksResult)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// MetricGranularity encapsulates the MetricGranularityType
-//
-// See http://goo.gl/WJ82AA for more details
-type MetricGranularity struct {
- Granularity string `xml:"Granularity"`
-}
-
-//MetricCollection encapsulates the MetricCollectionType
-//
-// See http://goo.gl/YrEG6h for more details
-type MetricCollection struct {
- Metric string `xml:"Metric"`
-}
-
-// DescribeMetricCollectionTypesResp response wrapper
-//
-// See http://goo.gl/UyYc3i for more details.
-type DescribeMetricCollectionTypesResp struct {
- Granularities []MetricGranularity `xml:"DescribeMetricCollectionTypesResult>Granularities>member"`
- Metrics []MetricCollection `xml:"DescribeMetricCollectionTypesResult>Metrics>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeMetricCollectionTypes returns a list of metrics and a corresponding list of granularities for each metric
-//
-// See http://goo.gl/UyYc3i for more details.
-func (as *AutoScaling) DescribeMetricCollectionTypes() (resp *DescribeMetricCollectionTypesResp, err error) {
- params := makeParams("DescribeMetricCollectionTypes")
-
- resp = new(DescribeMetricCollectionTypesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// NotificationConfiguration encapsulates the NotificationConfigurationType
-//
-// See http://goo.gl/M8xYOQ for more details
-type NotificationConfiguration struct {
- AutoScalingGroupName string `xml:"AutoScalingGroupName"`
- NotificationType string `xml:"NotificationType"`
- TopicARN string `xml:"TopicARN"`
-}
-
-// DescribeNotificationConfigurations response wrapper
-//
-// See http://goo.gl/qiAH31 for more details.
-type DescribeNotificationConfigurationsResp struct {
- NotificationConfigurations []NotificationConfiguration `xml:"DescribeNotificationConfigurationsResult>NotificationConfigurations>member"`
- NextToken string `xml:"DescribeNotificationConfigurationsResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeNotificationConfigurations returns a list of notification actions associated with Auto Scaling groups for specified events.
-// Supports pagination by using the returned "NextToken" parameter for subsequent calls
-//
-// http://goo.gl/qiAH31 for more details.
-func (as *AutoScaling) DescribeNotificationConfigurations(asgNames []string, maxRecords int, nextToken string) (
- resp *DescribeNotificationConfigurationsResp, err error) {
- params := makeParams("DescribeNotificationConfigurations")
-
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
- if len(asgNames) > 0 {
- addParamsList(params, "AutoScalingGroupNames.member", asgNames)
- }
-
- resp = new(DescribeNotificationConfigurationsResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Alarm encapsulates the Alarm data type.
-//
-// See http://goo.gl/Q0uPAB for more details
-type Alarm struct {
- AlarmARN string `xml:"AlarmARN"`
- AlarmName string `xml:"AlarmName"`
-}
-
-// ScalingPolicy encapsulates the ScalingPolicyType
-//
-// See http://goo.gl/BYAT18 for more details
-type ScalingPolicy struct {
- AdjustmentType string `xml:"AdjustmentType"` // ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity
- Alarms []Alarm `xml:"Alarms>member"` // A list of CloudWatch Alarms related to the policy
- AutoScalingGroupName string `xml:"AutoScalingGroupName"`
- Cooldown int `xml:"Cooldown"`
- MinAdjustmentStep int `xml:"MinAdjustmentStep"` // Changes the DesiredCapacity of ASG by at least the specified number of instances.
- PolicyARN string `xml:"PolicyARN"`
- PolicyName string `xml:"PolicyName"`
- ScalingAdjustment int `xml:"ScalingAdjustment"`
-}
-
-// DescribePolicies response wrapper
-//
-// http://goo.gl/bN7A9T for more details.
-type DescribePoliciesResp struct {
- ScalingPolicies []ScalingPolicy `xml:"DescribePoliciesResult>ScalingPolicies>member"`
- NextToken string `xml:"DescribePoliciesResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribePolicies returns descriptions of what each policy does.
-// Supports pagination by using the returned "NextToken" parameter for subsequent calls
-//
-// http://goo.gl/bN7A9Tfor more details.
-func (as *AutoScaling) DescribePolicies(asgName string, policyNames []string, maxRecords int, nextToken string) (
- resp *DescribePoliciesResp, err error) {
- params := makeParams("DescribePolicies")
-
- if asgName != "" {
- params["AutoScalingGroupName"] = asgName
- }
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
- if len(policyNames) > 0 {
- addParamsList(params, "PolicyNames.member", policyNames)
- }
-
- resp = new(DescribePoliciesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Activity encapsulates the Activity data type
-//
-// See http://goo.gl/fRaVi1 for more details
-type Activity struct {
- ActivityId string `xml:"ActivityId"`
- AutoScalingGroupName string `xml:"AutoScalingGroupName"`
- Cause string `xml:"Cause"`
- Description string `xml:"Description"`
- Details string `xml:"Details"`
- EndTime time.Time `xml:"EndTime"`
- Progress int `xml:"Progress"`
- StartTime time.Time `xml:"StartTime"`
- StatusCode string `xml:"StatusCode"`
- StatusMessage string `xml:"StatusMessage"`
-}
-
-// DescribeScalingActivities response wrapper
-//
-// http://goo.gl/noOXIC for more details.
-type DescribeScalingActivitiesResp struct {
- Activities []Activity `xml:"DescribeScalingActivitiesResult>Activities>member"`
- NextToken string `xml:"DescribeScalingActivitiesResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeScalingActivities returns the scaling activities for the specified Auto Scaling group.
-// Supports pagination by using the returned "NextToken" parameter for subsequent calls
-//
-// http://goo.gl/noOXIC more details.
-func (as *AutoScaling) DescribeScalingActivities(asgName string, activityIds []string, maxRecords int, nextToken string) (
- resp *DescribeScalingActivitiesResp, err error) {
- params := makeParams("DescribeScalingActivities")
-
- if asgName != "" {
- params["AutoScalingGroupName"] = asgName
- }
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
- if len(activityIds) > 0 {
- addParamsList(params, "ActivityIds.member", activityIds)
- }
-
- resp = new(DescribeScalingActivitiesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ProcessType encapsulates the Auto Scaling process data type
-//
-// See http://goo.gl/9BvNik for more details.
-type ProcessType struct {
- ProcessName string `xml:"ProcessName"`
-}
-
-// DescribeScalingProcessTypes response wrapper
-//
-// See http://goo.gl/rkp2tw for more details.
-type DescribeScalingProcessTypesResp struct {
- Processes []ProcessType `xml:"DescribeScalingProcessTypesResult>Processes>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeScalingProcessTypes returns scaling process types for use in the ResumeProcesses and SuspendProcesses actions.
-//
-// See http://goo.gl/rkp2tw for more details.
-func (as *AutoScaling) DescribeScalingProcessTypes() (resp *DescribeScalingProcessTypesResp, err error) {
- params := makeParams("DescribeScalingProcessTypes")
-
- resp = new(DescribeScalingProcessTypesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ScheduledUpdateGroupAction contains the information to be used in a scheduled update to an
-// AutoScalingGroup
-//
-// See http://goo.gl/z2Kfxe for more details
-type ScheduledUpdateGroupAction struct {
- AutoScalingGroupName string `xml:"AutoScalingGroupName"`
- DesiredCapacity int `xml:"DesiredCapacity"`
- EndTime time.Time `xml:"EndTime"`
- MaxSize int `xml:"MaxSize"`
- MinSize int `xml:"MinSize"`
- Recurrence string `xml:"Recurrence"`
- ScheduledActionARN string `xml:"ScheduledActionARN"`
- ScheduledActionName string `xml:"ScheduledActionName"`
- StartTime time.Time `xml:"StartTime"`
- Time time.Time `xml:"Time"`
-}
-
-// DescribeScheduledActionsResult contains the response from a DescribeScheduledActions.
-//
-// See http://goo.gl/zqrJLx for more details.
-type DescribeScheduledActionsResult struct {
- ScheduledUpdateGroupActions []ScheduledUpdateGroupAction `xml:"DescribeScheduledActionsResult>ScheduledUpdateGroupActions>member"`
- NextToken string `xml:"DescribeScheduledActionsResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ScheduledActionsRequestParams contains the items that can be specified when making
-// a ScheduledActions request
-type DescribeScheduledActionsParams struct {
- AutoScalingGroupName string
- EndTime time.Time
- MaxRecords int
- ScheduledActionNames []string
- StartTime time.Time
- NextToken string
-}
-
-// DescribeScheduledActions returns a list of the current scheduled actions. If the
-// AutoScalingGroup name is provided it will list all the scheduled actions for that group.
-//
-// See http://goo.gl/zqrJLx for more details.
-func (as *AutoScaling) DescribeScheduledActions(options *DescribeScheduledActionsParams) (
- resp *DescribeScheduledActionsResult, err error) {
- params := makeParams("DescribeScheduledActions")
-
- if options.AutoScalingGroupName != "" {
- params["AutoScalingGroupName"] = options.AutoScalingGroupName
- }
- if !options.StartTime.IsZero() {
- params["StartTime"] = options.StartTime.Format(time.RFC3339)
- }
- if !options.EndTime.IsZero() {
- params["EndTime"] = options.EndTime.Format(time.RFC3339)
- }
- if options.MaxRecords > 0 {
- params["MaxRecords"] = strconv.Itoa(options.MaxRecords)
- }
- if options.NextToken != "" {
- params["NextToken"] = options.NextToken
- }
- if len(options.ScheduledActionNames) > 0 {
- addParamsList(params, "ScheduledActionNames.member", options.ScheduledActionNames)
- }
-
- resp = new(DescribeScheduledActionsResult)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeTags response wrapper
-//
-// See http://goo.gl/ZTEU3G for more details.
-type DescribeTagsResp struct {
- Tags []Tag `xml:"DescribeTagsResult>Tags>member"`
- NextToken string `xml:"DescribeTagsResult>NextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeTags lists the Auto Scaling group tags.
-// Supports pagination by using the returned "NextToken" parameter for subsequent calls
-//
-// See http://goo.gl/ZTEU3G for more details.
-func (as *AutoScaling) DescribeTags(filter *Filter, maxRecords int, nextToken string) (
- resp *DescribeTagsResp, err error) {
- params := makeParams("DescribeTags")
-
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- filter.addParams(params)
-
- resp = new(DescribeTagsResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeTerminationPolicyTypes response wrapper
-//
-// See http://goo.gl/ZTEU3G for more details.
-type DescribeTerminationPolicyTypesResp struct {
- TerminationPolicyTypes []string `xml:"DescribeTerminationPolicyTypesResult>TerminationPolicyTypes>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeTerminationPolicyTypes returns a list of all termination policies supported by Auto Scaling
-//
-// See http://goo.gl/ZTEU3G for more details.
-func (as *AutoScaling) DescribeTerminationPolicyTypes() (resp *DescribeTerminationPolicyTypesResp, err error) {
- params := makeParams("DescribeTerminationPolicyTypes")
-
- resp = new(DescribeTerminationPolicyTypesResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DetachInstancesResult wraps a DetachInstances response
-type DetachInstancesResult struct {
- Activities []Activity `xml:"DetachInstancesResult>Activities>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DetachInstances removes an instance from an Auto Scaling group
-//
-// See http://goo.gl/cNwrqF for more details
-func (as *AutoScaling) DetachInstances(asgName string, instanceIds []string, decrementCapacity bool) (
- resp *DetachInstancesResult, err error) {
- params := makeParams("DetachInstances")
- params["AutoScalingGroupName"] = asgName
- params["ShouldDecrementDesiredCapacity"] = strconv.FormatBool(decrementCapacity)
-
- if len(instanceIds) > 0 {
- addParamsList(params, "InstanceIds.member", instanceIds)
- }
-
- resp = new(DetachInstancesResult)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DisableMetricsCollection disables monitoring of group metrics for the Auto Scaling group specified in asgName.
-// You can specify the list of affected metrics with the metrics parameter. If no metrics are specified, all metrics are disabled
-//
-// See http://goo.gl/kAvzQw for more details.
-func (as *AutoScaling) DisableMetricsCollection(asgName string, metrics []string) (
- resp *SimpleResp, err error) {
- params := makeParams("DisableMetricsCollection")
- params["AutoScalingGroupName"] = asgName
-
- if len(metrics) > 0 {
- addParamsList(params, "Metrics.member", metrics)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// EnableMetricsCollection enables monitoring of group metrics for the Auto Scaling group specified in asNmae.
-// You can specify the list of affected metrics with the metrics parameter.
-// Auto Scaling metrics collection can be turned on only if the InstanceMonitoring flag is set to true.
-// Currently, the only legal granularity is "1Minute".
-//
-// See http://goo.gl/UcVDWn for more details.
-func (as *AutoScaling) EnableMetricsCollection(asgName string, metrics []string, granularity string) (
- resp *SimpleResp, err error) {
- params := makeParams("EnableMetricsCollection")
- params["AutoScalingGroupName"] = asgName
- params["Granularity"] = granularity
-
- if len(metrics) > 0 {
- addParamsList(params, "Metrics.member", metrics)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// EnterStandbyResult wraps an EnterStandby response
-type EnterStandbyResult struct {
- Activities []Activity `xml:"EnterStandbyResult>Activities>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// EnterStandby moves instances in an Auto Scaling group into a Standby mode.
-//
-// See http://goo.gl/BJ3lXs for more information
-func (as *AutoScaling) EnterStandby(asgName string, instanceIds []string, decrementCapacity bool) (
- resp *EnterStandbyResult, err error) {
- params := makeParams("EnterStandby")
- params["AutoScalingGroupName"] = asgName
- params["ShouldDecrementDesiredCapacity"] = strconv.FormatBool(decrementCapacity)
-
- if len(instanceIds) > 0 {
- addParamsList(params, "InstanceIds.member", instanceIds)
- }
-
- resp = new(EnterStandbyResult)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ExecutePolicy executes the specified policy.
-//
-// See http://goo.gl/BxHpFc for more details.
-func (as *AutoScaling) ExecutePolicy(policyName string, asgName string, honorCooldown bool) (
- resp *SimpleResp, err error) {
- params := makeParams("ExecutePolicy")
- params["PolicyName"] = policyName
-
- if asgName != "" {
- params["AutoScalingGroupName"] = asgName
- }
- if honorCooldown {
- params["HonorCooldown"] = strconv.FormatBool(honorCooldown)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ExitStandbyResult wraps an ExitStandby response
-type ExitStandbyResult struct {
- Activities []Activity `xml:"ExitStandbyResult>Activities>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ExitStandby moves an instance out of Standby mode.
-//
-// See http://goo.gl/9zQV4G for more information
-func (as *AutoScaling) ExitStandby(asgName string, instanceIds []string) (
- resp *ExitStandbyResult, err error) {
- params := makeParams("ExitStandby")
- params["AutoScalingGroupName"] = asgName
-
- if len(instanceIds) > 0 {
- addParamsList(params, "InstanceIds.member", instanceIds)
- }
-
- resp = new(ExitStandbyResult)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// PutLifecycleHookParams wraps a PutLifecycleHook request
-//
-// See http://goo.gl/zsNqp5 for more details
-type PutLifecycleHookParams struct {
- AutoScalingGroupName string
- DefaultResult string
- HeartbeatTimeout int
- LifecycleHookName string
- LifecycleTransition string
- NotificationMetadata string
- NotificationTargetARN string
- RoleARN string
-}
-
-// PutLifecycleHook Creates or updates a lifecycle hook for an Auto Scaling Group.
-//
-// Part of the basic sequence for adding a lifecycle hook to an Auto Scaling group:
-// 1) Create a notification target (SQS queue || SNS Topic)
-// 2) Create an IAM role to allow the ASG topublish lifecycle notifications to the designated SQS queue or SNS topic
-// 3) *** Create the lifecycle hook. You can create a hook that acts when instances launch or when instances terminate***
-// 4) If necessary, record the lifecycle action heartbeat to keep the instance in a pending state
-// 5) Complete the lifecycle action
-//
-// See http://goo.gl/9XrROq for more details.
-func (as *AutoScaling) PutLifecycleHook(options *PutLifecycleHookParams) (
- resp *SimpleResp, err error) {
- params := makeParams("PutLifecycleHook")
- params["AutoScalingGroupName"] = options.AutoScalingGroupName
- params["LifecycleHookName"] = options.LifecycleHookName
-
- if options.DefaultResult != "" {
- params["DefaultResult"] = options.DefaultResult
- }
- if options.HeartbeatTimeout != 0 {
- params["HeartbeatTimeout"] = strconv.Itoa(options.HeartbeatTimeout)
- }
- if options.LifecycleTransition != "" {
- params["LifecycleTransition"] = options.LifecycleTransition
- }
- if options.NotificationMetadata != "" {
- params["NotificationMetadata"] = options.NotificationMetadata
- }
- if options.NotificationTargetARN != "" {
- params["NotificationTargetARN"] = options.NotificationTargetARN
- }
- if options.RoleARN != "" {
- params["RoleARN"] = options.RoleARN
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// PutNotificationConfiguration configures an Auto Scaling group to send notifications when specified events take place.
-//
-// See http://goo.gl/9XrROq for more details.
-func (as *AutoScaling) PutNotificationConfiguration(asgName string, notificationTypes []string, topicARN string) (
- resp *SimpleResp, err error) {
- params := makeParams("PutNotificationConfiguration")
- params["AutoScalingGroupName"] = asgName
- params["TopicARN"] = topicARN
-
- if len(notificationTypes) > 0 {
- addParamsList(params, "NotificationTypes.member", notificationTypes)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// PutScalingPolicyParams wraps a PutScalingPolicyParams request
-//
-// See http://goo.gl/o0E8hl for more details.
-type PutScalingPolicyParams struct {
- AutoScalingGroupName string
- PolicyName string
- ScalingAdjustment int
- AdjustmentType string
- Cooldown int
- MinAdjustmentStep int
-}
-
-// PutScalingPolicy response wrapper
-//
-// See http://goo.gl/o0E8hl for more details.
-type PutScalingPolicyResp struct {
- PolicyARN string `xml:"PutScalingPolicyResult>PolicyARN"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// PutScalingPolicy creates or updates a policy for an Auto Scaling group
-//
-// See http://goo.gl/o0E8hl for more details.
-func (as *AutoScaling) PutScalingPolicy(options *PutScalingPolicyParams) (
- resp *PutScalingPolicyResp, err error) {
- params := makeParams("PutScalingPolicy")
- params["AutoScalingGroupName"] = options.AutoScalingGroupName
- params["PolicyName"] = options.PolicyName
- params["ScalingAdjustment"] = strconv.Itoa(options.ScalingAdjustment)
- params["AdjustmentType"] = options.AdjustmentType
-
- if options.Cooldown != 0 {
- params["Cooldown"] = strconv.Itoa(options.Cooldown)
- }
- if options.MinAdjustmentStep != 0 {
- params["MinAdjustmentStep"] = strconv.Itoa(options.MinAdjustmentStep)
- }
-
- resp = new(PutScalingPolicyResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// PutScheduledUpdateGroupActionParams contains the details of the ScheduledAction to be added.
-//
-// See http://goo.gl/sLPi0d for more details
-type PutScheduledUpdateGroupActionParams struct {
- AutoScalingGroupName string
- DesiredCapacity int
- EndTime time.Time
- MaxSize int
- MinSize int
- Recurrence string
- ScheduledActionName string
- StartTime time.Time
-}
-
-// PutScheduledUpdateGroupAction creates or updates a scheduled scaling action for an
-// AutoScaling group. Scheduled actions can be made up to thirty days in advance. When updating
-// a scheduled scaling action, if you leave a parameter unspecified, the corresponding value
-// remains unchanged in the affected AutoScaling group.
-//
-// Auto Scaling supports the date and time expressed in "YYYY-MM-DDThh:mm:ssZ" format in UTC/GMT
-// only.
-//
-// See http://goo.gl/sLPi0d for more details.
-func (as *AutoScaling) PutScheduledUpdateGroupAction(options *PutScheduledUpdateGroupActionParams) (
- resp *SimpleResp, err error) {
- params := makeParams("PutScheduledUpdateGroupAction")
- params["AutoScalingGroupName"] = options.AutoScalingGroupName
- params["ScheduledActionName"] = options.ScheduledActionName
- params["MinSize"] = strconv.Itoa(options.MinSize)
- params["MaxSize"] = strconv.Itoa(options.MaxSize)
- params["DesiredCapacity"] = strconv.Itoa(options.DesiredCapacity)
-
- if !options.StartTime.IsZero() {
- params["StartTime"] = options.StartTime.Format(time.RFC3339)
- }
- if !options.EndTime.IsZero() {
- params["EndTime"] = options.EndTime.Format(time.RFC3339)
- }
- if options.Recurrence != "" {
- params["Recurrence"] = options.Recurrence
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// RecordLifecycleActionHeartbeat ecords a heartbeat for the lifecycle action associated with a specific token.
-// This extends the timeout by the length of time defined by the HeartbeatTimeout parameter of the
-// PutLifecycleHook operation.
-//
-// Part of the basic sequence for adding a lifecycle hook to an Auto Scaling group:
-// 1) Create a notification target (SQS queue || SNS Topic)
-// 2) Create an IAM role to allow the ASG topublish lifecycle notifications to the designated SQS queue or SNS topic
-// 3) Create the lifecycle hook. You can create a hook that acts when instances launch or when instances terminate
-// 4) ***If necessary, record the lifecycle action heartbeat to keep the instance in a pending state***
-// 5) Complete the lifecycle action
-//
-// See http://goo.gl/jc70xp for more details.
-func (as *AutoScaling) RecordLifecycleActionHeartbeat(asgName, lifecycleActionToken, hookName string) (
- resp *SimpleResp, err error) {
- params := makeParams("RecordLifecycleActionHeartbeat")
- params["AutoScalingGroupName"] = asgName
- params["LifecycleActionToken"] = lifecycleActionToken
- params["LifecycleHookName"] = hookName
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ResumeProcesses resumes the scaling processes for the scaling group. If no processes are
-// provided, all processes are resumed.
-//
-// See http://goo.gl/XWIIg1 for more details.
-func (as *AutoScaling) ResumeProcesses(asgName string, processes []string) (
- resp *SimpleResp, err error) {
- params := makeParams("ResumeProcesses")
- params["AutoScalingGroupName"] = asgName
-
- if len(processes) > 0 {
- addParamsList(params, "ScalingProcesses.member", processes)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// SetDesiredCapacity changes the DesiredCapacity of an AutoScaling group.
-//
-// See http://goo.gl/3WGZbI for more details.
-func (as *AutoScaling) SetDesiredCapacity(asgName string, desiredCapacity int, honorCooldown bool) (
- resp *SimpleResp, err error) {
- params := makeParams("SetDesiredCapacity")
- params["AutoScalingGroupName"] = asgName
- params["DesiredCapacity"] = strconv.Itoa(desiredCapacity)
- params["HonorCooldown"] = strconv.FormatBool(honorCooldown)
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// SetInstanceHealth sets the health status of a specified instance that belongs to any of your Auto Scaling groups.
-//
-// See http://goo.gl/j4ZRxh for more details.
-func (as *AutoScaling) SetInstanceHealth(id string, healthStatus string, respectGracePeriod bool) (
- resp *SimpleResp, err error) {
- params := makeParams("SetInstanceHealth")
- params["HealthStatus"] = healthStatus
- params["InstanceId"] = id
- // Default is true
- params["ShouldRespectGracePeriod"] = strconv.FormatBool(respectGracePeriod)
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// SuspendProcesses suspends the processes for the autoscaling group. If no processes are
-// provided, all processes are suspended.
-//
-// If you suspend either of the two primary processes (Launch or Terminate), this can prevent other
-// process types from functioning properly.
-//
-// See http://goo.gl/DUJpQy for more details.
-func (as *AutoScaling) SuspendProcesses(asgName string, processes []string) (
- resp *SimpleResp, err error) {
- params := makeParams("SuspendProcesses")
- params["AutoScalingGroupName"] = asgName
-
- if len(processes) > 0 {
- addParamsList(params, "ScalingProcesses.member", processes)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// TerminateInstanceInAutoScalingGroupResp response wrapper
-//
-// See http://goo.gl/ki5hMh for more details.
-type TerminateInstanceInAutoScalingGroupResp struct {
- Activity Activity `xml:"TerminateInstanceInAutoScalingGroupResult>Activity"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// TerminateInstanceInAutoScalingGroup terminates the specified instance.
-// Optionally, the desired group size can be adjusted by setting decrCap to true
-//
-// See http://goo.gl/ki5hMh for more details.
-func (as *AutoScaling) TerminateInstanceInAutoScalingGroup(id string, decrCap bool) (
- resp *TerminateInstanceInAutoScalingGroupResp, err error) {
- params := makeParams("TerminateInstanceInAutoScalingGroup")
- params["InstanceId"] = id
- params["ShouldDecrementDesiredCapacity"] = strconv.FormatBool(decrCap)
-
- resp = new(TerminateInstanceInAutoScalingGroupResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// UpdateAutoScalingGroup updates the scaling group.
-//
-// To update an auto scaling group with a launch configuration that has the InstanceMonitoring
-// flag set to False, you must first ensure that collection of group metrics is disabled.
-// Otherwise calls to UpdateAutoScalingGroup will fail.
-//
-// See http://goo.gl/rqrmxy for more details.
-func (as *AutoScaling) UpdateAutoScalingGroup(asg *AutoScalingGroup) (resp *SimpleResp, err error) {
- params := makeParams("UpdateAutoScalingGroup")
-
- params["AutoScalingGroupName"] = asg.AutoScalingGroupName
- params["MaxSize"] = strconv.Itoa(asg.MaxSize)
- params["MinSize"] = strconv.Itoa(asg.MinSize)
- params["DesiredCapacity"] = strconv.Itoa(asg.DesiredCapacity)
-
- if asg.DefaultCooldown > 0 {
- params["DefaultCooldown"] = strconv.Itoa(asg.DefaultCooldown)
- }
- if asg.HealthCheckGracePeriod > 0 {
- params["HealthCheckGracePeriod"] = strconv.Itoa(asg.HealthCheckGracePeriod)
- }
- if asg.HealthCheckType != "" {
- params["HealthCheckType"] = asg.HealthCheckType
- }
- if asg.LaunchConfigurationName != "" {
- params["LaunchConfigurationName"] = asg.LaunchConfigurationName
- }
- if asg.PlacementGroup != "" {
- params["PlacementGroup"] = asg.PlacementGroup
- }
- if asg.VPCZoneIdentifier != "" {
- params["VPCZoneIdentifier"] = asg.VPCZoneIdentifier
- }
-
- if len(asg.AvailabilityZones) > 0 {
- addParamsList(params, "AvailabilityZones.member", asg.AvailabilityZones)
- }
- if len(asg.TerminationPolicies) > 0 {
- addParamsList(params, "TerminationPolicies.member", asg.TerminationPolicies)
- }
-
- resp = new(SimpleResp)
- if err := as.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
diff --git a/vendor/github.com/goamz/goamz/autoscaling/autoscaling_test.go b/vendor/github.com/goamz/goamz/autoscaling/autoscaling_test.go
deleted file mode 100644
index b728a1cf4..000000000
--- a/vendor/github.com/goamz/goamz/autoscaling/autoscaling_test.go
+++ /dev/null
@@ -1,1180 +0,0 @@
-package autoscaling
-
-import (
- "testing"
- "time"
-
- . "gopkg.in/check.v1"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/testutil"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- as *AutoScaling
-}
-
-var testServer = testutil.NewHTTPServer()
-
-var mockTest bool
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.as = New(auth, aws.Region{AutoScalingEndpoint: testServer.URL})
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func TestBasicGroupRequest(t *testing.T) {
- var as *AutoScaling
- awsAuth, err := aws.EnvAuth()
- if err != nil {
- mockTest = true
- t.Log("Running mock tests as AWS environment variables are not set")
- awsAuth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- as = New(awsAuth, aws.Region{AutoScalingEndpoint: testServer.URL})
- testServer.Start()
- go testServer.WaitRequest()
- testServer.Response(200, nil, BasicGroupResponse)
- } else {
- as = New(awsAuth, aws.USWest2)
- }
-
- groupResp, err := as.DescribeAutoScalingGroups(nil, 10, "")
-
- if err != nil {
- t.Fatal(err)
- }
- if len(groupResp.AutoScalingGroups) > 0 {
- firstGroup := groupResp.AutoScalingGroups[0]
- if len(firstGroup.AutoScalingGroupName) > 0 {
- t.Logf("Found AutoScaling group %s\n",
- firstGroup.AutoScalingGroupName)
- }
- }
- testServer.Flush()
-}
-
-func TestAutoScalingGroup(t *testing.T) {
- var as *AutoScaling
- // Launch configuration test config
- lc := new(LaunchConfiguration)
- lc.LaunchConfigurationName = "LConf1"
- lc.ImageId = "ami-03e47533" // Octave debian ami
- lc.KernelId = "aki-98e26fa8"
- lc.KeyName = "testAWS" // Replace with valid key for your account
- lc.InstanceType = "m1.small"
-
- // CreateAutoScalingGroup params test config
- asgReq := new(CreateAutoScalingGroupParams)
- asgReq.AutoScalingGroupName = "ASGTest1"
- asgReq.LaunchConfigurationName = lc.LaunchConfigurationName
- asgReq.DefaultCooldown = 300
- asgReq.HealthCheckGracePeriod = 300
- asgReq.DesiredCapacity = 1
- asgReq.MinSize = 1
- asgReq.MaxSize = 5
- asgReq.AvailabilityZones = []string{"us-west-2a"}
-
- asg := new(AutoScalingGroup)
- asg.AutoScalingGroupName = "ASGTest1"
- asg.LaunchConfigurationName = lc.LaunchConfigurationName
- asg.DefaultCooldown = 300
- asg.HealthCheckGracePeriod = 300
- asg.DesiredCapacity = 1
- asg.MinSize = 1
- asg.MaxSize = 5
- asg.AvailabilityZones = []string{"us-west-2a"}
-
- awsAuth, err := aws.EnvAuth()
- if err != nil {
- mockTest = true
- t.Log("Running mock tests as AWS environment variables are not set")
- awsAuth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- as = New(awsAuth, aws.Region{AutoScalingEndpoint: testServer.URL})
- } else {
- as = New(awsAuth, aws.USWest2)
- }
-
- // Create the launch configuration
- if mockTest {
- testServer.Response(200, nil, CreateLaunchConfigurationResponse)
- }
- _, err = as.CreateLaunchConfiguration(lc)
- if err != nil {
- t.Fatal(err)
- }
-
- // Check that we can get the launch configuration details
- if mockTest {
- testServer.Response(200, nil, DescribeLaunchConfigurationsResponse)
- }
- _, err = as.DescribeLaunchConfigurations([]string{lc.LaunchConfigurationName}, 10, "")
- if err != nil {
- t.Fatal(err)
- }
-
- // Create the AutoScalingGroup
- if mockTest {
- testServer.Response(200, nil, CreateAutoScalingGroupResponse)
- }
- _, err = as.CreateAutoScalingGroup(asgReq)
- if err != nil {
- t.Fatal(err)
- }
-
- // Check that we can get the autoscaling group details
- if mockTest {
- testServer.Response(200, nil, DescribeAutoScalingGroupsResponse)
- }
- _, err = as.DescribeAutoScalingGroups(nil, 10, "")
- if err != nil {
- t.Fatal(err)
- }
-
- // Suspend the scaling processes for the test AutoScalingGroup
- if mockTest {
- testServer.Response(200, nil, SuspendProcessesResponse)
- }
- _, err = as.SuspendProcesses(asg.AutoScalingGroupName, nil)
- if err != nil {
- t.Fatal(err)
- }
-
- // Resume scaling processes for the test AutoScalingGroup
- if mockTest {
- testServer.Response(200, nil, ResumeProcessesResponse)
- }
- _, err = as.ResumeProcesses(asg.AutoScalingGroupName, nil)
- if err != nil {
- t.Fatal(err)
- }
-
- // Change the desired capacity from 1 to 2. This will launch a second instance
- if mockTest {
- testServer.Response(200, nil, SetDesiredCapacityResponse)
- }
- _, err = as.SetDesiredCapacity(asg.AutoScalingGroupName, 2, false)
- if err != nil {
- t.Fatal(err)
- }
-
- // Change the desired capacity from 2 to 1. This will terminate one of the instances
- if mockTest {
- testServer.Response(200, nil, SetDesiredCapacityResponse)
- }
-
- _, err = as.SetDesiredCapacity(asg.AutoScalingGroupName, 1, false)
- if err != nil {
- t.Fatal(err)
- }
-
- // Update the max capacity for the scaling group
- if mockTest {
- testServer.Response(200, nil, UpdateAutoScalingGroupResponse)
- }
- asg.MinSize = 1
- asg.MaxSize = 6
- asg.DesiredCapacity = 1
- _, err = as.UpdateAutoScalingGroup(asg)
- if err != nil {
- t.Fatal(err)
- }
-
- // Add a scheduled action to the group
- psar := new(PutScheduledUpdateGroupActionParams)
- psar.AutoScalingGroupName = asg.AutoScalingGroupName
- psar.MaxSize = 4
- psar.ScheduledActionName = "SATest1"
- psar.Recurrence = "30 0 1 1,6,12 *"
- if mockTest {
- testServer.Response(200, nil, PutScheduledUpdateGroupActionResponse)
- }
- _, err = as.PutScheduledUpdateGroupAction(psar)
- if err != nil {
- t.Fatal(err)
- }
-
- // List the scheduled actions for the group
- sar := new(DescribeScheduledActionsParams)
- sar.AutoScalingGroupName = asg.AutoScalingGroupName
- if mockTest {
- testServer.Response(200, nil, DescribeScheduledActionsResponse)
- }
- _, err = as.DescribeScheduledActions(sar)
- if err != nil {
- t.Fatal(err)
- }
-
- // Delete the test scheduled action from the group
- if mockTest {
- testServer.Response(200, nil, DeleteScheduledActionResponse)
- }
- _, err = as.DeleteScheduledAction(asg.AutoScalingGroupName, psar.ScheduledActionName)
- if err != nil {
- t.Fatal(err)
- }
- testServer.Flush()
-}
-
-// --------------------------------------------------------------------------
-// Detailed Unit Tests
-
-func (s *S) TestAttachInstances(c *C) {
- testServer.Response(200, nil, AttachInstancesResponse)
- resp, err := s.as.AttachInstances("my-test-asg", []string{"i-21321afs", "i-baaffg23"})
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "AttachInstances")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("InstanceIds.member.1"), Equals, "i-21321afs")
- c.Assert(values.Get("InstanceIds.member.2"), Equals, "i-baaffg23")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestCreateAutoScalingGroup(c *C) {
- testServer.Response(200, nil, CreateAutoScalingGroupResponse)
- testServer.Response(200, nil, DeleteAutoScalingGroupResponse)
-
- createAS := &CreateAutoScalingGroupParams{
- AutoScalingGroupName: "my-test-asg",
- AvailabilityZones: []string{"us-east-1a", "us-east-1b"},
- MinSize: 3,
- MaxSize: 3,
- DefaultCooldown: 600,
- DesiredCapacity: 0,
- LaunchConfigurationName: "my-test-lc",
- LoadBalancerNames: []string{"elb-1", "elb-2"},
- Tags: []Tag{
- {
- Key: "foo",
- Value: "bar",
- },
- {
- Key: "baz",
- Value: "qux",
- },
- },
- VPCZoneIdentifier: "subnet-610acd08,subnet-530fc83a",
- }
- resp, err := s.as.CreateAutoScalingGroup(createAS)
- c.Assert(err, IsNil)
- defer s.as.DeleteAutoScalingGroup(createAS.AutoScalingGroupName, true)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "CreateAutoScalingGroup")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("AvailabilityZones.member.1"), Equals, "us-east-1a")
- c.Assert(values.Get("AvailabilityZones.member.2"), Equals, "us-east-1b")
- c.Assert(values.Get("MinSize"), Equals, "3")
- c.Assert(values.Get("MaxSize"), Equals, "3")
- c.Assert(values.Get("DefaultCooldown"), Equals, "600")
- c.Assert(values.Get("DesiredCapacity"), Equals, "0")
- c.Assert(values.Get("LaunchConfigurationName"), Equals, "my-test-lc")
- c.Assert(values.Get("LoadBalancerNames.member.1"), Equals, "elb-1")
- c.Assert(values.Get("LoadBalancerNames.member.2"), Equals, "elb-2")
- c.Assert(values.Get("Tags.member.1.Key"), Equals, "foo")
- c.Assert(values.Get("Tags.member.1.Value"), Equals, "bar")
- c.Assert(values.Get("Tags.member.2.Key"), Equals, "baz")
- c.Assert(values.Get("Tags.member.2.Value"), Equals, "qux")
- c.Assert(values.Get("VPCZoneIdentifier"), Equals, "subnet-610acd08,subnet-530fc83a")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestCreateLaunchConfiguration(c *C) {
- testServer.Response(200, nil, CreateLaunchConfigurationResponse)
- testServer.Response(200, nil, DeleteLaunchConfigurationResponse)
-
- launchConfig := &LaunchConfiguration{
- LaunchConfigurationName: "my-test-lc",
- AssociatePublicIpAddress: true,
- EbsOptimized: true,
- SecurityGroups: []string{"sec-grp1", "sec-grp2"},
- UserData: "1234",
- KeyName: "secretKeyPair",
- ImageId: "ami-0078da69",
- InstanceType: "m1.small",
- SpotPrice: "0.03",
- BlockDeviceMappings: []BlockDeviceMapping{
- {
- DeviceName: "/dev/sda1",
- VirtualName: "ephemeral0",
- },
- {
- DeviceName: "/dev/sdb",
- VirtualName: "ephemeral1",
- },
- {
- DeviceName: "/dev/sdf",
- Ebs: EBS{
- DeleteOnTermination: true,
- SnapshotId: "snap-2a2b3c4d",
- VolumeSize: 100,
- },
- },
- },
- InstanceMonitoring: InstanceMonitoring{
- Enabled: true,
- },
- }
- resp, err := s.as.CreateLaunchConfiguration(launchConfig)
- c.Assert(err, IsNil)
- defer s.as.DeleteLaunchConfiguration(launchConfig.LaunchConfigurationName)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "CreateLaunchConfiguration")
- c.Assert(values.Get("LaunchConfigurationName"), Equals, "my-test-lc")
- c.Assert(values.Get("AssociatePublicIpAddress"), Equals, "true")
- c.Assert(values.Get("EbsOptimized"), Equals, "true")
- c.Assert(values.Get("SecurityGroups.member.1"), Equals, "sec-grp1")
- c.Assert(values.Get("SecurityGroups.member.2"), Equals, "sec-grp2")
- c.Assert(values.Get("UserData"), Equals, "MTIzNA==")
- c.Assert(values.Get("KeyName"), Equals, "secretKeyPair")
- c.Assert(values.Get("ImageId"), Equals, "ami-0078da69")
- c.Assert(values.Get("InstanceType"), Equals, "m1.small")
- c.Assert(values.Get("SpotPrice"), Equals, "0.03")
- c.Assert(values.Get("BlockDeviceMappings.member.1.DeviceName"), Equals, "/dev/sda1")
- c.Assert(values.Get("BlockDeviceMappings.member.1.VirtualName"), Equals, "ephemeral0")
- c.Assert(values.Get("BlockDeviceMappings.member.2.DeviceName"), Equals, "/dev/sdb")
- c.Assert(values.Get("BlockDeviceMappings.member.2.VirtualName"), Equals, "ephemeral1")
- c.Assert(values.Get("BlockDeviceMappings.member.3.DeviceName"), Equals, "/dev/sdf")
- c.Assert(values.Get("BlockDeviceMappings.member.3.Ebs.DeleteOnTermination"), Equals, "true")
- c.Assert(values.Get("BlockDeviceMappings.member.3.Ebs.SnapshotId"), Equals, "snap-2a2b3c4d")
- c.Assert(values.Get("BlockDeviceMappings.member.3.Ebs.VolumeSize"), Equals, "100")
- c.Assert(values.Get("InstanceMonitoring.Enabled"), Equals, "true")
- c.Assert(resp.RequestId, Equals, "7c6e177f-f082-11e1-ac58-3714bEXAMPLE")
-}
-
-func (s *S) TestCreateOrUpdateTags(c *C) {
- testServer.Response(200, nil, CreateOrUpdateTagsResponse)
- tags := []Tag{
- {
- Key: "foo",
- Value: "bar",
- ResourceId: "my-test-asg",
- },
- {
- Key: "baz",
- Value: "qux",
- ResourceId: "my-test-asg",
- PropagateAtLaunch: true,
- },
- }
- resp, err := s.as.CreateOrUpdateTags(tags)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "CreateOrUpdateTags")
- c.Assert(values.Get("Tags.member.1.Key"), Equals, "foo")
- c.Assert(values.Get("Tags.member.1.Value"), Equals, "bar")
- c.Assert(values.Get("Tags.member.1.ResourceId"), Equals, "my-test-asg")
- c.Assert(values.Get("Tags.member.2.Key"), Equals, "baz")
- c.Assert(values.Get("Tags.member.2.Value"), Equals, "qux")
- c.Assert(values.Get("Tags.member.2.ResourceId"), Equals, "my-test-asg")
- c.Assert(values.Get("Tags.member.2.PropagateAtLaunch"), Equals, "true")
- c.Assert(resp.RequestId, Equals, "b0203919-bf1b-11e2-8a01-13263EXAMPLE")
-}
-
-func (s *S) TestDeleteAutoScalingGroup(c *C) {
- testServer.Response(200, nil, DeleteAutoScalingGroupResponse)
- resp, err := s.as.DeleteAutoScalingGroup("my-test-asg", true)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DeleteAutoScalingGroup")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(resp.RequestId, Equals, "70a76d42-9665-11e2-9fdf-211deEXAMPLE")
-}
-
-func (s *S) TestDeleteAutoScalingGroupWithExistingInstances(c *C) {
- testServer.Response(400, nil, DeleteAutoScalingGroupErrorResponse)
- resp, err := s.as.DeleteAutoScalingGroup("my-test-asg", false)
- testServer.WaitRequest()
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- e, ok := err.(*Error)
- if !ok {
- c.Errorf("Unable to unmarshal error into AWS Autoscaling Error")
- }
- c.Assert(ok, Equals, true)
- c.Assert(e.Message, Equals, "You cannot delete an AutoScalingGroup while there are instances or pending Spot instance request(s) still in the group.")
- c.Assert(e.Code, Equals, "ResourceInUse")
- c.Assert(e.StatusCode, Equals, 400)
- c.Assert(e.RequestId, Equals, "70a76d42-9665-11e2-9fdf-211deEXAMPLE")
-}
-
-func (s *S) TestDeleteLaunchConfiguration(c *C) {
- testServer.Response(200, nil, DeleteLaunchConfigurationResponse)
- resp, err := s.as.DeleteLaunchConfiguration("my-test-lc")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DeleteLaunchConfiguration")
- c.Assert(values.Get("LaunchConfigurationName"), Equals, "my-test-lc")
- c.Assert(resp.RequestId, Equals, "7347261f-97df-11e2-8756-35eEXAMPLE")
-}
-
-func (s *S) TestDeleteLaunchConfigurationInUse(c *C) {
- testServer.Response(400, nil, DeleteLaunchConfigurationInUseResponse)
- resp, err := s.as.DeleteLaunchConfiguration("my-test-lc")
- testServer.WaitRequest()
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- e, ok := err.(*Error)
- if !ok {
- c.Errorf("Unable to unmarshal error into AWS Autoscaling Error")
- }
- c.Logf("%v %v %v", e.Code, e.Message, e.RequestId)
- c.Assert(ok, Equals, true)
- c.Assert(e.Message, Equals, "Cannot delete launch configuration my-test-lc because it is attached to AutoScalingGroup test")
- c.Assert(e.Code, Equals, "ResourceInUse")
- c.Assert(e.StatusCode, Equals, 400)
- c.Assert(e.RequestId, Equals, "7347261f-97df-11e2-8756-35eEXAMPLE")
-}
-
-func (s *S) TestDeleteTags(c *C) {
- testServer.Response(200, nil, DeleteTagsResponse)
- tags := []Tag{
- {
- Key: "foo",
- Value: "bar",
- ResourceId: "my-test-asg",
- },
- {
- Key: "baz",
- Value: "qux",
- ResourceId: "my-test-asg",
- PropagateAtLaunch: true,
- },
- }
- resp, err := s.as.DeleteTags(tags)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DeleteTags")
- c.Assert(values.Get("Tags.member.1.Key"), Equals, "foo")
- c.Assert(values.Get("Tags.member.1.Value"), Equals, "bar")
- c.Assert(values.Get("Tags.member.1.ResourceId"), Equals, "my-test-asg")
- c.Assert(values.Get("Tags.member.2.Key"), Equals, "baz")
- c.Assert(values.Get("Tags.member.2.Value"), Equals, "qux")
- c.Assert(values.Get("Tags.member.2.ResourceId"), Equals, "my-test-asg")
- c.Assert(values.Get("Tags.member.2.PropagateAtLaunch"), Equals, "true")
- c.Assert(resp.RequestId, Equals, "b0203919-bf1b-11e2-8a01-13263EXAMPLE")
-}
-
-func (s *S) TestDescribeAccountLimits(c *C) {
- testServer.Response(200, nil, DescribeAccountLimitsResponse)
-
- resp, err := s.as.DescribeAccountLimits()
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeAccountLimits")
- c.Assert(resp.RequestId, Equals, "a32bd184-519d-11e3-a8a4-c1c467cbcc3b")
- c.Assert(resp.MaxNumberOfAutoScalingGroups, Equals, 20)
- c.Assert(resp.MaxNumberOfLaunchConfigurations, Equals, 100)
-
-}
-
-func (s *S) TestDescribeAdjustmentTypes(c *C) {
- testServer.Response(200, nil, DescribeAdjustmentTypesResponse)
- resp, err := s.as.DescribeAdjustmentTypes()
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeAdjustmentTypes")
- c.Assert(resp.RequestId, Equals, "cc5f0337-b694-11e2-afc0-6544dEXAMPLE")
- c.Assert(resp.AdjustmentTypes, DeepEquals, []AdjustmentType{{"ChangeInCapacity"}, {"ExactCapacity"}, {"PercentChangeInCapacity"}})
-}
-
-func (s *S) TestDescribeAutoScalingGroups(c *C) {
- testServer.Response(200, nil, DescribeAutoScalingGroupsResponse)
- resp, err := s.as.DescribeAutoScalingGroups([]string{"my-test-asg-lbs"}, 0, "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- t, _ := time.Parse(time.RFC3339, "2013-05-06T17:47:15.107Z")
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeAutoScalingGroups")
- c.Assert(values.Get("AutoScalingGroupNames.member.1"), Equals, "my-test-asg-lbs")
-
- expected := &DescribeAutoScalingGroupsResp{
- AutoScalingGroups: []AutoScalingGroup{
- {
- AutoScalingGroupName: "my-test-asg-lbs",
- Tags: []Tag{
- {
- Key: "foo",
- Value: "bar",
- ResourceId: "my-test-asg-lbs",
- PropagateAtLaunch: true,
- ResourceType: "auto-scaling-group",
- },
- {
- Key: "baz",
- Value: "qux",
- ResourceId: "my-test-asg-lbs",
- PropagateAtLaunch: true,
- ResourceType: "auto-scaling-group",
- },
- },
- Instances: []Instance{
- {
- AvailabilityZone: "us-east-1b",
- HealthStatus: "Healthy",
- InstanceId: "i-zb1f313",
- LaunchConfigurationName: "my-test-lc",
- LifecycleState: "InService",
- },
- {
- AvailabilityZone: "us-east-1a",
- HealthStatus: "Healthy",
- InstanceId: "i-90123adv",
- LaunchConfigurationName: "my-test-lc",
- LifecycleState: "InService",
- },
- },
- HealthCheckType: "ELB",
- CreatedTime: t,
- LaunchConfigurationName: "my-test-lc",
- DesiredCapacity: 2,
- AvailabilityZones: []string{"us-east-1b", "us-east-1a"},
- LoadBalancerNames: []string{"my-test-asg-loadbalancer"},
- MinSize: 2,
- MaxSize: 10,
- VPCZoneIdentifier: "subnet-32131da1,subnet-1312dad2",
- HealthCheckGracePeriod: 120,
- DefaultCooldown: 300,
- AutoScalingGroupARN: "arn:aws:autoscaling:us-east-1:803981987763:autoScalingGroup:ca861182-c8f9-4ca7-b1eb-cd35505f5ebb:autoScalingGroupName/my-test-asg-lbs",
- TerminationPolicies: []string{"Default"},
- },
- },
- RequestId: "0f02a07d-b677-11e2-9eb0-dd50EXAMPLE",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeAutoScalingInstances(c *C) {
- testServer.Response(200, nil, DescribeAutoScalingInstancesResponse)
- resp, err := s.as.DescribeAutoScalingInstances([]string{"i-78e0d40b"}, 0, "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeAutoScalingInstances")
- c.Assert(resp.RequestId, Equals, "df992dc3-b72f-11e2-81e1-750aa6EXAMPLE")
- c.Assert(resp.AutoScalingInstances, DeepEquals, []Instance{
- {
- AutoScalingGroupName: "my-test-asg",
- AvailabilityZone: "us-east-1a",
- HealthStatus: "Healthy",
- InstanceId: "i-78e0d40b",
- LaunchConfigurationName: "my-test-lc",
- LifecycleState: "InService",
- },
- })
-}
-
-func (s *S) TestDescribeLaunchConfigurations(c *C) {
- testServer.Response(200, nil, DescribeLaunchConfigurationsResponse)
- resp, err := s.as.DescribeLaunchConfigurations([]string{"my-test-lc"}, 0, "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- t, _ := time.Parse(time.RFC3339, "2013-01-21T23:04:42.200Z")
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeLaunchConfigurations")
- c.Assert(values.Get("LaunchConfigurationNames.member.1"), Equals, "my-test-lc")
- expected := &DescribeLaunchConfigurationsResp{
- LaunchConfigurations: []LaunchConfiguration{
- {
- AssociatePublicIpAddress: true,
- BlockDeviceMappings: []BlockDeviceMapping{
- {
- DeviceName: "/dev/sdb",
- VirtualName: "ephemeral0",
- },
- {
- DeviceName: "/dev/sdf",
- Ebs: EBS{
- SnapshotId: "snap-XXXXYYY",
- VolumeSize: 100,
- Iops: 50,
- VolumeType: "io1",
- DeleteOnTermination: true,
- },
- },
- },
- EbsOptimized: false,
- CreatedTime: t,
- LaunchConfigurationName: "my-test-lc",
- InstanceType: "m1.small",
- ImageId: "ami-514ac838",
- InstanceMonitoring: InstanceMonitoring{Enabled: true},
- LaunchConfigurationARN: "arn:aws:autoscaling:us-east-1:803981987763:launchConfiguration:9dbbbf87-6141-428a-a409-0752edbe6cad:launchConfigurationName/my-test-lc",
- },
- },
- RequestId: "d05a22f8-b690-11e2-bf8e-2113fEXAMPLE",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeMetricCollectionTypes(c *C) {
- testServer.Response(200, nil, DescribeMetricCollectionTypesResponse)
- resp, err := s.as.DescribeMetricCollectionTypes()
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeMetricCollectionTypes")
- c.Assert(resp.RequestId, Equals, "07f3fea2-bf3c-11e2-9b6f-f3cdbb80c073")
- c.Assert(resp.Metrics, DeepEquals, []MetricCollection{
- {
- Metric: "GroupMinSize",
- },
- {
- Metric: "GroupMaxSize",
- },
- {
- Metric: "GroupDesiredCapacity",
- },
- {
- Metric: "GroupInServiceInstances",
- },
- {
- Metric: "GroupPendingInstances",
- },
- {
- Metric: "GroupTerminatingInstances",
- },
- {
- Metric: "GroupTotalInstances",
- },
- })
- c.Assert(resp.Granularities, DeepEquals, []MetricGranularity{
- {
- Granularity: "1Minute",
- },
- })
-}
-
-func (s *S) TestDescribeNotificationConfigurations(c *C) {
- testServer.Response(200, nil, DescribeNotificationConfigurationsResponse)
- resp, err := s.as.DescribeNotificationConfigurations([]string{"i-78e0d40b"}, 0, "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeNotificationConfigurations")
- c.Assert(resp.RequestId, Equals, "07f3fea2-bf3c-11e2-9b6f-f3cdbb80c073")
- c.Assert(resp.NotificationConfigurations, DeepEquals, []NotificationConfiguration{
- {
- AutoScalingGroupName: "my-test-asg",
- NotificationType: "autoscaling: EC2_INSTANCE_LAUNCH",
- TopicARN: "vajdoafj231j41231/topic",
- },
- })
-}
-
-func (s *S) TestDescribePolicies(c *C) {
- testServer.Response(200, nil, DescribePoliciesResponse)
- resp, err := s.as.DescribePolicies("my-test-asg", []string{}, 2, "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribePolicies")
- c.Assert(values.Get("MaxRecords"), Equals, "2")
- expected := &DescribePoliciesResp{
- RequestId: "ec3bffad-b739-11e2-b38d-15fbEXAMPLE",
- NextToken: "3ef417fe-9202-12-8ddd-d13e1313413",
- ScalingPolicies: []ScalingPolicy{
- {
- PolicyARN: "arn:aws:autoscaling:us-east-1:803981987763:scalingPolicy:c322761b-3172-4d56-9a21-0ed9d6161d67:autoScalingGroupName/my-test-asg:policyName/MyScaleDownPolicy",
- AdjustmentType: "ChangeInCapacity",
- ScalingAdjustment: -1,
- PolicyName: "MyScaleDownPolicy",
- AutoScalingGroupName: "my-test-asg",
- Cooldown: 60,
- Alarms: []Alarm{
- {
- AlarmName: "TestQueue",
- AlarmARN: "arn:aws:cloudwatch:us-east-1:803981987763:alarm:TestQueue",
- },
- },
- },
- {
- PolicyARN: "arn:aws:autoscaling:us-east-1:803981987763:scalingPolicy:c55a5cdd-9be0-435b-b60b-a8dd313159f5:autoScalingGroupName/my-test-asg:policyName/MyScaleUpPolicy",
- AdjustmentType: "ChangeInCapacity",
- ScalingAdjustment: 1,
- PolicyName: "MyScaleUpPolicy",
- AutoScalingGroupName: "my-test-asg",
- Cooldown: 60,
- Alarms: []Alarm{
- {
- AlarmName: "TestQueue",
- AlarmARN: "arn:aws:cloudwatch:us-east-1:803981987763:alarm:TestQueue",
- },
- },
- },
- },
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeScalingActivities(c *C) {
- testServer.Response(200, nil, DescribeScalingActivitiesResponse)
- resp, err := s.as.DescribeScalingActivities("my-test-asg", []string{}, 1, "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeScalingActivities")
- c.Assert(values.Get("MaxRecords"), Equals, "1")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- st, _ := time.Parse(time.RFC3339, "2012-04-12T17:32:07.882Z")
- et, _ := time.Parse(time.RFC3339, "2012-04-12T17:32:08Z")
- expected := &DescribeScalingActivitiesResp{
- RequestId: "7a641adc-84c5-11e1-a8a5-217ebEXAMPLE",
- NextToken: "3ef417fe-9202-12-8ddd-d13e1313413",
- Activities: []Activity{
- {
- StatusCode: "Failed",
- Progress: 0,
- ActivityId: "063308ae-aa22-4a9b-94f4-9faeEXAMPLE",
- StartTime: st,
- AutoScalingGroupName: "my-test-asg",
- Details: "{}",
- Cause: "At 2012-04-12T17:31:30Z a user request created an AutoScalingGroup changing the desired capacity from 0 to 1. At 2012-04-12T17:32:07Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1.",
- Description: "Launching a new EC2 instance. Status Reason: The image id 'ami-4edb0327' does not exist. Launching EC2 instance failed.",
- EndTime: et,
- StatusMessage: "The image id 'ami-4edb0327' does not exist. Launching EC2 instance failed.",
- },
- },
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeScalingProcessTypes(c *C) {
- testServer.Response(200, nil, DescribeScalingProcessTypesResponse)
- resp, err := s.as.DescribeScalingProcessTypes()
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeScalingProcessTypes")
- c.Assert(resp.RequestId, Equals, "27f2eacc-b73f-11e2-ad99-c7aba3a9c963")
- c.Assert(resp.Processes, DeepEquals, []ProcessType{
- {"AZRebalance"},
- {"AddToLoadBalancer"},
- {"AlarmNotification"},
- {"HealthCheck"},
- {"Launch"},
- {"ReplaceUnhealthy"},
- {"ScheduledActions"},
- {"Terminate"},
- })
-}
-
-func (s *S) TestDescribeScheduledActions(c *C) {
- testServer.Response(200, nil, DescribeScheduledActionsResponse)
- st, _ := time.Parse(time.RFC3339, "2014-06-01T00:30:00Z")
- request := &DescribeScheduledActionsParams{
- AutoScalingGroupName: "ASGTest1",
- MaxRecords: 1,
- StartTime: st,
- }
- resp, err := s.as.DescribeScheduledActions(request)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeScheduledActions")
- c.Assert(resp.RequestId, Equals, "0eb4217f-8421-11e3-9233-7100ef811766")
- c.Assert(resp.ScheduledUpdateGroupActions, DeepEquals, []ScheduledUpdateGroupAction{
- {
- AutoScalingGroupName: "ASGTest1",
- ScheduledActionARN: "arn:aws:autoscaling:us-west-2:193024542802:scheduledUpdateGroupAction:61f68b2c-bde3-4316-9a81-eb95dc246509:autoScalingGroupName/ASGTest1:scheduledActionName/SATest1",
- ScheduledActionName: "SATest1",
- Recurrence: "30 0 1 1,6,12 *",
- MaxSize: 4,
- StartTime: st,
- Time: st,
- },
- })
-}
-
-func (s *S) TestDescribeTags(c *C) {
- testServer.Response(200, nil, DescribeTagsResponse)
- filter := NewFilter()
- filter.Add("auto-scaling-group", "my-test-asg")
- resp, err := s.as.DescribeTags(filter, 1, "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeTags")
- c.Assert(values.Get("MaxRecords"), Equals, "1")
- c.Assert(values.Get("Filters.member.1.Name"), Equals, "auto-scaling-group")
- c.Assert(values.Get("Filters.member.1.Values.member.1"), Equals, "my-test-asg")
- c.Assert(resp.RequestId, Equals, "086265fd-bf3e-11e2-85fc-fbb1EXAMPLE")
- c.Assert(resp.Tags, DeepEquals, []Tag{
- {
- Key: "version",
- Value: "1.0",
- ResourceId: "my-test-asg",
- PropagateAtLaunch: true,
- ResourceType: "auto-scaling-group",
- },
- })
-}
-
-func (s *S) TestDescribeTerminationPolicyTypes(c *C) {
- testServer.Response(200, nil, DescribeTerminationPolicyTypesResponse)
- resp, err := s.as.DescribeTerminationPolicyTypes()
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DescribeTerminationPolicyTypes")
- c.Assert(resp.RequestId, Equals, "d9a05827-b735-11e2-a40c-c79a5EXAMPLE")
- c.Assert(resp.TerminationPolicyTypes, DeepEquals, []string{"ClosestToNextInstanceHour", "Default", "NewestInstance", "OldestInstance", "OldestLaunchConfiguration"})
-}
-
-func (s *S) TestDetachInstances(c *C) {
- testServer.Response(200, nil, DetachInstancesResponse)
- resp, err := s.as.DetachInstances("my-asg", []string{"i-5f2e8a0d"}, true)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DetachInstances")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-asg")
- c.Assert(values.Get("ShouldDecrementDesiredCapacity"), Equals, "true")
- c.Assert(values.Get("InstanceIds.member.1"), Equals, "i-5f2e8a0d")
- st, _ := time.Parse(time.RFC3339, "2014-06-14T00:07:30.280Z")
- expected := &DetachInstancesResult{
- RequestId: "e04f3b11-f357-11e3-a434-7f10009d5849",
- Activities: []Activity{
- {
- StatusCode: "InProgress",
- Progress: 50,
- ActivityId: "e54ff599-bf05-4076-8b95-a0f090ed90bb",
- StartTime: st,
- AutoScalingGroupName: "my-asg",
- Details: "{\"Availability Zone\":\"us-east-1a\"}",
- Cause: "At 2014-06-14T00:07:30Z instance i-5f2e8a0d was detached in response to a user request, shrinking the capacity from 4 to 3.",
- Description: "Detaching EC2 instance: i-5f2e8a0d",
- },
- },
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDisableMetricsCollection(c *C) {
- testServer.Response(200, nil, DisableMetricsCollectionResponse)
- resp, err := s.as.DisableMetricsCollection("my-test-asg", []string{"GroupMinSize"})
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "DisableMetricsCollection")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("Metrics.member.1"), Equals, "GroupMinSize")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestEnableMetricsCollection(c *C) {
- testServer.Response(200, nil, DisableMetricsCollectionResponse)
- resp, err := s.as.EnableMetricsCollection("my-test-asg", []string{"GroupMinSize", "GroupMaxSize"}, "1Minute")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "EnableMetricsCollection")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("Granularity"), Equals, "1Minute")
- c.Assert(values.Get("Metrics.member.1"), Equals, "GroupMinSize")
- c.Assert(values.Get("Metrics.member.2"), Equals, "GroupMaxSize")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestEnterStandby(c *C) {
- testServer.Response(200, nil, EnterStandbyResponse)
- resp, err := s.as.EnterStandby("my-asg", []string{"i-5b73d709"}, true)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "EnterStandby")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-asg")
- c.Assert(values.Get("ShouldDecrementDesiredCapacity"), Equals, "true")
- c.Assert(values.Get("InstanceIds.member.1"), Equals, "i-5b73d709")
- st, _ := time.Parse(time.RFC3339, "2014-06-13T22:35:50.884Z")
- expected := &EnterStandbyResult{
- RequestId: "126f2f31-f34b-11e3-bc51-b35178f0274f",
- Activities: []Activity{
- {
- StatusCode: "InProgress",
- Progress: 50,
- ActivityId: "462b4bc3-ad3b-4e67-a58d-96cd00f02f9e",
- StartTime: st,
- AutoScalingGroupName: "my-asg",
- Details: "{\"Availability Zone\":\"us-east-1a\"}",
- Cause: "At 2014-06-13T22:35:50Z instance i-5b73d709 was moved to standby in response to a user request, shrinking the capacity from 4 to 3.",
- Description: "Moving EC2 instance to Standby: i-5b73d709",
- },
- },
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestExecutePolicy(c *C) {
- testServer.Response(200, nil, ExecutePolicyResponse)
- resp, err := s.as.ExecutePolicy("my-scaleout-policy", "my-test-asg", true)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "ExecutePolicy")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("PolicyName"), Equals, "my-scaleout-policy")
- c.Assert(values.Get("HonorCooldown"), Equals, "true")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestExitStandby(c *C) {
- testServer.Response(200, nil, ExitStandbyResponse)
- resp, err := s.as.ExitStandby("my-asg", []string{"i-5b73d709"})
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "ExitStandby")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-asg")
- c.Assert(values.Get("InstanceIds.member.1"), Equals, "i-5b73d709")
- st, _ := time.Parse(time.RFC3339, "2014-06-13T22:43:53.523Z")
- expected := &ExitStandbyResult{
- RequestId: "321a11c8-f34c-11e3-a434-7f10009d5849",
- Activities: []Activity{
- {
- StatusCode: "PreInService",
- Progress: 30,
- ActivityId: "dca4efcf-eea6-4844-8064-cab1fecd1aa2",
- StartTime: st,
- AutoScalingGroupName: "my-asg",
- Details: "{\"Availability Zone\":\"us-east-1a\"}",
- Cause: "At 2014-06-13T22:43:53Z instance i-5b73d709 was moved out of standby in response to a user request, increasing the capacity from 3 to 4.",
- Description: "Moving EC2 instance out of Standby: i-5b73d709",
- },
- },
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestPutLifecycleHook(c *C) {
- testServer.Response(200, nil, PutLifecycleHookResponse)
- request := &PutLifecycleHookParams{
- AutoScalingGroupName: "my-asg",
- LifecycleHookName: "ReadyForSoftwareInstall",
- LifecycleTransition: "autoscaling:EC2_INSTANCE_LAUNCHING",
- NotificationTargetARN: "arn:aws:sqs:us-east-1:896650972448:lifecyclehookqueue",
- RoleARN: "arn:aws:iam::896650972448:role/AutoScaling",
- }
- resp, err := s.as.PutLifecycleHook(request)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "PutLifecycleHook")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-asg")
- c.Assert(values.Get("LifecycleHookName"), Equals, "ReadyForSoftwareInstall")
- c.Assert(values.Get("RoleARN"), Equals, "arn:aws:iam::896650972448:role/AutoScaling")
- c.Assert(values.Get("LifecycleTransition"), Equals, "autoscaling:EC2_INSTANCE_LAUNCHING")
- c.Assert(values.Get("NotificationTargetARN"), Equals, "arn:aws:sqs:us-east-1:896650972448:lifecyclehookqueue")
- c.Assert(values.Get("DefaultResult"), Equals, "")
- c.Assert(values.Get("HeartbeatTimeout"), Equals, "")
- c.Assert(values.Get("NotificationMetadata"), Equals, "")
- c.Assert(resp.RequestId, Equals, "1952f458-f645-11e3-bc51-b35178f0274f")
-}
-
-func (s *S) TestPutNotificationConfiguration(c *C) {
- testServer.Response(200, nil, PutNotificationConfigurationResponse)
- resp, err := s.as.PutNotificationConfiguration("my-test-asg", []string{"autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_LAUNCH_ERROR"}, "myTopicARN")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "PutNotificationConfiguration")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("TopicARN"), Equals, "myTopicARN")
- c.Assert(values.Get("NotificationTypes.member.1"), Equals, "autoscaling:EC2_INSTANCE_LAUNCH")
- c.Assert(values.Get("NotificationTypes.member.2"), Equals, "autoscaling:EC2_INSTANCE_LAUNCH_ERROR")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestPutScalingPolicy(c *C) {
- testServer.Response(200, nil, PutScalingPolicyResponse)
- request := &PutScalingPolicyParams{
- AutoScalingGroupName: "my-test-asg",
- PolicyName: "my-scaleout-policy",
- ScalingAdjustment: 30,
- AdjustmentType: "PercentChangeInCapacity",
- Cooldown: 0,
- MinAdjustmentStep: 0,
- }
- resp, err := s.as.PutScalingPolicy(request)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "PutScalingPolicy")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("PolicyName"), Equals, "my-scaleout-policy")
- c.Assert(values.Get("AdjustmentType"), Equals, "PercentChangeInCapacity")
- c.Assert(values.Get("ScalingAdjustment"), Equals, "30")
- c.Assert(resp.RequestId, Equals, "3cfc6fef-c08b-11e2-a697-2922EXAMPLE")
- c.Assert(resp.PolicyARN, Equals, "arn:aws:autoscaling:us-east-1:803981987763:scalingPolicy:b0dcf5e8-02e6-4e31-9719-0675d0dc31ae:autoScalingGroupName/my-test-asg:policyName/my-scaleout-policy")
-}
-
-func (s *S) TestPutScheduledUpdateGroupAction(c *C) {
- testServer.Response(200, nil, PutScheduledUpdateGroupActionResponse)
- st, _ := time.Parse(time.RFC3339, "2013-05-25T08:00:00Z")
- request := &PutScheduledUpdateGroupActionParams{
- AutoScalingGroupName: "my-test-asg",
- DesiredCapacity: 3,
- ScheduledActionName: "ScaleUp",
- StartTime: st,
- }
- resp, err := s.as.PutScheduledUpdateGroupAction(request)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "PutScheduledUpdateGroupAction")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("ScheduledActionName"), Equals, "ScaleUp")
- c.Assert(values.Get("DesiredCapacity"), Equals, "3")
- c.Assert(values.Get("StartTime"), Equals, "2013-05-25T08:00:00Z")
- c.Assert(resp.RequestId, Equals, "3bc8c9bc-6a62-11e2-8a51-4b8a1EXAMPLE")
-}
-
-func (s *S) TestPutScheduledUpdateGroupActionCron(c *C) {
- testServer.Response(200, nil, PutScheduledUpdateGroupActionResponse)
- st, _ := time.Parse(time.RFC3339, "2013-05-25T08:00:00Z")
- request := &PutScheduledUpdateGroupActionParams{
- AutoScalingGroupName: "my-test-asg",
- DesiredCapacity: 3,
- ScheduledActionName: "scaleup-schedule-year",
- StartTime: st,
- Recurrence: "30 0 1 1,6,12 *",
- }
- resp, err := s.as.PutScheduledUpdateGroupAction(request)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "PutScheduledUpdateGroupAction")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("ScheduledActionName"), Equals, "scaleup-schedule-year")
- c.Assert(values.Get("DesiredCapacity"), Equals, "3")
- c.Assert(values.Get("Recurrence"), Equals, "30 0 1 1,6,12 *")
- c.Assert(resp.RequestId, Equals, "3bc8c9bc-6a62-11e2-8a51-4b8a1EXAMPLE")
-
-}
-
-func (s *S) TestResumeProcesses(c *C) {
- testServer.Response(200, nil, ResumeProcessesResponse)
- resp, err := s.as.ResumeProcesses("my-test-asg", []string{"Launch", "Terminate"})
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "ResumeProcesses")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("ScalingProcesses.member.1"), Equals, "Launch")
- c.Assert(values.Get("ScalingProcesses.member.2"), Equals, "Terminate")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-
-}
-
-func (s *S) TestSetDesiredCapacity(c *C) {
- testServer.Response(200, nil, SetDesiredCapacityResponse)
- resp, err := s.as.SetDesiredCapacity("my-test-asg", 3, true)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "SetDesiredCapacity")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("HonorCooldown"), Equals, "true")
- c.Assert(values.Get("DesiredCapacity"), Equals, "3")
- c.Assert(resp.RequestId, Equals, "9fb7e2db-6998-11e2-a985-57c82EXAMPLE")
-}
-
-func (s *S) TestSetInstanceHealth(c *C) {
- testServer.Response(200, nil, SetInstanceHealthResponse)
- resp, err := s.as.SetInstanceHealth("i-baha3121", "Unhealthy", false)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "SetInstanceHealth")
- c.Assert(values.Get("HealthStatus"), Equals, "Unhealthy")
- c.Assert(values.Get("InstanceId"), Equals, "i-baha3121")
- c.Assert(values.Get("ShouldRespectGracePeriod"), Equals, "false")
- c.Assert(resp.RequestId, Equals, "9fb7e2db-6998-11e2-a985-57c82EXAMPLE")
-}
-
-func (s *S) TestSuspendProcesses(c *C) {
- testServer.Response(200, nil, SuspendProcessesResponse)
- resp, err := s.as.SuspendProcesses("my-test-asg", []string{"Launch", "Terminate"})
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "SuspendProcesses")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("ScalingProcesses.member.1"), Equals, "Launch")
- c.Assert(values.Get("ScalingProcesses.member.2"), Equals, "Terminate")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestTerminateInstanceInAutoScalingGroup(c *C) {
- testServer.Response(200, nil, TerminateInstanceInAutoScalingGroupResponse)
- st, _ := time.Parse(time.RFC3339, "2014-01-26T14:08:30.560Z")
- resp, err := s.as.TerminateInstanceInAutoScalingGroup("i-br234123", false)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "TerminateInstanceInAutoScalingGroup")
- c.Assert(values.Get("InstanceId"), Equals, "i-br234123")
- c.Assert(values.Get("ShouldDecrementDesiredCapacity"), Equals, "false")
- expected := &TerminateInstanceInAutoScalingGroupResp{
- Activity: Activity{
- ActivityId: "cczc44a87-7d04-dsa15-31-d27c219864c5",
- Cause: "At 2014-01-26T14:08:30Z instance i-br234123 was taken out of service in response to a user request.",
- Description: "Terminating EC2 instance: i-br234123",
- Details: "{\"Availability Zone\":\"us-east-1b\"}",
- Progress: 0,
- StartTime: st,
- StatusCode: "InProgress",
- },
- RequestId: "8d798a29-f083-11e1-bdfb-cb223EXAMPLE",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestUpdateAutoScalingGroup(c *C) {
- testServer.Response(200, nil, UpdateAutoScalingGroupResponse)
-
- asg := &AutoScalingGroup{
- AutoScalingGroupName: "my-test-asg",
- AvailabilityZones: []string{"us-east-1a", "us-east-1b"},
- MinSize: 3,
- MaxSize: 3,
- DefaultCooldown: 600,
- DesiredCapacity: 3,
- LaunchConfigurationName: "my-test-lc",
- VPCZoneIdentifier: "subnet-610acd08,subnet-530fc83a",
- }
- resp, err := s.as.UpdateAutoScalingGroup(asg)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2011-01-01")
- c.Assert(values.Get("Action"), Equals, "UpdateAutoScalingGroup")
- c.Assert(values.Get("AutoScalingGroupName"), Equals, "my-test-asg")
- c.Assert(values.Get("AvailabilityZones.member.1"), Equals, "us-east-1a")
- c.Assert(values.Get("AvailabilityZones.member.2"), Equals, "us-east-1b")
- c.Assert(values.Get("MinSize"), Equals, "3")
- c.Assert(values.Get("MaxSize"), Equals, "3")
- c.Assert(values.Get("DefaultCooldown"), Equals, "600")
- c.Assert(values.Get("DesiredCapacity"), Equals, "3")
- c.Assert(values.Get("LaunchConfigurationName"), Equals, "my-test-lc")
- c.Assert(values.Get("VPCZoneIdentifier"), Equals, "subnet-610acd08,subnet-530fc83a")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
diff --git a/vendor/github.com/goamz/goamz/autoscaling/responses_test.go b/vendor/github.com/goamz/goamz/autoscaling/responses_test.go
deleted file mode 100644
index 935231aa2..000000000
--- a/vendor/github.com/goamz/goamz/autoscaling/responses_test.go
+++ /dev/null
@@ -1,627 +0,0 @@
-package autoscaling
-
-var AttachInstancesResponse = `
-<AttachInstancesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</AttachInstancesResponse>
-`
-var BasicGroupResponse = `
-<DescribeAutoScalingGroupsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeAutoScalingGroupsResult>
- <AutoScalingGroups/>
- </DescribeAutoScalingGroupsResult>
- <ResponseMetadata>
- <RequestId>08c3bedc-8421-11e3-9bb5-bfa219b29cce</RequestId>
- </ResponseMetadata>
-</DescribeAutoScalingGroupsResponse>
-`
-var CreateAutoScalingGroupResponse = `
-<CreateAutoScalingGroupResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateAutoScalingGroupResponse>
-`
-var CreateLaunchConfigurationResponse = `
-<CreateLaunchConfigurationResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
-<ResponseMetadata>
- <RequestId>7c6e177f-f082-11e1-ac58-3714bEXAMPLE</RequestId>
-</ResponseMetadata>
-</CreateLaunchConfigurationResponse>
-`
-var CreateOrUpdateTagsResponse = `
-<CreateOrUpdateTagsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>b0203919-bf1b-11e2-8a01-13263EXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateOrUpdateTagsResponse>
-`
-var DeleteAutoScalingGroupResponse = `
- <DeleteAutoScalingGroupResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>70a76d42-9665-11e2-9fdf-211deEXAMPLE</RequestId>
- </ResponseMetadata>
- </DeleteAutoScalingGroupResponse>
-`
-var DeleteAutoScalingGroupErrorResponse = `
-<ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <Error>
- <Type>Sender</Type>
- <Code>ResourceInUse</Code>
- <Message>You cannot delete an AutoScalingGroup while there are instances or pending Spot instance request(s) still in the group.</Message>
- </Error>
- <RequestId>70a76d42-9665-11e2-9fdf-211deEXAMPLE</RequestId>
-</ErrorResponse>
-`
-var DeleteLaunchConfigurationResponse = `
-<DeleteLaunchConfigurationResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>7347261f-97df-11e2-8756-35eEXAMPLE</RequestId>
- </ResponseMetadata>
-</DeleteLaunchConfigurationResponse>
-`
-var DeleteLaunchConfigurationInUseResponse = `
-<ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <Error>
- <Type>Sender</Type>
- <Code>ResourceInUse</Code>
- <Message>Cannot delete launch configuration my-test-lc because it is attached to AutoScalingGroup test</Message>
- </Error>
- <RequestId>7347261f-97df-11e2-8756-35eEXAMPLE</RequestId>
-</ErrorResponse>
-`
-var DeleteScheduledActionResponse = `
-<DeleteScheduledActionResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>0f38bb02-8421-11e3-9bb5-bfa219b29cce</RequestId>
- </ResponseMetadata>
-</DeleteScheduledActionResponse>
-`
-var DeleteTagsResponse = `
-<CreateOrUpdateTagsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>b0203919-bf1b-11e2-8a01-13263EXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateOrUpdateTagsResponse>
-`
-var DescribeAccountLimitsResponse = `
-<DescribeAccountLimitsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeAccountLimitsResult>
- <MaxNumberOfLaunchConfigurations>100</MaxNumberOfLaunchConfigurations>
- <MaxNumberOfAutoScalingGroups>20</MaxNumberOfAutoScalingGroups>
- </DescribeAccountLimitsResult>
- <ResponseMetadata>
- <RequestId>a32bd184-519d-11e3-a8a4-c1c467cbcc3b</RequestId>
- </ResponseMetadata>
-</DescribeAccountLimitsResponse>
-`
-var DescribeAdjustmentTypesResponse = `
-<DescribeAdjustmentTypesResponse xmlns="http://autoscaling.amazonaws.com/doc/201-01-01/">
- <DescribeAdjustmentTypesResult>
- <AdjustmentTypes>
- <member>
- <AdjustmentType>ChangeInCapacity</AdjustmentType>
- </member>
- <member>
- <AdjustmentType>ExactCapacity</AdjustmentType>
- </member>
- <member>
- <AdjustmentType>PercentChangeInCapacity</AdjustmentType>
- </member>
- </AdjustmentTypes>
- </DescribeAdjustmentTypesResult>
- <ResponseMetadata>
- <RequestId>cc5f0337-b694-11e2-afc0-6544dEXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeAdjustmentTypesResponse>
-`
-var DescribeAutoScalingGroupsResponse = `
-<DescribeAutoScalingGroupsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
-<DescribeAutoScalingGroupsResult>
- <AutoScalingGroups>
- <member>
- <Tags>
- <member>
- <ResourceId>my-test-asg-lbs</ResourceId>
- <PropagateAtLaunch>true</PropagateAtLaunch>
- <Value>bar</Value>
- <Key>foo</Key>
- <ResourceType>auto-scaling-group</ResourceType>
- </member>
- <member>
- <ResourceId>my-test-asg-lbs</ResourceId>
- <PropagateAtLaunch>true</PropagateAtLaunch>
- <Value>qux</Value>
- <Key>baz</Key>
- <ResourceType>auto-scaling-group</ResourceType>
- </member>
- </Tags>
- <SuspendedProcesses/>
- <AutoScalingGroupName>my-test-asg-lbs</AutoScalingGroupName>
- <HealthCheckType>ELB</HealthCheckType>
- <CreatedTime>2013-05-06T17:47:15.107Z</CreatedTime>
- <EnabledMetrics/>
- <LaunchConfigurationName>my-test-lc</LaunchConfigurationName>
- <Instances>
- <member>
- <HealthStatus>Healthy</HealthStatus>
- <AvailabilityZone>us-east-1b</AvailabilityZone>
- <InstanceId>i-zb1f313</InstanceId>
- <LaunchConfigurationName>my-test-lc</LaunchConfigurationName>
- <LifecycleState>InService</LifecycleState>
- </member>
- <member>
- <HealthStatus>Healthy</HealthStatus>
- <AvailabilityZone>us-east-1a</AvailabilityZone>
- <InstanceId>i-90123adv</InstanceId>
- <LaunchConfigurationName>my-test-lc</LaunchConfigurationName>
- <LifecycleState>InService</LifecycleState>
- </member>
- </Instances>
- <DesiredCapacity>2</DesiredCapacity>
- <AvailabilityZones>
- <member>us-east-1b</member>
- <member>us-east-1a</member>
- </AvailabilityZones>
- <LoadBalancerNames>
- <member>my-test-asg-loadbalancer</member>
- </LoadBalancerNames>
- <MinSize>2</MinSize>
- <VPCZoneIdentifier>subnet-32131da1,subnet-1312dad2</VPCZoneIdentifier>
- <HealthCheckGracePeriod>120</HealthCheckGracePeriod>
- <DefaultCooldown>300</DefaultCooldown>
- <AutoScalingGroupARN>arn:aws:autoscaling:us-east-1:803981987763:autoScalingGroup:ca861182-c8f9-4ca7-b1eb-cd35505f5ebb:autoScalingGroupName/my-test-asg-lbs</AutoScalingGroupARN>
- <TerminationPolicies>
- <member>Default</member>
- </TerminationPolicies>
- <MaxSize>10</MaxSize>
- </member>
- </AutoScalingGroups>
- </DescribeAutoScalingGroupsResult>
- <ResponseMetadata>
- <RequestId>0f02a07d-b677-11e2-9eb0-dd50EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeAutoScalingGroupsResponse>
-`
-var DescribeAutoScalingInstancesResponse = `
-<DescribeAutoScalingInstancesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeAutoScalingInstancesResult>
- <AutoScalingInstances>
- <member>
- <HealthStatus>Healthy</HealthStatus>
- <AutoScalingGroupName>my-test-asg</AutoScalingGroupName>
- <AvailabilityZone>us-east-1a</AvailabilityZone>
- <InstanceId>i-78e0d40b</InstanceId>
- <LaunchConfigurationName>my-test-lc</LaunchConfigurationName>
- <LifecycleState>InService</LifecycleState>
- </member>
- </AutoScalingInstances>
- </DescribeAutoScalingInstancesResult>
- <ResponseMetadata>
- <RequestId>df992dc3-b72f-11e2-81e1-750aa6EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeAutoScalingInstancesResponse>
-`
-var DescribeLaunchConfigurationsResponse = `
-<DescribeLaunchConfigurationsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeLaunchConfigurationsResult>
- <LaunchConfigurations>
- <member>
- <AssociatePublicIpAddress>true</AssociatePublicIpAddress>
- <SecurityGroups/>
- <CreatedTime>2013-01-21T23:04:42.200Z</CreatedTime>
- <KernelId/>
- <LaunchConfigurationName>my-test-lc</LaunchConfigurationName>
- <UserData/>
- <InstanceType>m1.small</InstanceType>
- <LaunchConfigurationARN>arn:aws:autoscaling:us-east-1:803981987763:launchConfiguration:9dbbbf87-6141-428a-a409-0752edbe6cad:launchConfigurationName/my-test-lc</LaunchConfigurationARN>
- <BlockDeviceMappings>
- <member>
- <VirtualName>ephemeral0</VirtualName>
- <DeviceName>/dev/sdb</DeviceName>
- </member>
- <member>
- <Ebs>
- <SnapshotId>snap-XXXXYYY</SnapshotId>
- <VolumeSize>100</VolumeSize>
- <Iops>50</Iops>
- <VolumeType>io1</VolumeType>
- <DeleteOnTermination>true</DeleteOnTermination>
- </Ebs>
- <DeviceName>/dev/sdf</DeviceName>
- </member>
- </BlockDeviceMappings>
- <ImageId>ami-514ac838</ImageId>
- <KeyName/>
- <RamdiskId/>
- <InstanceMonitoring>
- <Enabled>true</Enabled>
- </InstanceMonitoring>
- <EbsOptimized>false</EbsOptimized>
- </member>
- </LaunchConfigurations>
- </DescribeLaunchConfigurationsResult>
- <ResponseMetadata>
- <RequestId>d05a22f8-b690-11e2-bf8e-2113fEXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeLaunchConfigurationsResponse>
-`
-var DescribeMetricCollectionTypesResponse = `
-<DescribeMetricCollectionTypesResponse xmlns="http://autoscaling.amazonaws.co
-oc/2011-01-01/">
- <DescribeMetricCollectionTypesResult>
- <Metrics>
- <member>
- <Metric>GroupMinSize</Metric>
- </member>
- <member>
- <Metric>GroupMaxSize</Metric>
- </member>
- <member>
- <Metric>GroupDesiredCapacity</Metric>
- </member>
- <member>
- <Metric>GroupInServiceInstances</Metric>
- </member>
- <member>
- <Metric>GroupPendingInstances</Metric>
- </member>
- <member>
- <Metric>GroupTerminatingInstances</Metric>
- </member>
- <member>
- <Metric>GroupTotalInstances</Metric>
- </member>
- </Metrics>
- <Granularities>
- <member>
- <Granularity>1Minute</Granularity>
- </member>
- </Granularities>
- </DescribeMetricCollectionTypesResult>
- <ResponseMetadata>
- <RequestId>07f3fea2-bf3c-11e2-9b6f-f3cdbb80c073</RequestId>
- </ResponseMetadata>
-</DescribeMetricCollectionTypesResponse>
-`
-var DescribeNotificationConfigurationsResponse = `
-<DescribeNotificationConfigurationsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeNotificationConfigurationsResult>
- <NotificationConfigurations>
- <member>
- <AutoScalingGroupName>my-test-asg</AutoScalingGroupName>
- <NotificationType>autoscaling: EC2_INSTANCE_LAUNCH</NotificationType>
- <TopicARN>vajdoafj231j41231/topic</TopicARN>
- </member>
- </NotificationConfigurations>
- </DescribeNotificationConfigurationsResult>
- <ResponseMetadata>
- <RequestId>07f3fea2-bf3c-11e2-9b6f-f3cdbb80c073</RequestId>
- </ResponseMetadata>
-</DescribeNotificationConfigurationsResponse>
-`
-var DescribePoliciesResponse = `
-<DescribePoliciesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribePoliciesResult>
- <NextToken>3ef417fe-9202-12-8ddd-d13e1313413</NextToken>
- <ScalingPolicies>
- <member>
- <PolicyARN>arn:aws:autoscaling:us-east-1:803981987763:scalingPolicy:c322761b-3172-4d56-9a21-0ed9d6161d67:autoScalingGroupName/my-test-asg:policyName/MyScaleDownPolicy</PolicyARN>
- <AdjustmentType>ChangeInCapacity</AdjustmentType>
- <ScalingAdjustment>-1</ScalingAdjustment>
- <PolicyName>MyScaleDownPolicy</PolicyName>
- <AutoScalingGroupName>my-test-asg</AutoScalingGroupName>
- <Cooldown>60</Cooldown>
- <Alarms>
- <member>
- <AlarmName>TestQueue</AlarmName>
- <AlarmARN>arn:aws:cloudwatch:us-east-1:803981987763:alarm:TestQueue</AlarmARN>
- </member>
- </Alarms>
- </member>
- <member>
- <PolicyARN>arn:aws:autoscaling:us-east-1:803981987763:scalingPolicy:c55a5cdd-9be0-435b-b60b-a8dd313159f5:autoScalingGroupName/my-test-asg:policyName/MyScaleUpPolicy</PolicyARN>
- <AdjustmentType>ChangeInCapacity</AdjustmentType>
- <ScalingAdjustment>1</ScalingAdjustment>
- <PolicyName>MyScaleUpPolicy</PolicyName>
- <AutoScalingGroupName>my-test-asg</AutoScalingGroupName>
- <Cooldown>60</Cooldown>
- <Alarms>
- <member>
- <AlarmName>TestQueue</AlarmName>
- <AlarmARN>arn:aws:cloudwatch:us-east-1:803981987763:alarm:TestQueue</AlarmARN>
- </member>
- </Alarms>
- </member>
- </ScalingPolicies>
- </DescribePoliciesResult>
- <ResponseMetadata>
- <RequestId>ec3bffad-b739-11e2-b38d-15fbEXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribePoliciesResponse>
-`
-var DescribeScalingActivitiesResponse = `
-<DescribeScalingActivitiesResponse xmlns="http://ec2.amazonaws.com/doc/2011-01-01/">
-<DescribeScalingActivitiesResult>
- <NextToken>3ef417fe-9202-12-8ddd-d13e1313413</NextToken>
-<Activities>
- <member>
- <StatusCode>Failed</StatusCode>
- <Progress>0</Progress>
- <ActivityId>063308ae-aa22-4a9b-94f4-9faeEXAMPLE</ActivityId>
- <StartTime>2012-04-12T17:32:07.882Z</StartTime>
- <AutoScalingGroupName>my-test-asg</AutoScalingGroupName>
- <Cause>At 2012-04-12T17:31:30Z a user request created an AutoScalingGroup changing the desired capacity from 0 to 1. At 2012-04-12T17:32:07Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1.</Cause>
- <Details>{}</Details>
- <Description>Launching a new EC2 instance. Status Reason: The image id 'ami-4edb0327' does not exist. Launching EC2 instance failed.</Description>
- <EndTime>2012-04-12T17:32:08Z</EndTime>
- <StatusMessage>The image id 'ami-4edb0327' does not exist. Launching EC2 instance failed.</StatusMessage>
- </member>
-</Activities>
- </DescribeScalingActivitiesResult>
- <ResponseMetadata>
- <RequestId>7a641adc-84c5-11e1-a8a5-217ebEXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeScalingActivitiesResponse>
-`
-var DescribeScalingProcessTypesResponse = `
-<DescribeScalingProcessTypesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeScalingProcessTypesResult>
- <Processes>
- <member>
- <ProcessName>AZRebalance</ProcessName>
- </member>
- <member>
- <ProcessName>AddToLoadBalancer</ProcessName>
- </member>
- <member>
- <ProcessName>AlarmNotification</ProcessName>
- </member>
- <member>
- <ProcessName>HealthCheck</ProcessName>
- </member>
- <member>
- <ProcessName>Launch</ProcessName>
- </member>
- <member>
- <ProcessName>ReplaceUnhealthy</ProcessName>
- </member>
- <member>
- <ProcessName>ScheduledActions</ProcessName>
- </member>
- <member>
- <ProcessName>Terminate</ProcessName>
- </member>
- </Processes>
- </DescribeScalingProcessTypesResult>
- <ResponseMetadata>
- <RequestId>27f2eacc-b73f-11e2-ad99-c7aba3a9c963</RequestId>
- </ResponseMetadata>
-</DescribeScalingProcessTypesResponse>
-`
-var DescribeScheduledActionsResponse = `
-<DescribeScheduledActionsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeScheduledActionsResult>
- <ScheduledUpdateGroupActions>
- <member>
- <ScheduledActionName>SATest1</ScheduledActionName>
- <StartTime>2014-06-01T00:30:00Z</StartTime>
- <Time>2014-06-01T00:30:00Z</Time>
- <ScheduledActionARN>arn:aws:autoscaling:us-west-2:193024542802:scheduledUpdateGroupAction:61f68b2c-bde3-4316-9a81-eb95dc246509:autoScalingGroupName/ASGTest1:scheduledActionName/SATest1</ScheduledActionARN>
- <AutoScalingGroupName>ASGTest1</AutoScalingGroupName>
- <Recurrence>30 0 1 1,6,12 *</Recurrence>
- <MaxSize>4</MaxSize>
- </member>
- </ScheduledUpdateGroupActions>
- </DescribeScheduledActionsResult>
- <ResponseMetadata>
- <RequestId>0eb4217f-8421-11e3-9233-7100ef811766</RequestId>
- </ResponseMetadata>
-</DescribeScheduledActionsResponse>
-`
-
-var DescribeTerminationPolicyTypesResponse = `
-<DescribeTerminationPolicyTypesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeTerminationPolicyTypesResult>
- <TerminationPolicyTypes>
- <member>ClosestToNextInstanceHour</member>
- <member>Default</member>
- <member>NewestInstance</member>
- <member>OldestInstance</member>
- <member>OldestLaunchConfiguration</member>
- </TerminationPolicyTypes>
- </DescribeTerminationPolicyTypesResult>
- <ResponseMetadata>
- <RequestId>d9a05827-b735-11e2-a40c-c79a5EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeTerminationPolicyTypesResponse>
-`
-var DescribeTagsResponse = `
-<DescribeTagsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DescribeTagsResult>
- <Tags>
- <member>
- <ResourceId>my-test-asg</ResourceId>
- <PropagateAtLaunch>true</PropagateAtLaunch>
- <Value>1.0</Value>
- <Key>version</Key>
- <ResourceType>auto-scaling-group</ResourceType>
- </member>
- </Tags>
- </DescribeTagsResult>
- <ResponseMetadata>
- <RequestId>086265fd-bf3e-11e2-85fc-fbb1EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeTagsResponse>
-`
-var DetachInstancesResponse = `
-<DetachInstancesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <DetachInstancesResult>
- <Activities>
- <member>
- <ActivityId>e54ff599-bf05-4076-8b95-a0f090ed90bb</ActivityId>
- <Progress>50</Progress>
- <StatusCode>InProgress</StatusCode>
- <StartTime>2014-06-14T00:07:30.280Z</StartTime>
- <Cause>At 2014-06-14T00:07:30Z instance i-5f2e8a0d was detached in response to a user request, shrinking the capacity from 4 to 3.</Cause>
- <AutoScalingGroupName>my-asg</AutoScalingGroupName>
- <Details>{"Availability Zone":"us-east-1a"}</Details>
- <Description>Detaching EC2 instance: i-5f2e8a0d</Description>
- </member>
- </Activities>
- </DetachInstancesResult>
- <ResponseMetadata>
- <RequestId>e04f3b11-f357-11e3-a434-7f10009d5849</RequestId>
- </ResponseMetadata>
-</DetachInstancesResponse>
-`
-var DisableMetricsCollectionResponse = `
-<DisableMetricsCollectionResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</DisableMetricsCollectionResponse>
-`
-var EnableMetricsCollectionResponse = `
-<EnableMetricsCollectionResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</EnableMetricsCollectionResponse>
-`
-var EnterStandbyResponse = `
-<EnterStandbyResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <EnterStandbyResult>
- <Activities>
- <member>
- <ActivityId>462b4bc3-ad3b-4e67-a58d-96cd00f02f9e</ActivityId>
- <Progress>50</Progress>
- <StatusCode>InProgress</StatusCode>
- <StartTime>2014-06-13T22:35:50.884Z</StartTime>
- <Cause>At 2014-06-13T22:35:50Z instance i-5b73d709 was moved to standby in response to a user request, shrinking the capacity from 4 to 3.</Cause>
- <AutoScalingGroupName>my-asg</AutoScalingGroupName>
- <Details>{"Availability Zone":"us-east-1a"}</Details>
- <Description>Moving EC2 instance to Standby: i-5b73d709</Description>
- </member>
- </Activities>
- </EnterStandbyResult>
- <ResponseMetadata>
- <RequestId>126f2f31-f34b-11e3-bc51-b35178f0274f</RequestId>
- </ResponseMetadata>
-</EnterStandbyResponse>
-`
-var ExecutePolicyResponse = `
-<EnableMetricsCollectionResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</EnableMetricsCollectionResponse>
-`
-var ExitStandbyResponse = `
-<ExitStandbyResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ExitStandbyResult>
- <Activities>
- <member>
- <ActivityId>dca4efcf-eea6-4844-8064-cab1fecd1aa2</ActivityId>
- <Progress>30</Progress>
- <StatusCode>PreInService</StatusCode>
- <StartTime>2014-06-13T22:43:53.523Z</StartTime>
- <Cause>At 2014-06-13T22:43:53Z instance i-5b73d709 was moved out of standby in response to a user request, increasing the capacity from 3 to 4.</Cause>
- <AutoScalingGroupName>my-asg</AutoScalingGroupName>
- <Details>{"Availability Zone":"us-east-1a"}</Details>
- <Description>Moving EC2 instance out of Standby: i-5b73d709</Description>
- </member>
- </Activities>
- </ExitStandbyResult>
- <ResponseMetadata>
- <RequestId>321a11c8-f34c-11e3-a434-7f10009d5849</RequestId>
- </ResponseMetadata>
-</ExitStandbyResponse>
-`
-var PutLifecycleHookResponse = `
-<PutLifecycleHookResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <PutLifecycleHookResult/>
- <ResponseMetadata>
- <RequestId>1952f458-f645-11e3-bc51-b35178f0274f</RequestId>
- </ResponseMetadata>
-</PutLifecycleHookResponse>
-`
-var PutNotificationConfigurationResponse = `
-<EnableMetricsCollectionResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</EnableMetricsCollectionResponse>
-`
-var PutScalingPolicyResponse = `
-<PutScalingPolicyResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <PutScalingPolicyResult>
- <PolicyARN>arn:aws:autoscaling:us-east-1:803981987763:scalingPolicy:b0dcf5e8-02e6-4e31-9719-0675d0dc31ae:autoScalingGroupName/my-test-asg:policyName/my-scaleout-policy</PolicyARN>
- </PutScalingPolicyResult>
- <ResponseMetadata>
- <RequestId>3cfc6fef-c08b-11e2-a697-2922EXAMPLE</RequestId>
- </ResponseMetadata>
-</PutScalingPolicyResponse>
-`
-var PutScheduledUpdateGroupActionResponse = `
-<PutScheduledUpdateGroupActionResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>3bc8c9bc-6a62-11e2-8a51-4b8a1EXAMPLE</RequestId>
- </ResponseMetadata>
- </PutScheduledUpdateGroupActionResponse>
- `
-var ResumeProcessesResponse = `
-<ResumeProcessesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</ResumeProcessesResponse>
-`
-var SetDesiredCapacityResponse = `
-<SetDesiredCapacityResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>9fb7e2db-6998-11e2-a985-57c82EXAMPLE</RequestId>
- </ResponseMetadata>
-</SetDesiredCapacityResponse>
-`
-var SetInstanceHealthResponse = `
-<SetInstanceHealthResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>9fb7e2db-6998-11e2-a985-57c82EXAMPLE</RequestId>
- </ResponseMetadata>
-</SetInstanceHealthResponse>
-`
-var SuspendProcessesResponse = `
-<SuspendProcessesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</SuspendProcessesResponse>
-`
-var TerminateInstanceInAutoScalingGroupResponse = `
-<TerminateInstanceInAutoScalingGroupResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <TerminateInstanceInAutoScalingGroupResult>
- <Activity>
- <StatusCode>InProgress</StatusCode>
- <ActivityId>cczc44a87-7d04-dsa15-31-d27c219864c5</ActivityId>
- <Progress>0</Progress>
- <StartTime>2014-01-26T14:08:30.560Z</StartTime>
- <Cause>At 2014-01-26T14:08:30Z instance i-br234123 was taken out of service in response to a user request.</Cause>
- <Details>{&quot;Availability Zone&quot;:&quot;us-east-1b&quot;}</Details>
- <Description>Terminating EC2 instance: i-br234123</Description>
- </Activity>
- </TerminateInstanceInAutoScalingGroupResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</TerminateInstanceInAutoScalingGroupResponse>
-`
-var UpdateAutoScalingGroupResponse = `
-<UpdateAutoScalingGroupResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</UpdateAutoScalingGroupResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/aws/attempt.go b/vendor/github.com/goamz/goamz/aws/attempt.go
deleted file mode 100644
index c0654f5d8..000000000
--- a/vendor/github.com/goamz/goamz/aws/attempt.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package aws
-
-import (
- "time"
-)
-
-// AttemptStrategy represents a strategy for waiting for an action
-// to complete successfully. This is an internal type used by the
-// implementation of other goamz packages.
-type AttemptStrategy struct {
- Total time.Duration // total duration of attempt.
- Delay time.Duration // interval between each try in the burst.
- Min int // minimum number of retries; overrides Total
-}
-
-type Attempt struct {
- strategy AttemptStrategy
- last time.Time
- end time.Time
- force bool
- count int
-}
-
-// Start begins a new sequence of attempts for the given strategy.
-func (s AttemptStrategy) Start() *Attempt {
- now := time.Now()
- return &Attempt{
- strategy: s,
- last: now,
- end: now.Add(s.Total),
- force: true,
- }
-}
-
-// Next waits until it is time to perform the next attempt or returns
-// false if it is time to stop trying.
-func (a *Attempt) Next() bool {
- now := time.Now()
- sleep := a.nextSleep(now)
- if !a.force && !now.Add(sleep).Before(a.end) && a.strategy.Min <= a.count {
- return false
- }
- a.force = false
- if sleep > 0 && a.count > 0 {
- time.Sleep(sleep)
- now = time.Now()
- }
- a.count++
- a.last = now
- return true
-}
-
-func (a *Attempt) nextSleep(now time.Time) time.Duration {
- sleep := a.strategy.Delay - now.Sub(a.last)
- if sleep < 0 {
- return 0
- }
- return sleep
-}
-
-// HasNext returns whether another attempt will be made if the current
-// one fails. If it returns true, the following call to Next is
-// guaranteed to return true.
-func (a *Attempt) HasNext() bool {
- if a.force || a.strategy.Min > a.count {
- return true
- }
- now := time.Now()
- if now.Add(a.nextSleep(now)).Before(a.end) {
- a.force = true
- return true
- }
- return false
-}
diff --git a/vendor/github.com/goamz/goamz/aws/attempt_test.go b/vendor/github.com/goamz/goamz/aws/attempt_test.go
deleted file mode 100644
index 8ba497715..000000000
--- a/vendor/github.com/goamz/goamz/aws/attempt_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package aws_test
-
-import (
- "time"
-
- "github.com/goamz/goamz/aws"
- . "gopkg.in/check.v1"
-)
-
-func (S) TestAttemptTiming(c *C) {
- testAttempt := aws.AttemptStrategy{
- Total: 0.25e9,
- Delay: 0.1e9,
- }
- want := []time.Duration{0, 0.1e9, 0.2e9, 0.2e9}
- got := make([]time.Duration, 0, len(want)) // avoid allocation when testing timing
- t0 := time.Now()
- for a := testAttempt.Start(); a.Next(); {
- got = append(got, time.Now().Sub(t0))
- }
- got = append(got, time.Now().Sub(t0))
- c.Assert(got, HasLen, len(want))
- const margin = 0.01e9
- for i, got := range want {
- lo := want[i] - margin
- hi := want[i] + margin
- if got < lo || got > hi {
- c.Errorf("attempt %d want %g got %g", i, want[i].Seconds(), got.Seconds())
- }
- }
-}
-
-func (S) TestAttemptNextHasNext(c *C) {
- a := aws.AttemptStrategy{}.Start()
- c.Assert(a.Next(), Equals, true)
- c.Assert(a.Next(), Equals, false)
-
- a = aws.AttemptStrategy{}.Start()
- c.Assert(a.Next(), Equals, true)
- c.Assert(a.HasNext(), Equals, false)
- c.Assert(a.Next(), Equals, false)
-
- a = aws.AttemptStrategy{Total: 2e8}.Start()
- c.Assert(a.Next(), Equals, true)
- c.Assert(a.HasNext(), Equals, true)
- time.Sleep(2e8)
- c.Assert(a.HasNext(), Equals, true)
- c.Assert(a.Next(), Equals, true)
- c.Assert(a.Next(), Equals, false)
-
- a = aws.AttemptStrategy{Total: 1e8, Min: 2}.Start()
- time.Sleep(1e8)
- c.Assert(a.Next(), Equals, true)
- c.Assert(a.HasNext(), Equals, true)
- c.Assert(a.Next(), Equals, true)
- c.Assert(a.HasNext(), Equals, false)
- c.Assert(a.Next(), Equals, false)
-}
diff --git a/vendor/github.com/goamz/goamz/aws/aws.go b/vendor/github.com/goamz/goamz/aws/aws.go
deleted file mode 100644
index a4d359160..000000000
--- a/vendor/github.com/goamz/goamz/aws/aws.go
+++ /dev/null
@@ -1,435 +0,0 @@
-//
-// goamz - Go packages to interact with the Amazon Web Services.
-//
-// https://wiki.ubuntu.com/goamz
-//
-// Copyright (c) 2011 Canonical Ltd.
-//
-// Written by Gustavo Niemeyer <gustavo.niemeyer@canonical.com>
-//
-package aws
-
-import (
- "encoding/json"
- "encoding/xml"
- "errors"
- "fmt"
- "io/ioutil"
- "net/http"
- "net/url"
- "os"
- "time"
-
- "github.com/vaughan0/go-ini"
-)
-
-// Defines the valid signers
-const (
- V2Signature = iota
- V4Signature = iota
- Route53Signature = iota
-)
-
-// Defines the service endpoint and correct Signer implementation to use
-// to sign requests for this endpoint
-type ServiceInfo struct {
- Endpoint string
- Signer uint
-}
-
-// Region defines the URLs where AWS services may be accessed.
-//
-// See http://goo.gl/d8BP1 for more details.
-type Region struct {
- Name string // the canonical name of this region.
- EC2Endpoint string
- S3Endpoint string
- S3BucketEndpoint string // Not needed by AWS S3. Use ${bucket} for bucket name.
- S3LocationConstraint bool // true if this region requires a LocationConstraint declaration.
- S3LowercaseBucket bool // true if the region requires bucket names to be lower case.
- SDBEndpoint string
- SESEndpoint string
- SNSEndpoint string
- SQSEndpoint string
- IAMEndpoint string
- ELBEndpoint string
- DynamoDBEndpoint string
- CloudWatchServicepoint ServiceInfo
- AutoScalingEndpoint string
- RDSEndpoint ServiceInfo
- STSEndpoint string
- CloudFormationEndpoint string
- ECSEndpoint string
- DynamoDBStreamsEndpoint string
-}
-
-var Regions = map[string]Region{
- APNortheast.Name: APNortheast,
- APNortheast2.Name: APNortheast2,
- APSoutheast.Name: APSoutheast,
- APSoutheast2.Name: APSoutheast2,
- EUCentral.Name: EUCentral,
- EUWest.Name: EUWest,
- USEast.Name: USEast,
- USEast2.Name: USEast2,
- USWest.Name: USWest,
- USWest2.Name: USWest2,
- USGovWest.Name: USGovWest,
- SAEast.Name: SAEast,
- CNNorth.Name: CNNorth,
-}
-
-// Designates a signer interface suitable for signing AWS requests, params
-// should be appropriately encoded for the request before signing.
-//
-// A signer should be initialized with Auth and the appropriate endpoint.
-type Signer interface {
- Sign(method, path string, params map[string]string)
-}
-
-// An AWS Service interface with the API to query the AWS service
-//
-// Supplied as an easy way to mock out service calls during testing.
-type AWSService interface {
- // Queries the AWS service at a given method/path with the params and
- // returns an http.Response and error
- Query(method, path string, params map[string]string) (*http.Response, error)
- // Builds an error given an XML payload in the http.Response, can be used
- // to process an error if the status code is not 200 for example.
- BuildError(r *http.Response) error
-}
-
-// Implements a Server Query/Post API to easily query AWS services and build
-// errors when desired
-type Service struct {
- service ServiceInfo
- signer Signer
-}
-
-// Create a base set of params for an action
-func MakeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-// Create a new AWS server to handle making requests
-func NewService(auth Auth, service ServiceInfo) (s *Service, err error) {
- var signer Signer
- switch service.Signer {
- case V2Signature:
- signer, err = NewV2Signer(auth, service)
- // case V4Signature:
- // signer, err = NewV4Signer(auth, service, Regions["eu-west-1"])
- default:
- err = fmt.Errorf("Unsupported signer for service")
- }
- if err != nil {
- return
- }
- s = &Service{service: service, signer: signer}
- return
-}
-
-func (s *Service) Query(method, path string, params map[string]string) (resp *http.Response, err error) {
- params["Timestamp"] = time.Now().UTC().Format(time.RFC3339)
- u, err := url.Parse(s.service.Endpoint)
- if err != nil {
- return nil, err
- }
- u.Path = path
-
- s.signer.Sign(method, path, params)
- if method == "GET" {
- u.RawQuery = multimap(params).Encode()
- resp, err = http.Get(u.String())
- } else if method == "POST" {
- resp, err = http.PostForm(u.String(), multimap(params))
- }
-
- return
-}
-
-func (s *Service) BuildError(r *http.Response) error {
- errors := ErrorResponse{}
- xml.NewDecoder(r.Body).Decode(&errors)
- var err Error
- err = errors.Errors
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-type ErrorResponse struct {
- Errors Error `xml:"Error"`
- RequestId string // A unique ID for tracking the request
-}
-
-type Error struct {
- StatusCode int
- Type string
- Code string
- Message string
- RequestId string
-}
-
-func (err *Error) Error() string {
- return fmt.Sprintf("Type: %s, Code: %s, Message: %s",
- err.Type, err.Code, err.Message,
- )
-}
-
-type Auth struct {
- AccessKey, SecretKey string
- token string
- expiration time.Time
-}
-
-func (a *Auth) Token() string {
- if a.token == "" {
- return ""
- }
- if time.Since(a.expiration) >= -30*time.Second { //in an ideal world this should be zero assuming the instance is synching it's clock
- *a, _ = GetAuth("", "", "", time.Time{})
- }
- return a.token
-}
-
-func (a *Auth) Expiration() time.Time {
- return a.expiration
-}
-
-// To be used with other APIs that return auth credentials such as STS
-func NewAuth(accessKey, secretKey, token string, expiration time.Time) *Auth {
- return &Auth{
- AccessKey: accessKey,
- SecretKey: secretKey,
- token: token,
- expiration: expiration,
- }
-}
-
-// ResponseMetadata
-type ResponseMetadata struct {
- RequestId string // A unique ID for tracking the request
-}
-
-type BaseResponse struct {
- ResponseMetadata ResponseMetadata
-}
-
-var unreserved = make([]bool, 128)
-var hex = "0123456789ABCDEF"
-
-func init() {
- // RFC3986
- u := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890-_.~"
- for _, c := range u {
- unreserved[c] = true
- }
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-type credentials struct {
- Code string
- LastUpdated string
- Type string
- AccessKeyId string
- SecretAccessKey string
- Token string
- Expiration string
-}
-
-// GetMetaData retrieves instance metadata about the current machine.
-//
-// See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html for more details.
-func GetMetaData(path string) (contents []byte, err error) {
- url := "http://169.254.169.254/latest/meta-data/" + path
-
- resp, err := RetryingClient.Get(url)
- if err != nil {
- return
- }
- defer resp.Body.Close()
-
- if resp.StatusCode != 200 {
- err = fmt.Errorf("Code %d returned for url %s", resp.StatusCode, url)
- return
- }
-
- body, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- return
- }
- return []byte(body), err
-}
-
-func getInstanceCredentials() (cred credentials, err error) {
- credentialPath := "iam/security-credentials/"
-
- // Get the instance role
- role, err := GetMetaData(credentialPath)
- if err != nil {
- return
- }
-
- // Get the instance role credentials
- credentialJSON, err := GetMetaData(credentialPath + string(role))
- if err != nil {
- return
- }
-
- err = json.Unmarshal([]byte(credentialJSON), &cred)
- return
-}
-
-// GetAuth creates an Auth based on either passed in credentials,
-// environment information or instance based role credentials.
-func GetAuth(accessKey string, secretKey, token string, expiration time.Time) (auth Auth, err error) {
- // First try passed in credentials
- if accessKey != "" && secretKey != "" {
- return Auth{accessKey, secretKey, token, expiration}, nil
- }
-
- // Next try to get auth from the shared credentials file
- auth, err = SharedAuth()
- if err == nil {
- // Found auth, return
- return
- }
-
- // Next try to get auth from the environment
- auth, err = EnvAuth()
- if err == nil {
- // Found auth, return
- return
- }
-
- // Next try getting auth from the instance role
- cred, err := getInstanceCredentials()
- if err == nil {
- // Found auth, return
- auth.AccessKey = cred.AccessKeyId
- auth.SecretKey = cred.SecretAccessKey
- auth.token = cred.Token
- exptdate, err := time.Parse("2006-01-02T15:04:05Z", cred.Expiration)
- if err != nil {
- err = fmt.Errorf("Error Parseing expiration date: cred.Expiration :%s , error: %s \n", cred.Expiration, err)
- }
- auth.expiration = exptdate
- return auth, err
- }
- err = errors.New("No valid AWS authentication found")
- return auth, err
-}
-
-// EnvAuth creates an Auth based on environment information.
-// The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment
-// variables are used.
-// AWS_SESSION_TOKEN is used if present.
-func EnvAuth() (auth Auth, err error) {
- auth.AccessKey = os.Getenv("AWS_ACCESS_KEY_ID")
- if auth.AccessKey == "" {
- auth.AccessKey = os.Getenv("AWS_ACCESS_KEY")
- }
-
- auth.SecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
- if auth.SecretKey == "" {
- auth.SecretKey = os.Getenv("AWS_SECRET_KEY")
- }
- if auth.AccessKey == "" {
- err = errors.New("AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment")
- }
- if auth.SecretKey == "" {
- err = errors.New("AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment")
- }
-
- auth.token = os.Getenv("AWS_SESSION_TOKEN")
- return
-}
-
-// SharedAuth creates an Auth based on shared credentials stored in
-// $HOME/.aws/credentials. The AWS_PROFILE environment variables is used to
-// select the profile.
-func SharedAuth() (auth Auth, err error) {
- var profileName = os.Getenv("AWS_PROFILE")
-
- if profileName == "" {
- profileName = "default"
- }
-
- var credentialsFile = os.Getenv("AWS_CREDENTIAL_FILE")
- if credentialsFile == "" {
- var homeDir = os.Getenv("HOME")
- if homeDir == "" {
- err = errors.New("Could not get HOME")
- return
- }
- credentialsFile = homeDir + "/.aws/credentials"
- }
-
- file, err := ini.LoadFile(credentialsFile)
- if err != nil {
- err = errors.New("Couldn't parse AWS credentials file")
- return
- }
-
- var profile = file[profileName]
- if profile == nil {
- err = errors.New("Couldn't find profile in AWS credentials file")
- return
- }
-
- auth.AccessKey = profile["aws_access_key_id"]
- auth.SecretKey = profile["aws_secret_access_key"]
- auth.token = profile["aws_session_token"]
-
- if auth.AccessKey == "" {
- err = errors.New("AWS_ACCESS_KEY_ID not found in environment in credentials file")
- }
- if auth.SecretKey == "" {
- err = errors.New("AWS_SECRET_ACCESS_KEY not found in credentials file")
- }
- return
-}
-
-// Encode takes a string and URI-encodes it in a way suitable
-// to be used in AWS signatures.
-func Encode(s string) string {
- encode := false
- for i := 0; i != len(s); i++ {
- c := s[i]
- if c > 127 || !unreserved[c] {
- encode = true
- break
- }
- }
- if !encode {
- return s
- }
- e := make([]byte, len(s)*3)
- ei := 0
- for i := 0; i != len(s); i++ {
- c := s[i]
- if c > 127 || !unreserved[c] {
- e[ei] = '%'
- e[ei+1] = hex[c>>4]
- e[ei+2] = hex[c&0xF]
- ei += 3
- } else {
- e[ei] = c
- ei += 1
- }
- }
- return string(e[:ei])
-}
diff --git a/vendor/github.com/goamz/goamz/aws/aws_test.go b/vendor/github.com/goamz/goamz/aws/aws_test.go
deleted file mode 100644
index 0c74a7905..000000000
--- a/vendor/github.com/goamz/goamz/aws/aws_test.go
+++ /dev/null
@@ -1,211 +0,0 @@
-package aws_test
-
-import (
- "io/ioutil"
- "os"
- "strings"
- "testing"
- "time"
-
- "github.com/goamz/goamz/aws"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- environ []string
-}
-
-func (s *S) SetUpSuite(c *C) {
- s.environ = os.Environ()
-}
-
-func (s *S) TearDownTest(c *C) {
- os.Clearenv()
- for _, kv := range s.environ {
- l := strings.SplitN(kv, "=", 2)
- os.Setenv(l[0], l[1])
- }
-}
-
-func (s *S) TestSharedAuthNoHome(c *C) {
- os.Clearenv()
- os.Setenv("AWS_PROFILE", "foo")
- _, err := aws.SharedAuth()
- c.Assert(err, ErrorMatches, "Could not get HOME")
-}
-
-func (s *S) TestSharedAuthNoCredentialsFile(c *C) {
- os.Clearenv()
- os.Setenv("AWS_PROFILE", "foo")
- os.Setenv("HOME", "/tmp")
- _, err := aws.SharedAuth()
- c.Assert(err, ErrorMatches, "Couldn't parse AWS credentials file")
-}
-
-func (s *S) TestSharedAuthNoProfileInFile(c *C) {
- os.Clearenv()
- os.Setenv("AWS_PROFILE", "foo")
-
- d, err := ioutil.TempDir("", "")
- if err != nil {
- panic(err)
- }
- defer os.RemoveAll(d)
-
- err = os.Mkdir(d+"/.aws", 0755)
- if err != nil {
- panic(err)
- }
-
- ioutil.WriteFile(d+"/.aws/credentials", []byte("[bar]\n"), 0644)
- os.Setenv("HOME", d)
-
- _, err = aws.SharedAuth()
- c.Assert(err, ErrorMatches, "Couldn't find profile in AWS credentials file")
-}
-
-func (s *S) TestSharedAuthNoKeysInProfile(c *C) {
- os.Clearenv()
- os.Setenv("AWS_PROFILE", "bar")
-
- d, err := ioutil.TempDir("", "")
- if err != nil {
- panic(err)
- }
- defer os.RemoveAll(d)
-
- err = os.Mkdir(d+"/.aws", 0755)
- if err != nil {
- panic(err)
- }
-
- ioutil.WriteFile(d+"/.aws/credentials", []byte("[bar]\nawsaccesskeyid = AK.."), 0644)
- os.Setenv("HOME", d)
-
- _, err = aws.SharedAuth()
- c.Assert(err, ErrorMatches, "AWS_SECRET_ACCESS_KEY not found in credentials file")
-}
-
-func (s *S) TestSharedAuthDefaultCredentials(c *C) {
- os.Clearenv()
-
- d, err := ioutil.TempDir("", "")
- if err != nil {
- panic(err)
- }
- defer os.RemoveAll(d)
-
- err = os.Mkdir(d+"/.aws", 0755)
- if err != nil {
- panic(err)
- }
-
- ioutil.WriteFile(d+"/.aws/credentials", []byte("[default]\naws_access_key_id = access\naws_secret_access_key = secret\n"), 0644)
- os.Setenv("HOME", d)
-
- auth, err := aws.SharedAuth()
- c.Assert(err, IsNil)
- c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
-}
-
-func (s *S) TestSharedAuth(c *C) {
- os.Clearenv()
- os.Setenv("AWS_PROFILE", "bar")
-
- d, err := ioutil.TempDir("", "")
- if err != nil {
- panic(err)
- }
- defer os.RemoveAll(d)
-
- err = os.Mkdir(d+"/.aws", 0755)
- if err != nil {
- panic(err)
- }
-
- ioutil.WriteFile(d+"/.aws/credentials", []byte("[bar]\naws_access_key_id = access\naws_secret_access_key = secret\n"), 0644)
- os.Setenv("HOME", d)
-
- auth, err := aws.SharedAuth()
- c.Assert(err, IsNil)
- c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
-}
-
-func (s *S) TestEnvAuthNoSecret(c *C) {
- os.Clearenv()
- _, err := aws.EnvAuth()
- c.Assert(err, ErrorMatches, "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment")
-}
-
-func (s *S) TestEnvAuthNoAccess(c *C) {
- os.Clearenv()
- os.Setenv("AWS_SECRET_ACCESS_KEY", "foo")
- _, err := aws.EnvAuth()
- c.Assert(err, ErrorMatches, "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment")
-}
-
-func (s *S) TestEnvAuth(c *C) {
- os.Clearenv()
- os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
- os.Setenv("AWS_ACCESS_KEY_ID", "access")
- auth, err := aws.EnvAuth()
- c.Assert(err, IsNil)
- c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
-}
-
-func (s *S) TestEnvAuthAlt(c *C) {
- os.Clearenv()
- os.Setenv("AWS_SECRET_KEY", "secret")
- os.Setenv("AWS_ACCESS_KEY", "access")
- auth, err := aws.EnvAuth()
- c.Assert(err, IsNil)
- c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
-}
-
-func (s *S) TestEnvAuthToken(c *C) {
- os.Clearenv()
- os.Setenv("AWS_SECRET_KEY", "secret")
- os.Setenv("AWS_ACCESS_KEY", "access")
- os.Setenv("AWS_SESSION_TOKEN", "token")
- auth, err := aws.EnvAuth()
- c.Assert(err, IsNil)
- c.Assert(auth.SecretKey, Equals, "secret")
- c.Assert(auth.AccessKey, Equals, "access")
- c.Assert(auth.Token(), Equals, "token")
-}
-
-func (s *S) TestGetAuthStatic(c *C) {
- exptdate := time.Now().Add(time.Hour)
- auth, err := aws.GetAuth("access", "secret", "token", exptdate)
- c.Assert(err, IsNil)
- c.Assert(auth.AccessKey, Equals, "access")
- c.Assert(auth.SecretKey, Equals, "secret")
- c.Assert(auth.Token(), Equals, "token")
- c.Assert(auth.Expiration(), Equals, exptdate)
-}
-
-func (s *S) TestGetAuthEnv(c *C) {
- os.Clearenv()
- os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
- os.Setenv("AWS_ACCESS_KEY_ID", "access")
- auth, err := aws.GetAuth("", "", "", time.Time{})
- c.Assert(err, IsNil)
- c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
-}
-
-func (s *S) TestEncode(c *C) {
- c.Assert(aws.Encode("foo"), Equals, "foo")
- c.Assert(aws.Encode("/"), Equals, "%2F")
-}
-
-func (s *S) TestRegionsAreNamed(c *C) {
- for n, r := range aws.Regions {
- c.Assert(n, Equals, r.Name)
- }
-}
diff --git a/vendor/github.com/goamz/goamz/aws/client.go b/vendor/github.com/goamz/goamz/aws/client.go
deleted file mode 100644
index 86d2ccec8..000000000
--- a/vendor/github.com/goamz/goamz/aws/client.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package aws
-
-import (
- "math"
- "net"
- "net/http"
- "time"
-)
-
-type RetryableFunc func(*http.Request, *http.Response, error) bool
-type WaitFunc func(try int)
-type DeadlineFunc func() time.Time
-
-type ResilientTransport struct {
- // Timeout is the maximum amount of time a dial will wait for
- // a connect to complete.
- //
- // The default is no timeout.
- //
- // With or without a timeout, the operating system may impose
- // its own earlier timeout. For instance, TCP timeouts are
- // often around 3 minutes.
- DialTimeout time.Duration
-
- // MaxTries, if non-zero, specifies the number of times we will retry on
- // failure. Retries are only attempted for temporary network errors or known
- // safe failures.
- MaxTries int
- Deadline DeadlineFunc
- ShouldRetry RetryableFunc
- Wait WaitFunc
- transport *http.Transport
-}
-
-// Convenience method for creating an http client
-func NewClient(rt *ResilientTransport) *http.Client {
- rt.transport = &http.Transport{
- Dial: func(netw, addr string) (net.Conn, error) {
- c, err := net.DialTimeout(netw, addr, rt.DialTimeout)
- if err != nil {
- return nil, err
- }
- c.SetDeadline(rt.Deadline())
- return c, nil
- },
- Proxy: http.ProxyFromEnvironment,
- }
- // TODO: Would be nice is ResilientTransport allowed clients to initialize
- // with http.Transport attributes.
- return &http.Client{
- Transport: rt,
- }
-}
-
-var retryingTransport = &ResilientTransport{
- Deadline: func() time.Time {
- return time.Now().Add(5 * time.Second)
- },
- DialTimeout: 10 * time.Second,
- MaxTries: 3,
- ShouldRetry: awsRetry,
- Wait: ExpBackoff,
-}
-
-// Exported default client
-var RetryingClient = NewClient(retryingTransport)
-
-func (t *ResilientTransport) RoundTrip(req *http.Request) (*http.Response, error) {
- return t.tries(req)
-}
-
-// Retry a request a maximum of t.MaxTries times.
-// We'll only retry if the proper criteria are met.
-// If a wait function is specified, wait that amount of time
-// In between requests.
-func (t *ResilientTransport) tries(req *http.Request) (res *http.Response, err error) {
- for try := 0; try < t.MaxTries; try += 1 {
- res, err = t.transport.RoundTrip(req)
-
- if !t.ShouldRetry(req, res, err) {
- break
- }
- if res != nil {
- res.Body.Close()
- }
- if t.Wait != nil {
- t.Wait(try)
- }
- }
-
- return
-}
-
-func ExpBackoff(try int) {
- time.Sleep(100 * time.Millisecond *
- time.Duration(math.Exp2(float64(try))))
-}
-
-func LinearBackoff(try int) {
- time.Sleep(time.Duration(try*100) * time.Millisecond)
-}
-
-// Decide if we should retry a request.
-// In general, the criteria for retrying a request is described here
-// http://docs.aws.amazon.com/general/latest/gr/api-retries.html
-func awsRetry(req *http.Request, res *http.Response, err error) bool {
- retry := false
-
- // Retry if there's a temporary network error.
- if neterr, ok := err.(net.Error); ok {
- if neterr.Temporary() {
- retry = true
- }
- }
-
- // Retry if we get a 5xx series error.
- if res != nil {
- if res.StatusCode >= 500 && res.StatusCode < 600 {
- retry = true
- }
- }
-
- return retry
-}
diff --git a/vendor/github.com/goamz/goamz/aws/client_test.go b/vendor/github.com/goamz/goamz/aws/client_test.go
deleted file mode 100644
index c66a86333..000000000
--- a/vendor/github.com/goamz/goamz/aws/client_test.go
+++ /dev/null
@@ -1,121 +0,0 @@
-package aws_test
-
-import (
- "fmt"
- "github.com/goamz/goamz/aws"
- "io/ioutil"
- "net/http"
- "net/http/httptest"
- "strings"
- "testing"
- "time"
-)
-
-// Retrieve the response from handler using aws.RetryingClient
-func serveAndGet(handler http.HandlerFunc) (body string, err error) {
- ts := httptest.NewServer(handler)
- defer ts.Close()
- resp, err := aws.RetryingClient.Get(ts.URL)
- if err != nil {
- return
- }
- if resp.StatusCode != 200 {
- return "", fmt.Errorf("Bad status code: %d", resp.StatusCode)
- }
- greeting, err := ioutil.ReadAll(resp.Body)
- resp.Body.Close()
- if err != nil {
- return
- }
- return strings.TrimSpace(string(greeting)), nil
-}
-
-func TestClient_expected(t *testing.T) {
- body := "foo bar"
-
- resp, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintln(w, body)
- })
- if err != nil {
- t.Fatal(err)
- }
- if resp != body {
- t.Fatal("Body not as expected.")
- }
-}
-
-func TestClient_delay(t *testing.T) {
- body := "baz"
- wait := 4
- resp, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
- if wait < 0 {
- // If we dipped to zero delay and still failed.
- t.Fatal("Never succeeded.")
- }
- wait -= 1
- time.Sleep(time.Second * time.Duration(wait))
- fmt.Fprintln(w, body)
- })
- if err != nil {
- t.Fatal(err)
- }
- if resp != body {
- t.Fatal("Body not as expected.", resp)
- }
-}
-
-func TestClient_no4xxRetry(t *testing.T) {
- tries := 0
-
- // Fail once before succeeding.
- _, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
- tries += 1
- http.Error(w, "error", 404)
- })
-
- if err == nil {
- t.Fatal("should have error")
- }
-
- if tries != 1 {
- t.Fatalf("should only try once: %d", tries)
- }
-}
-
-func TestClient_retries(t *testing.T) {
- body := "biz"
- failed := false
- // Fail once before succeeding.
- resp, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
- if !failed {
- http.Error(w, "error", 500)
- failed = true
- } else {
- fmt.Fprintln(w, body)
- }
- })
- if failed != true {
- t.Error("We didn't retry!")
- }
- if err != nil {
- t.Fatal(err)
- }
- if resp != body {
- t.Fatal("Body not as expected.")
- }
-}
-
-func TestClient_fails(t *testing.T) {
- tries := 0
- // Fail 3 times and return the last error.
- _, err := serveAndGet(func(w http.ResponseWriter, r *http.Request) {
- tries += 1
- http.Error(w, "error", 500)
- })
- if err == nil {
- t.Fatal(err)
- }
- if tries != 3 {
- t.Fatal("Didn't retry enough")
- }
-}
diff --git a/vendor/github.com/goamz/goamz/aws/export_test.go b/vendor/github.com/goamz/goamz/aws/export_test.go
deleted file mode 100644
index c4aca1d72..000000000
--- a/vendor/github.com/goamz/goamz/aws/export_test.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package aws
-
-import (
- "net/http"
- "time"
-)
-
-// V4Signer:
-// Exporting methods for testing
-
-func (s *V4Signer) RequestTime(req *http.Request) time.Time {
- return s.requestTime(req)
-}
-
-func (s *V4Signer) CanonicalRequest(req *http.Request) string {
- return s.canonicalRequest(req)
-}
-
-func (s *V4Signer) StringToSign(t time.Time, creq string) string {
- return s.stringToSign(t, creq)
-}
-
-func (s *V4Signer) Signature(t time.Time, sts string) string {
- return s.signature(t, sts)
-}
-
-func (s *V4Signer) Authorization(header http.Header, t time.Time, signature string) string {
- return s.authorization(header, t, signature)
-}
diff --git a/vendor/github.com/goamz/goamz/aws/regions.go b/vendor/github.com/goamz/goamz/aws/regions.go
deleted file mode 100644
index c75d41e11..000000000
--- a/vendor/github.com/goamz/goamz/aws/regions.go
+++ /dev/null
@@ -1,300 +0,0 @@
-package aws
-
-var USGovWest = Region{
- "us-gov-west-1",
- "https://ec2.us-gov-west-1.amazonaws.com",
- "https://s3-fips-us-gov-west-1.amazonaws.com",
- "",
- true,
- true,
- "",
- "",
- "https://sns.us-gov-west-1.amazonaws.com",
- "https://sqs.us-gov-west-1.amazonaws.com",
- "https://iam.us-gov.amazonaws.com",
- "https://elasticloadbalancing.us-gov-west-1.amazonaws.com",
- "https://dynamodb.us-gov-west-1.amazonaws.com",
- ServiceInfo{"https://monitoring.us-gov-west-1.amazonaws.com", V2Signature},
- "https://autoscaling.us-gov-west-1.amazonaws.com",
- ServiceInfo{"https://rds.us-gov-west-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.us-gov-west-1.amazonaws.com",
- "https://ecs.us-gov-west-1.amazonaws.com",
- "https://streams.dynamodb.us-gov-west-1.amazonaws.com",
-}
-
-var USEast = Region{
- "us-east-1",
- "https://ec2.us-east-1.amazonaws.com",
- "https://s3.amazonaws.com",
- "",
- false,
- false,
- "https://sdb.amazonaws.com",
- "https://email.us-east-1.amazonaws.com",
- "https://sns.us-east-1.amazonaws.com",
- "https://sqs.us-east-1.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.us-east-1.amazonaws.com",
- "https://dynamodb.us-east-1.amazonaws.com",
- ServiceInfo{"https://monitoring.us-east-1.amazonaws.com", V2Signature},
- "https://autoscaling.us-east-1.amazonaws.com",
- ServiceInfo{"https://rds.us-east-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.us-east-1.amazonaws.com",
- "https://ecs.us-east-1.amazonaws.com",
- "https://streams.dynamodb.us-east-1.amazonaws.com",
-}
-
-var USEast2 = Region{
- "us-east-2",
- "https://ec2.us-east-2.amazonaws.com",
- "https://s3.amazonaws.com",
- "",
- true,
- true,
- "",
- "",
- "https://sns.us-east-2.amazonaws.com",
- "https://sqs.us-east-2.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.us-east-2.amazonaws.com",
- "https://dynamodb.us-east-2.amazonaws.com",
- ServiceInfo{"https://monitoring.us-east-2.amazonaws.com", V2Signature},
- "https://autoscaling.us-east-1.amazonaws.com",
- ServiceInfo{"https://rds.us-east-2.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.us-east-2.amazonaws.com",
- "https://ecs.us-east-2.amazonaws.com",
- "https://streams.dynamodb.us-east-2.amazonaws.com",
-}
-
-var USWest = Region{
- "us-west-1",
- "https://ec2.us-west-1.amazonaws.com",
- "https://s3-us-west-1.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.us-west-1.amazonaws.com",
- "",
- "https://sns.us-west-1.amazonaws.com",
- "https://sqs.us-west-1.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.us-west-1.amazonaws.com",
- "https://dynamodb.us-west-1.amazonaws.com",
- ServiceInfo{"https://monitoring.us-west-1.amazonaws.com", V2Signature},
- "https://autoscaling.us-west-1.amazonaws.com",
- ServiceInfo{"https://rds.us-west-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.us-west-1.amazonaws.com",
- "https://ecs.us-west-1.amazonaws.com",
- "https://streams.dynamodb.us-west-1.amazonaws.com",
-}
-
-var USWest2 = Region{
- "us-west-2",
- "https://ec2.us-west-2.amazonaws.com",
- "https://s3-us-west-2.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.us-west-2.amazonaws.com",
- "https://email.us-west-2.amazonaws.com",
- "https://sns.us-west-2.amazonaws.com",
- "https://sqs.us-west-2.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.us-west-2.amazonaws.com",
- "https://dynamodb.us-west-2.amazonaws.com",
- ServiceInfo{"https://monitoring.us-west-2.amazonaws.com", V2Signature},
- "https://autoscaling.us-west-2.amazonaws.com",
- ServiceInfo{"https://rds.us-west-2.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.us-west-2.amazonaws.com",
- "https://ecs.us-west-2.amazonaws.com",
- "https://streams.dynamodb.us-west-2.amazonaws.com",
-}
-
-var EUWest = Region{
- "eu-west-1",
- "https://ec2.eu-west-1.amazonaws.com",
- "https://s3-eu-west-1.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.eu-west-1.amazonaws.com",
- "https://email.eu-west-1.amazonaws.com",
- "https://sns.eu-west-1.amazonaws.com",
- "https://sqs.eu-west-1.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.eu-west-1.amazonaws.com",
- "https://dynamodb.eu-west-1.amazonaws.com",
- ServiceInfo{"https://monitoring.eu-west-1.amazonaws.com", V2Signature},
- "https://autoscaling.eu-west-1.amazonaws.com",
- ServiceInfo{"https://rds.eu-west-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.eu-west-1.amazonaws.com",
- "https://ecs.eu-west-1.amazonaws.com",
- "https://streams.dynamodb.eu-west-1.amazonaws.com",
-}
-
-var EUCentral = Region{
- "eu-central-1",
- "https://ec2.eu-central-1.amazonaws.com",
- "https://s3-eu-central-1.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.eu-central-1.amazonaws.com",
- "https://email.eu-central-1.amazonaws.com",
- "https://sns.eu-central-1.amazonaws.com",
- "https://sqs.eu-central-1.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.eu-central-1.amazonaws.com",
- "https://dynamodb.eu-central-1.amazonaws.com",
- ServiceInfo{"https://monitoring.eu-central-1.amazonaws.com", V2Signature},
- "https://autoscaling.eu-central-1.amazonaws.com",
- ServiceInfo{"https://rds.eu-central-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.eu-central-1.amazonaws.com",
- "https://ecs.eu-central-1.amazonaws.com",
- "https://streams.dynamodb.eu-central-1.amazonaws.com",
-}
-
-var APSoutheast = Region{
- "ap-southeast-1",
- "https://ec2.ap-southeast-1.amazonaws.com",
- "https://s3-ap-southeast-1.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.ap-southeast-1.amazonaws.com",
- "",
- "https://sns.ap-southeast-1.amazonaws.com",
- "https://sqs.ap-southeast-1.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.ap-southeast-1.amazonaws.com",
- "https://dynamodb.ap-southeast-1.amazonaws.com",
- ServiceInfo{"https://monitoring.ap-southeast-1.amazonaws.com", V2Signature},
- "https://autoscaling.ap-southeast-1.amazonaws.com",
- ServiceInfo{"https://rds.ap-southeast-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.ap-southeast-1.amazonaws.com",
- "https://ecs.ap-southeast-1.amazonaws.com",
- "https://streams.dynamodb.ap-southeast-1.amazonaws.com",
-}
-
-var APSoutheast2 = Region{
- "ap-southeast-2",
- "https://ec2.ap-southeast-2.amazonaws.com",
- "https://s3-ap-southeast-2.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.ap-southeast-2.amazonaws.com",
- "",
- "https://sns.ap-southeast-2.amazonaws.com",
- "https://sqs.ap-southeast-2.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.ap-southeast-2.amazonaws.com",
- "https://dynamodb.ap-southeast-2.amazonaws.com",
- ServiceInfo{"https://monitoring.ap-southeast-2.amazonaws.com", V2Signature},
- "https://autoscaling.ap-southeast-2.amazonaws.com",
- ServiceInfo{"https://rds.ap-southeast-2.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.ap-southeast-2.amazonaws.com",
- "https://ecs.ap-southeast-2.amazonaws.com",
- "https://streams.dynamodb.ap-southeast-2.amazonaws.com",
-}
-
-var APNortheast = Region{
- "ap-northeast-1",
- "https://ec2.ap-northeast-1.amazonaws.com",
- "https://s3-ap-northeast-1.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.ap-northeast-1.amazonaws.com",
- "",
- "https://sns.ap-northeast-1.amazonaws.com",
- "https://sqs.ap-northeast-1.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.ap-northeast-1.amazonaws.com",
- "https://dynamodb.ap-northeast-1.amazonaws.com",
- ServiceInfo{"https://monitoring.ap-northeast-1.amazonaws.com", V2Signature},
- "https://autoscaling.ap-northeast-1.amazonaws.com",
- ServiceInfo{"https://rds.ap-northeast-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.ap-northeast-1.amazonaws.com",
- "https://ecs.ap-northeast-1.amazonaws.com",
- "https://streams.dynamodb.ap-northeast-1.amazonaws.com",
-}
-
-var APNortheast2 = Region{
- "ap-northeast-2",
- "https://ec2.ap-northeast-2.amazonaws.com",
- "https://s3-ap-northeast-2.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.ap-northeast-2.amazonaws.com",
- "",
- "https://sns.ap-northeast-2.amazonaws.com",
- "https://sqs.ap-northeast-2.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.ap-northeast-2.amazonaws.com",
- "https://dynamodb.ap-northeast-2.amazonaws.com",
- ServiceInfo{"https://monitoring.ap-northeast-2.amazonaws.com", V2Signature},
- "https://autoscaling.ap-northeast-2.amazonaws.com",
- ServiceInfo{"https://rds.ap-northeast-2.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.ap-northeast-2.amazonaws.com",
- "https://ecs.ap-northeast-2.amazonaws.com",
- "https://streams.dynamodb.ap-northeast-2.amazonaws.com",
-}
-
-var SAEast = Region{
- "sa-east-1",
- "https://ec2.sa-east-1.amazonaws.com",
- "https://s3-sa-east-1.amazonaws.com",
- "",
- true,
- true,
- "https://sdb.sa-east-1.amazonaws.com",
- "",
- "https://sns.sa-east-1.amazonaws.com",
- "https://sqs.sa-east-1.amazonaws.com",
- "https://iam.amazonaws.com",
- "https://elasticloadbalancing.sa-east-1.amazonaws.com",
- "https://dynamodb.sa-east-1.amazonaws.com",
- ServiceInfo{"https://monitoring.sa-east-1.amazonaws.com", V2Signature},
- "https://autoscaling.sa-east-1.amazonaws.com",
- ServiceInfo{"https://rds.sa-east-1.amazonaws.com", V2Signature},
- "https://sts.amazonaws.com",
- "https://cloudformation.sa-east-1.amazonaws.com",
- "https://ecs.sa-east-1.amazonaws.com",
- "https://streams.dynamodb.sa-east-1.amazonaws.com",
-}
-
-var CNNorth = Region{
- "cn-north-1",
- "https://ec2.cn-north-1.amazonaws.com.cn",
- "https://s3.cn-north-1.amazonaws.com.cn",
- "",
- true,
- true,
- "https://sdb.cn-north-1.amazonaws.com.cn",
- "",
- "https://sns.cn-north-1.amazonaws.com.cn",
- "https://sqs.cn-north-1.amazonaws.com.cn",
- "https://iam.cn-north-1.amazonaws.com.cn",
- "https://elasticloadbalancing.cn-north-1.amazonaws.com.cn",
- "https://dynamodb.cn-north-1.amazonaws.com.cn",
- ServiceInfo{"https://monitoring.cn-north-1.amazonaws.com.cn", V4Signature},
- "https://autoscaling.cn-north-1.amazonaws.com.cn",
- ServiceInfo{"https://rds.cn-north-1.amazonaws.com.cn", V4Signature},
- "https://sts.cn-north-1.amazonaws.com.cn",
- "https://cloudformation.cn-north-1.amazonaws.com.cn",
- "https://ecs.cn-north-1.amazonaws.com.cn",
- "https://streams.dynamodb.cn-north-1.amazonaws.com.cn",
-}
diff --git a/vendor/github.com/goamz/goamz/aws/sign.go b/vendor/github.com/goamz/goamz/aws/sign.go
deleted file mode 100644
index 22ce0781b..000000000
--- a/vendor/github.com/goamz/goamz/aws/sign.go
+++ /dev/null
@@ -1,357 +0,0 @@
-package aws
-
-import (
- "bytes"
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "fmt"
- "io/ioutil"
- "net/http"
- "net/url"
- "path"
- "sort"
- "strings"
- "time"
-)
-
-type V2Signer struct {
- auth Auth
- service ServiceInfo
- host string
-}
-
-var b64 = base64.StdEncoding
-
-func NewV2Signer(auth Auth, service ServiceInfo) (*V2Signer, error) {
- u, err := url.Parse(service.Endpoint)
- if err != nil {
- return nil, err
- }
- return &V2Signer{auth: auth, service: service, host: u.Host}, nil
-}
-
-func (s *V2Signer) Sign(method, path string, params map[string]string) {
- params["AWSAccessKeyId"] = s.auth.AccessKey
- params["SignatureVersion"] = "2"
- params["SignatureMethod"] = "HmacSHA256"
- if s.auth.Token() != "" {
- params["SecurityToken"] = s.auth.Token()
- }
-
- // AWS specifies that the parameters in a signed request must
- // be provided in the natural order of the keys. This is distinct
- // from the natural order of the encoded value of key=value.
- // Percent and Equals affect the sorting order.
- var keys, sarray []string
- for k, _ := range params {
- keys = append(keys, k)
- }
- sort.Strings(keys)
- for _, k := range keys {
- sarray = append(sarray, Encode(k)+"="+Encode(params[k]))
- }
- joined := strings.Join(sarray, "&")
- payload := method + "\n" + s.host + "\n" + path + "\n" + joined
- hash := hmac.New(sha256.New, []byte(s.auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- params["Signature"] = string(signature)
-}
-
-// Common date formats for signing requests
-const (
- ISO8601BasicFormat = "20060102T150405Z"
- ISO8601BasicFormatShort = "20060102"
-)
-
-type Route53Signer struct {
- auth Auth
-}
-
-func NewRoute53Signer(auth Auth) *Route53Signer {
- return &Route53Signer{auth: auth}
-}
-
-// getCurrentDate fetches the date stamp from the aws servers to
-// ensure the auth headers are within 5 minutes of the server time
-func (s *Route53Signer) getCurrentDate() string {
- response, err := http.Get("https://route53.amazonaws.com/date")
- if err != nil {
- fmt.Print("Unable to get date from amazon: ", err)
- return ""
- }
-
- response.Body.Close()
- return response.Header.Get("Date")
-}
-
-// Creates the authorize signature based on the date stamp and secret key
-func (s *Route53Signer) getHeaderAuthorize(message string) string {
- hmacSha256 := hmac.New(sha256.New, []byte(s.auth.SecretKey))
- hmacSha256.Write([]byte(message))
- cryptedString := hmacSha256.Sum(nil)
-
- return base64.StdEncoding.EncodeToString(cryptedString)
-}
-
-// Adds all the required headers for AWS Route53 API to the request
-// including the authorization
-func (s *Route53Signer) Sign(req *http.Request) {
- date := s.getCurrentDate()
- authHeader := fmt.Sprintf("AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=%s,Signature=%s",
- s.auth.AccessKey, "HmacSHA256", s.getHeaderAuthorize(date))
-
- req.Header.Set("Host", req.Host)
- req.Header.Set("X-Amzn-Authorization", authHeader)
- req.Header.Set("X-Amz-Date", date)
- req.Header.Set("Content-Type", "application/xml")
-}
-
-/*
-The V4Signer encapsulates all of the functionality to sign a request with the AWS
-Signature Version 4 Signing Process. (http://goo.gl/u1OWZz)
-*/
-type V4Signer struct {
- auth Auth
- serviceName string
- region Region
-}
-
-/*
-Return a new instance of a V4Signer capable of signing AWS requests.
-*/
-func NewV4Signer(auth Auth, serviceName string, region Region) *V4Signer {
- return &V4Signer{auth: auth, serviceName: serviceName, region: region}
-}
-
-/*
-Sign a request according to the AWS Signature Version 4 Signing Process. (http://goo.gl/u1OWZz)
-
-The signed request will include an "x-amz-date" header with a current timestamp if a valid "x-amz-date"
-or "date" header was not available in the original request. In addition, AWS Signature Version 4 requires
-the "host" header to be a signed header, therefor the Sign method will manually set a "host" header from
-the request.Host.
-
-The signed request will include a new "Authorization" header indicating that the request has been signed.
-
-Any changes to the request after signing the request will invalidate the signature.
-*/
-func (s *V4Signer) Sign(req *http.Request) {
- req.Header.Set("host", req.Host) // host header must be included as a signed header
- t := s.requestTime(req) // Get requst time
- creq := s.canonicalRequest(req) // Build canonical request
- sts := s.stringToSign(t, creq) // Build string to sign
- signature := s.signature(t, sts) // Calculate the AWS Signature Version 4
- auth := s.authorization(req.Header, t, signature) // Create Authorization header value
- req.Header.Set("Authorization", auth) // Add Authorization header to request
- return
-}
-
-/*
-requestTime method will parse the time from the request "x-amz-date" or "date" headers.
-If the "x-amz-date" header is present, that will take priority over the "date" header.
-If neither header is defined or we are unable to parse either header as a valid date
-then we will create a new "x-amz-date" header with the current time.
-*/
-func (s *V4Signer) requestTime(req *http.Request) time.Time {
-
- // Get "x-amz-date" header
- date := req.Header.Get("x-amz-date")
-
- // Attempt to parse as ISO8601BasicFormat
- t, err := time.Parse(ISO8601BasicFormat, date)
- if err == nil {
- return t
- }
-
- // Attempt to parse as http.TimeFormat
- t, err = time.Parse(http.TimeFormat, date)
- if err == nil {
- req.Header.Set("x-amz-date", t.Format(ISO8601BasicFormat))
- return t
- }
-
- // Get "date" header
- date = req.Header.Get("date")
-
- // Attempt to parse as http.TimeFormat
- t, err = time.Parse(http.TimeFormat, date)
- if err == nil {
- return t
- }
-
- // Create a current time header to be used
- t = time.Now().UTC()
- req.Header.Set("x-amz-date", t.Format(ISO8601BasicFormat))
- return t
-}
-
-/*
-canonicalRequest method creates the canonical request according to Task 1 of the AWS Signature Version 4 Signing Process. (http://goo.gl/eUUZ3S)
-
- CanonicalRequest =
- HTTPRequestMethod + '\n' +
- CanonicalURI + '\n' +
- CanonicalQueryString + '\n' +
- CanonicalHeaders + '\n' +
- SignedHeaders + '\n' +
- HexEncode(Hash(Payload))
-*/
-func (s *V4Signer) canonicalRequest(req *http.Request) string {
- c := new(bytes.Buffer)
- fmt.Fprintf(c, "%s\n", req.Method)
- fmt.Fprintf(c, "%s\n", s.canonicalURI(req.URL))
- fmt.Fprintf(c, "%s\n", s.canonicalQueryString(req.URL))
- fmt.Fprintf(c, "%s\n\n", s.canonicalHeaders(req.Header))
- fmt.Fprintf(c, "%s\n", s.signedHeaders(req.Header))
- fmt.Fprintf(c, "%s", s.payloadHash(req))
- return c.String()
-}
-
-func (s *V4Signer) canonicalURI(u *url.URL) string {
- canonicalPath := u.RequestURI()
- if u.RawQuery != "" {
- canonicalPath = canonicalPath[:len(canonicalPath)-len(u.RawQuery)-1]
- }
- slash := strings.HasSuffix(canonicalPath, "/")
- canonicalPath = path.Clean(canonicalPath)
- if canonicalPath != "/" && slash {
- canonicalPath += "/"
- }
- return canonicalPath
-}
-
-func (s *V4Signer) canonicalQueryString(u *url.URL) string {
- var a []string
- for k, vs := range u.Query() {
- k = Encode(k)
- for _, v := range vs {
- if v == "" {
- a = append(a, k+"=")
- } else {
- v = Encode(v)
- a = append(a, k+"="+v)
- }
- }
- }
- sort.Strings(a)
- return strings.Join(a, "&")
-}
-
-func (s *V4Signer) canonicalHeaders(h http.Header) string {
- i, a := 0, make([]string, len(h))
- for k, v := range h {
- for j, w := range v {
- v[j] = strings.Trim(w, " ")
- }
- sort.Strings(v)
- a[i] = strings.ToLower(k) + ":" + strings.Join(v, ",")
- i++
- }
- sort.Strings(a)
- return strings.Join(a, "\n")
-}
-
-func (s *V4Signer) signedHeaders(h http.Header) string {
- i, a := 0, make([]string, len(h))
- for k, _ := range h {
- a[i] = strings.ToLower(k)
- i++
- }
- sort.Strings(a)
- return strings.Join(a, ";")
-}
-
-func (s *V4Signer) payloadHash(req *http.Request) string {
- var b []byte
- if req.Body == nil {
- b = []byte("")
- } else {
- var err error
- b, err = ioutil.ReadAll(req.Body)
- if err != nil {
- // TODO: I REALLY DON'T LIKE THIS PANIC!!!!
- panic(err)
- }
- }
- req.Body = ioutil.NopCloser(bytes.NewBuffer(b))
- return s.hash(string(b))
-}
-
-/*
-stringToSign method creates the string to sign accorting to Task 2 of the AWS Signature Version 4 Signing Process. (http://goo.gl/es1PAu)
-
- StringToSign =
- Algorithm + '\n' +
- RequestDate + '\n' +
- CredentialScope + '\n' +
- HexEncode(Hash(CanonicalRequest))
-*/
-func (s *V4Signer) stringToSign(t time.Time, creq string) string {
- w := new(bytes.Buffer)
- fmt.Fprint(w, "AWS4-HMAC-SHA256\n")
- fmt.Fprintf(w, "%s\n", t.Format(ISO8601BasicFormat))
- fmt.Fprintf(w, "%s\n", s.credentialScope(t))
- fmt.Fprintf(w, "%s", s.hash(creq))
- return w.String()
-}
-
-func (s *V4Signer) credentialScope(t time.Time) string {
- return fmt.Sprintf("%s/%s/%s/aws4_request", t.Format(ISO8601BasicFormatShort), s.region.Name, s.serviceName)
-}
-
-/*
-signature method calculates the AWS Signature Version 4 according to Task 3 of the AWS Signature Version 4 Signing Process. (http://goo.gl/j0Yqe1)
-
- signature = HexEncode(HMAC(derived-signing-key, string-to-sign))
-*/
-func (s *V4Signer) signature(t time.Time, sts string) string {
- h := s.hmac(s.derivedKey(t), []byte(sts))
- return fmt.Sprintf("%x", h)
-}
-
-/*
-derivedKey method derives a signing key to be used for signing a request.
-
- kSecret = Your AWS Secret Access Key
- kDate = HMAC("AWS4" + kSecret, Date)
- kRegion = HMAC(kDate, Region)
- kService = HMAC(kRegion, Service)
- kSigning = HMAC(kService, "aws4_request")
-*/
-func (s *V4Signer) derivedKey(t time.Time) []byte {
- h := s.hmac([]byte("AWS4"+s.auth.SecretKey), []byte(t.Format(ISO8601BasicFormatShort)))
- h = s.hmac(h, []byte(s.region.Name))
- h = s.hmac(h, []byte(s.serviceName))
- h = s.hmac(h, []byte("aws4_request"))
- return h
-}
-
-/*
-authorization method generates the authorization header value.
-*/
-func (s *V4Signer) authorization(header http.Header, t time.Time, signature string) string {
- w := new(bytes.Buffer)
- fmt.Fprint(w, "AWS4-HMAC-SHA256 ")
- fmt.Fprintf(w, "Credential=%s/%s, ", s.auth.AccessKey, s.credentialScope(t))
- fmt.Fprintf(w, "SignedHeaders=%s, ", s.signedHeaders(header))
- fmt.Fprintf(w, "Signature=%s", signature)
- return w.String()
-}
-
-// hash method calculates the sha256 hash for a given string
-func (s *V4Signer) hash(in string) string {
- h := sha256.New()
- fmt.Fprintf(h, "%s", in)
- return fmt.Sprintf("%x", h.Sum(nil))
-}
-
-// hmac method calculates the sha256 hmac for a given slice of bytes
-func (s *V4Signer) hmac(key, data []byte) []byte {
- h := hmac.New(sha256.New, key)
- h.Write(data)
- return h.Sum(nil)
-}
diff --git a/vendor/github.com/goamz/goamz/aws/sign_test.go b/vendor/github.com/goamz/goamz/aws/sign_test.go
deleted file mode 100644
index 4ce2ff9a0..000000000
--- a/vendor/github.com/goamz/goamz/aws/sign_test.go
+++ /dev/null
@@ -1,540 +0,0 @@
-package aws_test
-
-import (
- "fmt"
- "net/http"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
- . "gopkg.in/check.v1"
-)
-
-var _ = Suite(&V4SignerSuite{})
-
-type V4SignerSuite struct {
- auth aws.Auth
- region aws.Region
- cases []V4SignerSuiteCase
-}
-
-type V4SignerSuiteCase struct {
- label string
- request V4SignerSuiteCaseRequest
- canonicalRequest string
- stringToSign string
- signature string
- authorization string
-}
-
-type V4SignerSuiteCaseRequest struct {
- method string
- host string
- url string
- headers []string
- body string
-}
-
-func (s *V4SignerSuite) SetUpSuite(c *C) {
- s.auth = aws.Auth{AccessKey: "AKIDEXAMPLE", SecretKey: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"}
- s.region = aws.USEast
-
- // Test cases from the Signature Version 4 Test Suite (http://goo.gl/nguvs0)
- s.cases = append(s.cases,
-
- // get-header-key-duplicate
- V4SignerSuiteCase{
- label: "get-header-key-duplicate",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"DATE:Mon, 09 Sep 2011 23:36:00 GMT", "ZOO:zoobar", "zoo:foobar", "zoo:zoobar"},
- },
- canonicalRequest: "POST\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\nzoo:foobar,zoobar,zoobar\n\ndate;host;zoo\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n3c52f0eaae2b61329c0a332e3fa15842a37bc5812cf4d80eb64784308850e313",
- signature: "54afcaaf45b331f81cd2edb974f7b824ff4dd594cbbaa945ed636b48477368ed",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host;zoo, Signature=54afcaaf45b331f81cd2edb974f7b824ff4dd594cbbaa945ed636b48477368ed",
- },
-
- // get-header-value-order
- V4SignerSuiteCase{
- label: "get-header-value-order",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"DATE:Mon, 09 Sep 2011 23:36:00 GMT", "p:z", "p:a", "p:p", "p:a"},
- },
- canonicalRequest: "POST\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\np:a,a,p,z\n\ndate;host;p\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n94c0389fefe0988cbbedc8606f0ca0b485b48da010d09fc844b45b697c8924fe",
- signature: "d2973954263943b11624a11d1c963ca81fb274169c7868b2858c04f083199e3d",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host;p, Signature=d2973954263943b11624a11d1c963ca81fb274169c7868b2858c04f083199e3d",
- },
-
- // get-header-value-trim
- V4SignerSuiteCase{
- label: "get-header-value-trim",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"DATE:Mon, 09 Sep 2011 23:36:00 GMT", "p: phfft "},
- },
- canonicalRequest: "POST\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\np:phfft\n\ndate;host;p\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\ndddd1902add08da1ac94782b05f9278c08dc7468db178a84f8950d93b30b1f35",
- signature: "debf546796015d6f6ded8626f5ce98597c33b47b9164cf6b17b4642036fcb592",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host;p, Signature=debf546796015d6f6ded8626f5ce98597c33b47b9164cf6b17b4642036fcb592",
- },
-
- // get-relative-relative
- V4SignerSuiteCase{
- label: "get-relative-relative",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/foo/bar/../..",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n366b91fb121d72a00f46bbe8d395f53a102b06dfb7e79636515208ed3fa606b1",
- signature: "b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- },
-
- // get-relative
- V4SignerSuiteCase{
- label: "get-relative",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/foo/..",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n366b91fb121d72a00f46bbe8d395f53a102b06dfb7e79636515208ed3fa606b1",
- signature: "b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- },
-
- // get-slash-dot-slash
- V4SignerSuiteCase{
- label: "get-slash-dot-slash",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/./",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n366b91fb121d72a00f46bbe8d395f53a102b06dfb7e79636515208ed3fa606b1",
- signature: "b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- },
-
- // get-slash-pointless-dot
- V4SignerSuiteCase{
- label: "get-slash-pointless-dot",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/./foo",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/foo\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n8021a97572ee460f87ca67f4e8c0db763216d84715f5424a843a5312a3321e2d",
- signature: "910e4d6c9abafaf87898e1eb4c929135782ea25bb0279703146455745391e63a",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=910e4d6c9abafaf87898e1eb4c929135782ea25bb0279703146455745391e63a",
- },
-
- // get-slash
- V4SignerSuiteCase{
- label: "get-slash",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "//",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n366b91fb121d72a00f46bbe8d395f53a102b06dfb7e79636515208ed3fa606b1",
- signature: "b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- },
-
- // get-slashes
- V4SignerSuiteCase{
- label: "get-slashes",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "//foo//",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/foo/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n6bb4476ee8745730c9cb79f33a0c70baa6d8af29c0077fa12e4e8f1dd17e7098",
- signature: "b00392262853cfe3201e47ccf945601079e9b8a7f51ee4c3d9ee4f187aa9bf19",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b00392262853cfe3201e47ccf945601079e9b8a7f51ee4c3d9ee4f187aa9bf19",
- },
-
- // get-space
- V4SignerSuiteCase{
- label: "get-space",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/%20/foo",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/%20/foo\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n69c45fb9fe3fd76442b5086e50b2e9fec8298358da957b293ef26e506fdfb54b",
- signature: "f309cfbd10197a230c42dd17dbf5cca8a0722564cb40a872d25623cfa758e374",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=f309cfbd10197a230c42dd17dbf5cca8a0722564cb40a872d25623cfa758e374",
- },
-
- // get-unreserved
- V4SignerSuiteCase{
- label: "get-unreserved",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\ndf63ee3247c0356c696a3b21f8d8490b01fa9cd5bc6550ef5ef5f4636b7b8901",
- signature: "830cc36d03f0f84e6ee4953fbe701c1c8b71a0372c63af9255aa364dd183281e",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=830cc36d03f0f84e6ee4953fbe701c1c8b71a0372c63af9255aa364dd183281e",
- },
-
- // get-utf8
- V4SignerSuiteCase{
- label: "get-utf8",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/%E1%88%B4",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/%E1%88%B4\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n27ba31df5dbc6e063d8f87d62eb07143f7f271c5330a917840586ac1c85b6f6b",
- signature: "8d6634c189aa8c75c2e51e106b6b5121bed103fdb351f7d7d4381c738823af74",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=8d6634c189aa8c75c2e51e106b6b5121bed103fdb351f7d7d4381c738823af74",
- },
-
- // get-vanilla-empty-query-key
- V4SignerSuiteCase{
- label: "get-vanilla-empty-query-key",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/?foo=bar",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\nfoo=bar\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n0846c2945b0832deb7a463c66af5c4f8bd54ec28c438e67a214445b157c9ddf8",
- signature: "56c054473fd260c13e4e7393eb203662195f5d4a1fada5314b8b52b23f985e9f",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=56c054473fd260c13e4e7393eb203662195f5d4a1fada5314b8b52b23f985e9f",
- },
-
- // get-vanilla-space-query-parameters
- V4SignerSuiteCase{
- label: "get-vanilla-space-query-parameters",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/?foo foo=bar bar",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\nfoo%20foo=bar%20bar\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n6a81658ae0a0a4f73aa72ca7d3b01c9cb0c5d4099f7a5ee897f5a571bfe6f7ff",
- signature: "c8556bc676129d0806ea8fe6ef182dc095666f4c1582c3d9751d47e4306037c9",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=c8556bc676129d0806ea8fe6ef182dc095666f4c1582c3d9751d47e4306037c9",
- },
-
- // get-vanilla-query-order-key-case
- V4SignerSuiteCase{
- label: "get-vanilla-query-order-key-case",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/?foo=Zoo&foo=aha",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\nfoo=Zoo&foo=aha\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\ne25f777ba161a0f1baf778a87faf057187cf5987f17953320e3ca399feb5f00d",
- signature: "be7148d34ebccdc6423b19085378aa0bee970bdc61d144bd1a8c48c33079ab09",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=be7148d34ebccdc6423b19085378aa0bee970bdc61d144bd1a8c48c33079ab09",
- },
-
- // get-vanilla-query-order-key
- V4SignerSuiteCase{
- label: "get-vanilla-query-order-key",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/?a=foo&b=foo",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\na=foo&b=foo\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n2f23d14fe13caebf6dfda346285c6d9c14f49eaca8f5ec55c627dd7404f7a727",
- signature: "0dc122f3b28b831ab48ba65cb47300de53fbe91b577fe113edac383730254a3b",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=0dc122f3b28b831ab48ba65cb47300de53fbe91b577fe113edac383730254a3b",
- },
-
- // get-vanilla-query-order-value
- V4SignerSuiteCase{
- label: "get-vanilla-query-order-value",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/?foo=b&foo=a",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\nfoo=a&foo=b\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n33dffc220e89131f8f6157a35c40903daa658608d9129ff9489e5cf5bbd9b11b",
- signature: "feb926e49e382bec75c9d7dcb2a1b6dc8aa50ca43c25d2bc51143768c0875acc",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=feb926e49e382bec75c9d7dcb2a1b6dc8aa50ca43c25d2bc51143768c0875acc",
- },
-
- // get-vanilla-query-unreserved
- V4SignerSuiteCase{
- label: "get-vanilla-query-unreserved",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/?-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\nd2578f3156d4c9d180713d1ff20601d8a3eed0dd35447d24603d7d67414bd6b5",
- signature: "f1498ddb4d6dae767d97c466fb92f1b59a2c71ca29ac954692663f9db03426fb",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=f1498ddb4d6dae767d97c466fb92f1b59a2c71ca29ac954692663f9db03426fb",
- },
-
- // get-vanilla-query
- V4SignerSuiteCase{
- label: "get-vanilla-query",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n366b91fb121d72a00f46bbe8d395f53a102b06dfb7e79636515208ed3fa606b1",
- signature: "b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- },
-
- // get-vanilla-ut8-query
- V4SignerSuiteCase{
- label: "get-vanilla-ut8-query",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/?ሴ=bar",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n%E1%88%B4=bar\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\nde5065ff39c131e6c2e2bd19cd9345a794bf3b561eab20b8d97b2093fc2a979e",
- signature: "6fb359e9a05394cc7074e0feb42573a2601abc0c869a953e8c5c12e4e01f1a8c",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=6fb359e9a05394cc7074e0feb42573a2601abc0c869a953e8c5c12e4e01f1a8c",
- },
-
- // get-vanilla
- V4SignerSuiteCase{
- label: "get-vanilla",
- request: V4SignerSuiteCaseRequest{
- method: "GET",
- host: "host.foo.com",
- url: "/",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "GET\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n366b91fb121d72a00f46bbe8d395f53a102b06dfb7e79636515208ed3fa606b1",
- signature: "b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470",
- },
-
- // post-header-key-case
- V4SignerSuiteCase{
- label: "post-header-key-case",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"DATE:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "POST\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n05da62cee468d24ae84faff3c39f1b85540de60243c1bcaace39c0a2acc7b2c4",
- signature: "22902d79e148b64e7571c3565769328423fe276eae4b26f83afceda9e767f726",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=22902d79e148b64e7571c3565769328423fe276eae4b26f83afceda9e767f726",
- },
-
- // post-header-key-sort
- V4SignerSuiteCase{
- label: "post-header-key-sort",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"DATE:Mon, 09 Sep 2011 23:36:00 GMT", "ZOO:zoobar"},
- },
- canonicalRequest: "POST\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\nzoo:zoobar\n\ndate;host;zoo\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n34e1bddeb99e76ee01d63b5e28656111e210529efeec6cdfd46a48e4c734545d",
- signature: "b7a95a52518abbca0964a999a880429ab734f35ebbf1235bd79a5de87756dc4a",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host;zoo, Signature=b7a95a52518abbca0964a999a880429ab734f35ebbf1235bd79a5de87756dc4a",
- },
-
- // post-header-value-case
- V4SignerSuiteCase{
- label: "post-header-value-case",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"DATE:Mon, 09 Sep 2011 23:36:00 GMT", "zoo:ZOOBAR"},
- },
- canonicalRequest: "POST\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\nzoo:ZOOBAR\n\ndate;host;zoo\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n3aae6d8274b8c03e2cc96fc7d6bda4b9bd7a0a184309344470b2c96953e124aa",
- signature: "273313af9d0c265c531e11db70bbd653f3ba074c1009239e8559d3987039cad7",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host;zoo, Signature=273313af9d0c265c531e11db70bbd653f3ba074c1009239e8559d3987039cad7",
- },
-
- // post-vanilla-empty-query-value
- V4SignerSuiteCase{
- label: "post-vanilla-empty-query-value",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/?foo=bar",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "POST\n/\nfoo=bar\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\ncd4f39132d8e60bb388831d734230460872b564871c47f5de62e62d1a68dbe1e",
- signature: "b6e3b79003ce0743a491606ba1035a804593b0efb1e20a11cba83f8c25a57a92",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b6e3b79003ce0743a491606ba1035a804593b0efb1e20a11cba83f8c25a57a92",
- },
-
- // post-vanilla-query
- V4SignerSuiteCase{
- label: "post-vanilla-query",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/?foo=bar",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "POST\n/\nfoo=bar\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\ncd4f39132d8e60bb388831d734230460872b564871c47f5de62e62d1a68dbe1e",
- signature: "b6e3b79003ce0743a491606ba1035a804593b0efb1e20a11cba83f8c25a57a92",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b6e3b79003ce0743a491606ba1035a804593b0efb1e20a11cba83f8c25a57a92",
- },
-
- // post-vanilla
- V4SignerSuiteCase{
- label: "post-vanilla",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- },
- canonicalRequest: "POST\n/\n\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ndate;host\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n05da62cee468d24ae84faff3c39f1b85540de60243c1bcaace39c0a2acc7b2c4",
- signature: "22902d79e148b64e7571c3565769328423fe276eae4b26f83afceda9e767f726",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=22902d79e148b64e7571c3565769328423fe276eae4b26f83afceda9e767f726",
- },
-
- // post-x-www-form-urlencoded-parameters
- V4SignerSuiteCase{
- label: "post-x-www-form-urlencoded-parameters",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"Content-Type:application/x-www-form-urlencoded; charset=utf8", "Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- body: "foo=bar",
- },
- canonicalRequest: "POST\n/\n\ncontent-type:application/x-www-form-urlencoded; charset=utf8\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ncontent-type;date;host\n3ba8907e7a252327488df390ed517c45b96dead033600219bdca7107d1d3f88a",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\nc4115f9e54b5cecf192b1eaa23b8e88ed8dc5391bd4fde7b3fff3d9c9fe0af1f",
- signature: "b105eb10c6d318d2294de9d49dd8b031b55e3c3fe139f2e637da70511e9e7b71",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=content-type;date;host, Signature=b105eb10c6d318d2294de9d49dd8b031b55e3c3fe139f2e637da70511e9e7b71",
- },
-
- // post-x-www-form-urlencoded
- V4SignerSuiteCase{
- label: "post-x-www-form-urlencoded",
- request: V4SignerSuiteCaseRequest{
- method: "POST",
- host: "host.foo.com",
- url: "/",
- headers: []string{"Content-Type:application/x-www-form-urlencoded", "Date:Mon, 09 Sep 2011 23:36:00 GMT"},
- body: "foo=bar",
- },
- canonicalRequest: "POST\n/\n\ncontent-type:application/x-www-form-urlencoded\ndate:Mon, 09 Sep 2011 23:36:00 GMT\nhost:host.foo.com\n\ncontent-type;date;host\n3ba8907e7a252327488df390ed517c45b96dead033600219bdca7107d1d3f88a",
- stringToSign: "AWS4-HMAC-SHA256\n20110909T233600Z\n20110909/us-east-1/host/aws4_request\n4c5c6e4b52fb5fb947a8733982a8a5a61b14f04345cbfe6e739236c76dd48f74",
- signature: "5a15b22cf462f047318703b92e6f4f38884e4a7ab7b1d6426ca46a8bd1c26cbc",
- authorization: "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=content-type;date;host, Signature=5a15b22cf462f047318703b92e6f4f38884e4a7ab7b1d6426ca46a8bd1c26cbc",
- },
- )
-}
-
-func (s *V4SignerSuite) TestCases(c *C) {
- signer := aws.NewV4Signer(s.auth, "host", s.region)
-
- for _, testCase := range s.cases {
-
- req, err := http.NewRequest(testCase.request.method, "http://"+testCase.request.host+testCase.request.url, strings.NewReader(testCase.request.body))
- c.Assert(err, IsNil, Commentf("Testcase: %s", testCase.label))
- for _, v := range testCase.request.headers {
- h := strings.SplitN(v, ":", 2)
- req.Header.Add(h[0], h[1])
- }
- req.Header.Set("host", req.Host)
-
- t := signer.RequestTime(req)
-
- canonicalRequest := signer.CanonicalRequest(req)
- c.Check(canonicalRequest, Equals, testCase.canonicalRequest, Commentf("Testcase: %s", testCase.label))
-
- stringToSign := signer.StringToSign(t, canonicalRequest)
- c.Check(stringToSign, Equals, testCase.stringToSign, Commentf("Testcase: %s", testCase.label))
-
- signature := signer.Signature(t, stringToSign)
- c.Check(signature, Equals, testCase.signature, Commentf("Testcase: %s", testCase.label))
-
- authorization := signer.Authorization(req.Header, t, signature)
- c.Check(authorization, Equals, testCase.authorization, Commentf("Testcase: %s", testCase.label))
-
- signer.Sign(req)
- c.Check(req.Header.Get("Authorization"), Equals, testCase.authorization, Commentf("Testcase: %s", testCase.label))
- }
-}
-
-func ExampleV4Signer() {
- // Get auth from env vars
- auth, err := aws.EnvAuth()
- if err != nil {
- fmt.Println(err)
- }
-
- // Create a signer with the auth, name of the service, and aws region
- signer := aws.NewV4Signer(auth, "dynamodb", aws.USEast)
-
- // Create a request
- req, err := http.NewRequest("POST", aws.USEast.DynamoDBEndpoint, strings.NewReader("sample_request"))
- if err != nil {
- fmt.Println(err)
- }
-
- // Date or x-amz-date header is required to sign a request
- req.Header.Add("Date", time.Now().UTC().Format(http.TimeFormat))
-
- // Sign the request
- signer.Sign(req)
-
- // Issue signed request
- http.DefaultClient.Do(req)
-}
diff --git a/vendor/github.com/goamz/goamz/cloudformation/cloudformation.go b/vendor/github.com/goamz/goamz/cloudformation/cloudformation.go
deleted file mode 100644
index 00081d0c2..000000000
--- a/vendor/github.com/goamz/goamz/cloudformation/cloudformation.go
+++ /dev/null
@@ -1,837 +0,0 @@
-//
-// cloudformation: This package provides types and functions to interact with the AWS CloudFormation API
-//
-// Depends on https://github.com/goamz/goamz
-//
-
-package cloudformation
-
-import (
- "encoding/xml"
- "fmt"
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-// The CloudFormation type encapsulates operations within a specific EC2 region.
-type CloudFormation struct {
- aws.Auth
- aws.Region
-}
-
-// New creates a new CloudFormation Client.
-func New(auth aws.Auth, region aws.Region) *CloudFormation {
-
- return &CloudFormation{auth, region}
-
-}
-
-const debug = false
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-// Error encapsulates an error returned by the AWS CloudFormation API.
-//
-// See http://goo.gl/zDZbuQ for more details.
-type Error struct {
- // HTTP status code (200, 403, ...)
- StatusCode int
- // Error type
- Type string `xml:"Type"`
- // CloudFormation error code
- Code string `xml:"Code"`
- // The human-oriented error message
- Message string `xml:"Message"`
- RequestId string `xml:"RequestID"`
-}
-
-func (err *Error) Error() string {
- if err.Code == "" {
- return err.Message
- }
-
- return fmt.Sprintf("%s (%s)", err.Message, err.Code)
-}
-
-type xmlErrors struct {
- RequestId string `xml:"RequestId"`
- Errors []Error `xml:"Error"`
-}
-
-func (c *CloudFormation) query(params map[string]string, resp interface{}) error {
- params["Version"] = "2010-05-15"
-
- data := strings.NewReader(multimap(params).Encode())
-
- hreq, err := http.NewRequest("POST", c.Region.CloudFormationEndpoint+"/", data)
- if err != nil {
- return err
- }
-
- hreq.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
-
- token := c.Auth.Token()
- if token != "" {
- hreq.Header.Set("X-Amz-Security-Token", token)
- }
-
- signer := aws.NewV4Signer(c.Auth, "cloudformation", c.Region)
- signer.Sign(hreq)
-
- if debug {
- log.Printf("%v -> {\n", hreq)
- }
- r, err := http.DefaultClient.Do(hreq)
-
- if err != nil {
- log.Printf("Error calling Amazon")
- return err
- }
-
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("response:\n")
- log.Printf("%v\n}\n", string(dump))
- }
- if r.StatusCode != 200 {
- return buildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-func buildError(r *http.Response) error {
- var (
- err Error
- errors xmlErrors
- )
- xml.NewDecoder(r.Body).Decode(&errors)
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
-
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func makeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-// addParamsList adds params in the form of param.member.N to the params map
-func addParamsList(params map[string]string, label string, ids []string) {
- for i, id := range ids {
- params[label+"."+strconv.Itoa(i+1)] = id
- }
-}
-
-// -----------------------------------------------------------------------
-// API Supported Types and Methods
-
-// SimpleResp is the basic response from most actions.
-type SimpleResp struct {
- XMLName xml.Name
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// CancelUpdateStack cancels an update on the specified stack.
-// If the call completes successfully, the stack will roll back the update and revert
-// to the previous stack configuration.
-//
-// See http://goo.gl/ZE6fOa for more details
-func (c *CloudFormation) CancelUpdateStack(stackName string) (resp *SimpleResp, err error) {
- params := makeParams("CancelUpdateStack")
-
- params["StackName"] = stackName
-
- resp = new(SimpleResp)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Parameter encapsulates the cloudstack paramter data type
-//
-// See http://goo.gl/2rg9eG for more details
-type Parameter struct {
- ParameterKey string `xml:"ParameterKey"`
- ParameterValue string `xml:"ParameterValue"`
- UsePreviousValue bool `xml:"UsePreviousValue"`
-}
-
-type Tag struct {
- Key string `xml:"Key"`
- Value string `xml:"Value"`
-}
-
-// CreateStackParams wraps CreateStack request options
-//
-// See http://goo.gl/yDZYuV for more information
-type CreateStackParams struct {
- Capabilities []string
- DisableRollback bool
- NotificationARNs []string
- OnFailure string
- Parameters []Parameter
- StackName string
- StackPolicyBody string
- StackPolicyURL string
- Tags []Tag
- TemplateBody string
- TemplateURL string
- TimeoutInMinutes int
-}
-
-// CreateStackResponse wraps a CreateStack call response
-//
-// See http://goo.gl/yDZYuV for more details
-type CreateStackResponse struct {
- StackId string `xml:"CreateStackResult>StackId"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// CreateStack creates a stack as specified in the template. After the call completes successfully,
-// the stack creation starts.
-//
-// Required params: StackName
-//
-// See http://goo.gl/yDZYuV for more details
-func (c *CloudFormation) CreateStack(options *CreateStackParams) (
- resp *CreateStackResponse, err error) {
- params := makeParams("CreateStack")
-
- params["StackName"] = options.StackName
-
- if options.DisableRollback {
- params["DisableRollback"] = strconv.FormatBool(options.DisableRollback)
- }
- if options.OnFailure != "" {
- params["OnFailure"] = options.OnFailure
- }
- if options.StackPolicyBody != "" {
- params["StackPolicyBody"] = options.StackPolicyBody
- }
- if options.StackPolicyURL != "" {
- params["StackPolicyURL"] = options.StackPolicyURL
- }
- if options.TemplateBody != "" {
- params["TemplateBody"] = options.TemplateBody
- }
- if options.TemplateURL != "" {
- params["TemplateURL"] = options.TemplateURL
- }
- if options.TimeoutInMinutes != 0 {
- params["TimeoutInMinutes"] = strconv.Itoa(options.TimeoutInMinutes)
- }
- if len(options.Capabilities) > 0 {
- addParamsList(params, "Capabilities.member", options.Capabilities)
- }
- if len(options.NotificationARNs) > 0 {
- addParamsList(params, "NotificationARNs.member", options.NotificationARNs)
- }
- // Add any parameters
- for i, t := range options.Parameters {
- key := "Parameters.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "ParameterKey")] = t.ParameterKey
- params[fmt.Sprintf(key, index, "ParameterValue")] = t.ParameterValue
- params[fmt.Sprintf(key, index, "UsePreviousValue")] = strconv.FormatBool(t.UsePreviousValue)
- }
- // Add any tags
- for i, t := range options.Tags {
- key := "Tags.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "Key")] = t.Key
- params[fmt.Sprintf(key, index, "Value")] = t.Value
- }
-
- resp = new(CreateStackResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteStack deletes a specified stack.
-// Once the call completes successfully, stack deletion starts.
-//
-// See http://goo.gl/CVMpxC for more details
-func (c *CloudFormation) DeleteStack(stackName string) (resp *SimpleResp, err error) {
- params := makeParams("DeleteStack")
-
- params["StackName"] = stackName
-
- resp = new(SimpleResp)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StackEvent encapsulates the StackEvent data type
-//
-// See http://goo.gl/EHwiMf for more details
-type StackEvent struct {
- EventId string `xml:"EventId"`
- LogicalResourceId string `xml:"LogicalResourceId"`
- PhysicalResourceId string `xml:"PhysicalResourceId"`
- ResourceProperties string `xml:"ResourceProperties"`
- ResourceStatus string `xml:"ResourceStatus"`
- ResourceStatusReason string `xml:"ResourceStatusReason"`
- ResourceType string `xml:"ResourceType"`
- StackId string `xml:"StackId"`
- StackName string `xml:"StackName"`
- Timestamp time.Time `xml:"Timestamp"`
-}
-
-// DescribeStackEventsResponse wraps a response returned by DescribeStackEvents request
-//
-// See http://goo.gl/zqj4Bz for more details
-type DescribeStackEventsResponse struct {
- NextToken string `xml:"DescribeStackEventsResult>NextToken"`
- StackEvents []StackEvent `xml:"DescribeStackEventsResult>StackEvents>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeStackEvents returns all stack related events for a specified stack.
-//
-// See http://goo.gl/zqj4Bz for more details
-func (c *CloudFormation) DescribeStackEvents(stackName string, nextToken string) (
- resp *DescribeStackEventsResponse, err error) {
- params := makeParams("DescribeStackEvents")
-
- if stackName != "" {
- params["StackName"] = stackName
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- resp = new(DescribeStackEventsResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StackResourceDetail encapsulates the StackResourceDetail data type
-//
-// See http://goo.gl/flce6I for more details
-type StackResourceDetail struct {
- Description string `xml:"Description"`
- LastUpdatedTimestamp time.Time `xml:"LastUpdatedTimestamp"`
- LogicalResourceId string `xml:"LogicalResourceId"`
- Metadata string `xml:"Metadata"`
- PhysicalResourceId string `xml:"PhysicalResourceId"`
- ResourceStatus string `xml:"ResourceStatus"`
- ResourceStatusReason string `xml:"ResourceStatusReason"`
- ResourceType string `xml:"ResourceType"`
- StackId string `xml:"StackId"`
- StackName string `xml:"StackName"`
-}
-
-// DescribeStackResourceResponse wraps a response returned by DescribeStackResource request
-//
-// See http://goo.gl/6pfPFs for more details
-type DescribeStackResourceResponse struct {
- StackResourceDetail StackResourceDetail `xml:"DescribeStackResourceResult>StackResourceDetail"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeStackResource returns a description of the specified resource in the specified stack.
-// For deleted stacks, DescribeStackResource returns resource information
-// for up to 90 days after the stack has been deleted.
-//
-// Required params: stackName, logicalResourceId
-//
-// See http://goo.gl/6pfPFs for more details
-func (c *CloudFormation) DescribeStackResource(stackName string, logicalResourceId string) (
- resp *DescribeStackResourceResponse, err error) {
- params := makeParams("DescribeStackResource")
-
- params["StackName"] = stackName
- params["LogicalResourceId"] = logicalResourceId
-
- resp = new(DescribeStackResourceResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StackResource encapsulates the StackResource data type
-//
-// See http://goo.gl/j4eli5 for more details
-type StackResource struct {
- Description string `xml:"Description"`
- LogicalResourceId string `xml:"LogicalResourceId"`
- PhysicalResourceId string `xml:"PhysicalResourceId"`
- ResourceStatus string `xml:"ResourceStatus"`
- ResourceStatusReason string `xml:"ResourceStatusReason"`
- ResourceType string `xml:"ResourceType"`
- StackId string `xml:"StackId"`
- StackName string `xml:"StackName"`
- Timestamp time.Time `xml:"Timestamp"`
-}
-
-// DescribeStackResourcesResponse wraps a response returned by DescribeStackResources request
-//
-// See http://goo.gl/YnY5rs for more details
-type DescribeStackResourcesResponse struct {
- StackResources []StackResource `xml:"DescribeStackResourcesResult>StackResources>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeStackResources returns AWS resource descriptions for running and deleted stacks.
-// If stackName is specified, all the associated resources that are part of the stack are returned.
-// If physicalResourceId is specified, the associated resources of the stack that the resource
-// belongs to are returned.
-//
-// Only the first 100 resources will be returned. If your stack has more resources than this,
-// you should use ListStackResources instead.
-//
-// See http://goo.gl/YnY5rs for more details
-func (c *CloudFormation) DescribeStackResources(stackName, physicalResourceId, logicalResourceId string) (
- resp *DescribeStackResourcesResponse, err error) {
- params := makeParams("DescribeStackResources")
-
- if stackName != "" {
- params["StackName"] = stackName
- }
- if physicalResourceId != "" {
- params["PhysicalResourceId"] = physicalResourceId
- }
- if logicalResourceId != "" {
- params["LogicalResourceId"] = logicalResourceId
- }
-
- resp = new(DescribeStackResourcesResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Output encapsulates the Output AWS data type
-//
-// See http://goo.gl/UOn7q6 for more information
-type Output struct {
- Description string `xml:"Description"`
- OutputKey string `xml:"OutputKey"`
- OutputValue string `xml:"OutputValue"`
-}
-
-// Stack encapsulates the Stack AWS data type
-//
-// See http://goo.gl/yDZYuV for more information
-type Stack struct {
- Capabilities []string `xml:"Capabilities>member"`
- CreationTime time.Time `xml:"CreationTime"`
- Description string `xml:"Description"`
- DisableRollback bool `xml:"DisableRollback"`
- LastUpdatedTime time.Time `xml:"LastUpdatedTime"`
- NotificationARNs []string `xml:"NotificationARNs>member"`
- Outputs []Output `xml:"Outputs>member"`
- Parameters []Parameter `xml:"Parameters>member"`
- StackId string `xml:"StackId"`
- StackName string `xml:"StackName"`
- StackStatus string `xml:"StackStatus"`
- StackStatusReason string `xml:"StackStatusReason"`
- Tags []Tag `xml:"Tags>member"`
- TimeoutInMinutes int `xml:"TimeoutInMinutes"`
-}
-
-// DescribeStacksResponse wraps a response returned by DescribeStacks request
-//
-// See http://goo.gl/UOLsXD for more information
-type DescribeStacksResponse struct {
- NextToken string `xml:"DescribeStacksResult>NextToken"`
- Stacks []Stack `xml:"DescribeStacksResult>Stacks>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeStacks returns the description for the specified stack;
-// If no stack name was specified, then it returns the description for all the stacks created.
-//
-// See http://goo.gl/UOLsXD for more information
-func (c *CloudFormation) DescribeStacks(stackName string, nextToken string) (
- resp *DescribeStacksResponse, err error) {
- params := makeParams("DescribeStacks")
-
- if stackName != "" {
- params["StackName"] = stackName
- }
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- resp = new(DescribeStacksResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// EstimateTemplateCostResponse wraps a response returned by EstimateTemplateCost request
-//
-// See http://goo.gl/PD9hle for more information
-type EstimateTemplateCostResponse struct {
- Url string `xml:"EstimateTemplateCostResult>Url"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// EstimateTemplateCost returns the estimated monthly cost of a template.
-// The return value is an AWS Simple Monthly Calculator URL with a query string that describes
-// the resources required to run the template.
-//
-// See http://goo.gl/PD9hle for more information
-func (c *CloudFormation) EstimateTemplateCost(parameters []Parameter, templateBody, templateUrl string) (
- resp *EstimateTemplateCostResponse, err error) {
- params := makeParams("EstimateTemplateCost")
-
- if templateBody != "" {
- params["TemplateBody"] = templateBody
- }
- if templateUrl != "" {
- params["TemplateURL"] = templateUrl
- }
- // Add any parameters
- for i, t := range parameters {
- key := "Parameters.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "ParameterKey")] = t.ParameterKey
- params[fmt.Sprintf(key, index, "ParameterValue")] = t.ParameterValue
- params[fmt.Sprintf(key, index, "UsePreviousValue")] = strconv.FormatBool(t.UsePreviousValue)
- }
-
- resp = new(EstimateTemplateCostResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// GetStackPolicyResponse wraps a response returned by GetStackPolicy request
-//
-// See http://goo.gl/iZFSgy for more information
-type GetStackPolicyResponse struct {
- StackPolicyBody string `xml:"GetStackPolicyResult>StackPolicyBody"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// GetStackPolicy returns the stack policy for a specified stack. If a stack doesn't have a policy,
-// a null value is returned.
-//
-// See http://goo.gl/iZFSgy for more information
-func (c *CloudFormation) GetStackPolicy(stackName string) (
- resp *GetStackPolicyResponse, err error) {
- params := makeParams("GetStackPolicy")
-
- params["StackName"] = stackName
-
- resp = new(GetStackPolicyResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// GetTemplateResponse wraps a response returned by GetTemplate request
-//
-// See http://goo.gl/GU59CB for more information
-type GetTemplateResponse struct {
- TemplateBody string `xml:"GetTemplateResult>TemplateBody"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// GetTemplate returns the template body for a specified stack.
-// You can get the template for running or deleted stacks
-//
-// Required Params: StackName - The name or the unique identifier associated with the stack,
-// which are not always interchangeable:
-// Running stacks: You can specify either the stack's name or its unique stack ID.
-// Deleted stacks: You must specify the unique stack ID.
-//
-// See http://goo.gl/GU59CB for more information
-func (c *CloudFormation) GetTemplate(stackName string) (
- resp *GetTemplateResponse, err error) {
- params := makeParams("GetTemplate")
-
- params["StackName"] = stackName
-
- resp = new(GetTemplateResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StackResourceSummary encapsulates the StackResourceSummary data type
-//
-// See http://goo.gl/Af0vcm for more details
-type StackResourceSummary struct {
- LastUpdatedTimestamp time.Time `xml:"LastUpdatedTimestamp"`
- LogicalResourceId string `xml:"LogicalResourceId"`
- PhysicalResourceId string `xml:"PhysicalResourceId"`
- ResourceStatus string `xml:"ResourceStatus"`
- ResourceStatusReason string `xml:"ResourceStatusReason"`
- ResourceType string `xml:"ResourceType"`
-}
-
-// ListStackResourcesResponse wraps a response returned by ListStackResources request
-//
-// See http://goo.gl/JUCgLf for more details
-type ListStackResourcesResponse struct {
- NextToken string `xml:"ListStackResourcesResult>NextToken"`
- StackResourceSummaries []StackResourceSummary `xml:"ListStackResourcesResult>StackResourceSummaries>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ListStackResources returns descriptions of all resources of the specified stack.
-// For deleted stacks, ListStackResources returns resource information for up to 90 days
-// after the stack has been deleted.
-//
-// Required Params: stackName - the name or the unique identifier associated with the stack,
-// which are not always interchangeable:
-// Running stacks: You can specify either the stack's name or its unique stack ID.
-// Deleted stacks: You must specify the unique stack ID.
-//
-// See http://goo.gl/JUCgLf for more details
-func (c *CloudFormation) ListStackResources(stackName, nextToken string) (
- resp *ListStackResourcesResponse, err error) {
- params := makeParams("ListStackResources")
-
- params["StackName"] = stackName
-
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- resp = new(ListStackResourcesResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StackSummary encapsulates the StackSummary data type
-//
-// See http://goo.gl/35j3wf for more details
-type StackSummary struct {
- CreationTime time.Time `xml:"CreationTime"`
- DeletionTime time.Time `xml:"DeletionTime"`
- LastUpdatedTime time.Time `xml:"LastUpdatedTime"`
- StackId string `xml:"StackId"`
- StackName string `xml:"StackName"`
- StackStatus string `xml:"StackStatus"`
- StackStatusReason string `xml:"StackStatusReason"`
- TemplateDescription string `xml:"TemplateDescription"`
-}
-
-// ListStacksResponse wraps a response returned by ListStacks request
-//
-// See http://goo.gl/UWi6nm for more details
-type ListStacksResponse struct {
- NextToken string `xml:"ListStacksResult>NextToken"`
- StackSummaries []StackSummary `xml:"ListStacksResult>StackSummaries>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ListStacks Returns the summary information for stacks whose status matches the specified StackStatusFilter.
-// Summary information for stacks that have been deleted is kept for 90 days after the stack is deleted.
-// If no StackStatusFilter is specified, summary information for all stacks is returned
-// (including existing stacks and stacks that have been deleted).
-//
-// See http://goo.gl/UWi6nm for more details
-func (c *CloudFormation) ListStacks(stackStatusFilters []string, nextToken string) (
- resp *ListStacksResponse, err error) {
- params := makeParams("ListStacks")
-
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- if len(stackStatusFilters) > 0 {
- addParamsList(params, "StackStatusFilter.member", stackStatusFilters)
- }
-
- resp = new(ListStacksResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// SetStackPolicy sets a stack policy for a specified stack.
-//
-// Required Params: stackName
-//
-// See http://goo.gl/iY9ohu for more information
-func (c *CloudFormation) SetStackPolicy(stackName, stackPolicyBody, stackPolicyUrl string) (
- resp *SimpleResp, err error) {
- params := makeParams("SetStackPolicy")
-
- params["StackName"] = stackName
-
- if stackPolicyBody != "" {
- params["StackPolicyBody"] = stackPolicyBody
- }
- if stackPolicyUrl != "" {
- params["StackPolicyURL"] = stackPolicyUrl
- }
-
- resp = new(SimpleResp)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// UpdateStackParams wraps UpdateStack request options
-//
-// See http://goo.gl/LvkhZq for more information
-type UpdateStackParams struct {
- Capabilities []string
- NotificationARNs []string
- Parameters []Parameter
- StackName string
- StackPolicyBody string
- StackPolicyDuringUpdateBody string
- StackPolicyDuringUpdateURL string
- StackPolicyURL string
- TemplateBody string
- TemplateURL string
- UsePreviousTemplate bool
-}
-
-// UpdateStackResponse wraps the UpdateStack call response
-//
-// See http://goo.gl/LvkhZq for more information
-type UpdateStackResponse struct {
- StackId string `xml:"UpdateStackResult>StackId"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// UpdateStack updates a stack as specified in the template.
-// After the call completes successfully, the stack update starts.
-// You can check the status of the stack via the DescribeStacks action.
-//
-// Required Params: options.StackName
-//
-// See http://goo.gl/LvkhZq for more information
-func (c *CloudFormation) UpdateStack(options *UpdateStackParams) (
- resp *UpdateStackResponse, err error) {
- params := makeParams("UpdateStack")
-
- params["StackName"] = options.StackName
-
- if options.StackPolicyBody != "" {
- params["StackPolicyBody"] = options.StackPolicyBody
- }
- if options.StackPolicyDuringUpdateBody != "" {
- params["StackPolicyDuringUpdateBody"] = options.StackPolicyDuringUpdateBody
- }
- if options.StackPolicyDuringUpdateURL != "" {
- params["StackPolicyDuringUpdateURL"] = options.StackPolicyDuringUpdateURL
- }
- if options.StackPolicyURL != "" {
- params["StackPolicyURL"] = options.StackPolicyURL
- }
- if options.TemplateBody != "" {
- params["TemplateBody"] = options.TemplateBody
- }
- if options.TemplateURL != "" {
- params["TemplateURL"] = options.TemplateURL
- }
- if options.UsePreviousTemplate {
- params["UsePreviousTemplate"] = strconv.FormatBool(options.UsePreviousTemplate)
- }
-
- if len(options.Capabilities) > 0 {
- addParamsList(params, "Capabilities.member", options.Capabilities)
- }
- if len(options.NotificationARNs) > 0 {
- addParamsList(params, "NotificationARNs.member", options.NotificationARNs)
- }
- // Add any parameters
- for i, t := range options.Parameters {
- key := "Parameters.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "ParameterKey")] = t.ParameterKey
- params[fmt.Sprintf(key, index, "ParameterValue")] = t.ParameterValue
- params[fmt.Sprintf(key, index, "UsePreviousValue")] = strconv.FormatBool(t.UsePreviousValue)
- }
-
- resp = new(UpdateStackResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// TemplateParameter encapsulates the AWS TemplateParameter data type
-//
-// See http://goo.gl/OBhNzk for more information
-type TemplateParameter struct {
- DefaultValue string `xml:"DefaultValue"`
- Description string `xml:Description"`
- NoEcho bool `xml:NoEcho"`
- ParameterKey string `xml:ParameterKey"`
-}
-
-// ValidateTemplateResponse wraps the ValidateTemplate call response
-//
-// See http://goo.gl/OBhNzk for more information
-type ValidateTemplateResponse struct {
- Capabilities []string `xml:"ValidateTemplateResult>Capabilities>member"`
- CapabilitiesReason string `xml:"ValidateTemplateResult>CapabilitiesReason"`
- Description string `xml:"ValidateTemplateResult>Description"`
- Parameters []TemplateParameter `xml:"ValidateTemplateResult>Parameters>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ValidateTemplate validates a specified template.
-//
-// See http://goo.gl/OBhNzk for more information
-func (c *CloudFormation) ValidateTemplate(templateBody, templateUrl string) (
- resp *ValidateTemplateResponse, err error) {
- params := makeParams("ValidateTemplate")
-
- if templateBody != "" {
- params["TemplateBody"] = templateBody
- }
- if templateUrl != "" {
- params["TemplateURL"] = templateUrl
- }
-
- resp = new(ValidateTemplateResponse)
- if err := c.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
diff --git a/vendor/github.com/goamz/goamz/cloudformation/cloudformation_test.go b/vendor/github.com/goamz/goamz/cloudformation/cloudformation_test.go
deleted file mode 100644
index 1937e8042..000000000
--- a/vendor/github.com/goamz/goamz/cloudformation/cloudformation_test.go
+++ /dev/null
@@ -1,653 +0,0 @@
-package cloudformation_test
-
-import (
- "testing"
- "time"
-
- . "gopkg.in/check.v1"
-
- "github.com/goamz/goamz/aws"
- cf "github.com/goamz/goamz/cloudformation"
- "github.com/goamz/goamz/testutil"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- cf *cf.CloudFormation
-}
-
-var testServer = testutil.NewHTTPServer()
-
-var mockTest bool
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.cf = cf.New(auth, aws.Region{CloudFormationEndpoint: testServer.URL})
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestCancelUpdateStack(c *C) {
- testServer.Response(200, nil, CancelUpdateStackResponse)
-
- resp, err := s.cf.CancelUpdateStack("foo")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "CancelUpdateStack")
- c.Assert(values.Get("StackName"), Equals, "foo")
- // Response test
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
-}
-
-func (s *S) TestCreateStack(c *C) {
- testServer.Response(200, nil, CreateStackResponse)
-
- stackParams := &cf.CreateStackParams{
- NotificationARNs: []string{"arn:aws:sns:us-east-1:1234567890:my-topic"},
- Parameters: []cf.Parameter{
- {
- ParameterKey: "AvailabilityZone",
- ParameterValue: "us-east-1a",
- },
- },
- StackName: "MyStack",
- TemplateBody: "[Template Document]",
- }
- resp, err := s.cf.CreateStack(stackParams)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "CreateStack")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("NotificationARNs.member.1"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic")
- c.Assert(values.Get("TemplateBody"), Equals, "[Template Document]")
- c.Assert(values.Get("Parameters.member.1.ParameterKey"), Equals, "AvailabilityZone")
- c.Assert(values.Get("Parameters.member.1.ParameterValue"), Equals, "us-east-1a")
- // Response test
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
- c.Assert(resp.StackId, Equals, "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83")
-}
-
-func (s *S) TestCreateStackWithInvalidParams(c *C) {
- testServer.Response(400, nil, CreateStackWithInvalidParamsResponse)
- //testServer.Response(200, nil, DeleteAutoScalingGroupResponse)
-
- cfTemplate := `
-{
- "AWSTemplateFormatVersion" : "2010-09-09",
- "Description" : "Sample template",
- "Parameters" : {
- "KeyName" : {
- "Description" : "key pair",
- "Type" : "String"
- }
- },
- "Resources" : {
- "Ec2Instance" : {
- "Type" : "AWS::EC2::Instance",
- "Properties" : {
- "KeyName" : { "Ref" : "KeyName" },
- "ImageId" : "ami-7f418316",
- "UserData" : { "Fn::Base64" : "80" }
- }
- }
- },
- "Outputs" : {
- "InstanceId" : {
- "Description" : "InstanceId of the newly created EC2 instance",
- "Value" : { "Ref" : "Ec2Instance" }
- }
-}`
-
- stackParams := &cf.CreateStackParams{
- Capabilities: []string{"CAPABILITY_IAM"},
- DisableRollback: true,
- NotificationARNs: []string{
- "arn:aws:sns:us-east-1:1234567890:my-topic",
- "arn:aws:sns:us-east-1:1234567890:my-topic2",
- },
- OnFailure: "ROLLBACK",
- Parameters: []cf.Parameter{
- {
- ParameterKey: "AvailabilityZone",
- ParameterValue: "us-east-1a",
- },
- },
- StackName: "MyStack",
- StackPolicyBody: "{PolicyBody}",
- StackPolicyURL: "http://stack-policy-url",
- Tags: []cf.Tag{
- {
- Key: "TagKey",
- Value: "TagValue",
- },
- },
- TemplateBody: cfTemplate,
- TemplateURL: "http://url",
- TimeoutInMinutes: 20,
- }
- resp, err := s.cf.CreateStack(stackParams)
- c.Assert(err, NotNil)
- c.Assert(resp, IsNil)
- values := testServer.WaitRequest().PostForm
-
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "CreateStack")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("NotificationARNs.member.1"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic")
- c.Assert(values.Get("NotificationARNs.member.2"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic2")
- c.Assert(values.Get("Capabilities.member.1"), Equals, "CAPABILITY_IAM")
- c.Assert(values.Get("TemplateBody"), Equals, cfTemplate)
- c.Assert(values.Get("TemplateURL"), Equals, "http://url")
- c.Assert(values.Get("StackPolicyBody"), Equals, "{PolicyBody}")
- c.Assert(values.Get("StackPolicyURL"), Equals, "http://stack-policy-url")
- c.Assert(values.Get("OnFailure"), Equals, "ROLLBACK")
- c.Assert(values.Get("DisableRollback"), Equals, "true")
- c.Assert(values.Get("Tags.member.1.Key"), Equals, "TagKey")
- c.Assert(values.Get("Tags.member.1.Value"), Equals, "TagValue")
- c.Assert(values.Get("Parameters.member.1.ParameterKey"), Equals, "AvailabilityZone")
- c.Assert(values.Get("Parameters.member.1.ParameterValue"), Equals, "us-east-1a")
- c.Assert(values.Get("TimeoutInMinutes"), Equals, "20")
-
- // Response test
- c.Assert(err.(*cf.Error).RequestId, Equals, "70a76d42-9665-11e2-9fdf-211deEXAMPLE")
- c.Assert(err.(*cf.Error).Message, Equals, "Either Template URL or Template Body must be specified.")
- c.Assert(err.(*cf.Error).Type, Equals, "Sender")
- c.Assert(err.(*cf.Error).Code, Equals, "ValidationError")
- c.Assert(err.(*cf.Error).StatusCode, Equals, 400)
-
-}
-
-func (s *S) TestDeleteStack(c *C) {
- testServer.Response(200, nil, DeleteStackResponse)
-
- resp, err := s.cf.DeleteStack("foo")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "DeleteStack")
- c.Assert(values.Get("StackName"), Equals, "foo")
- // Response test
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
-}
-
-func (s *S) TestDescribeStackEvents(c *C) {
- testServer.Response(200, nil, DescribeStackEventsResponse)
-
- resp, err := s.cf.DescribeStackEvents("MyStack", "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
-
- // Post request test
- t1, _ := time.Parse(time.RFC3339, "2010-07-27T22:26:28Z")
- t2, _ := time.Parse(time.RFC3339, "2010-07-27T22:27:28Z")
- t3, _ := time.Parse(time.RFC3339, "2010-07-27T22:28:28Z")
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "DescribeStackEvents")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("NextToken"), Equals, "")
-
- // Response test
- expected := &cf.DescribeStackEventsResponse{
- StackEvents: []cf.StackEvent{
- {
- EventId: "Event-1-Id",
- StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83",
- StackName: "MyStack",
- LogicalResourceId: "MyStack",
- PhysicalResourceId: "MyStack_One",
- ResourceType: "AWS::CloudFormation::Stack",
- Timestamp: t1,
- ResourceStatus: "CREATE_IN_PROGRESS",
- ResourceStatusReason: "User initiated",
- },
- {
- EventId: "Event-2-Id",
- StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83",
- StackName: "MyStack",
- LogicalResourceId: "MyDBInstance",
- PhysicalResourceId: "MyStack_DB1",
- ResourceType: "AWS::SecurityGroup",
- Timestamp: t2,
- ResourceStatus: "CREATE_IN_PROGRESS",
- ResourceProperties: "{\"GroupDescription\":...}",
- },
- {
- EventId: "Event-3-Id",
- StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83",
- StackName: "MyStack",
- LogicalResourceId: "MySG1",
- PhysicalResourceId: "MyStack_SG1",
- ResourceType: "AWS::SecurityGroup",
- Timestamp: t3,
- ResourceStatus: "CREATE_COMPLETE",
- },
- },
- NextToken: "",
- RequestId: "4af14eec-350e-11e4-b260-EXAMPLE",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeStackResource(c *C) {
- testServer.Response(200, nil, DescribeStackResourceResponse)
-
- resp, err := s.cf.DescribeStackResource("MyStack", "MyDBInstance")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "DescribeStackResource")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("LogicalResourceId"), Equals, "MyDBInstance")
- t, _ := time.Parse(time.RFC3339, "2011-07-07T22:27:28Z")
- // Response test
- expected := &cf.DescribeStackResourceResponse{
- StackResourceDetail: cf.StackResourceDetail{
- StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83",
- StackName: "MyStack",
- LogicalResourceId: "MyDBInstance",
- PhysicalResourceId: "MyStack_DB1",
- ResourceType: "AWS::RDS::DBInstance",
- LastUpdatedTimestamp: t,
- ResourceStatus: "CREATE_COMPLETE",
- },
- RequestId: "4af14eec-350e-11e4-b260-EXAMPLE",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeStackResources(c *C) {
- testServer.Response(200, nil, DescribeStackResourcesResponse)
-
- resp, err := s.cf.DescribeStackResources("MyStack", "", "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
-
- // Post request test
- t1, _ := time.Parse(time.RFC3339, "2010-07-27T22:27:28Z")
- t2, _ := time.Parse(time.RFC3339, "2010-07-27T22:28:28Z")
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "DescribeStackResources")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("PhysicalResourceId"), Equals, "")
- c.Assert(values.Get("LogicalResourceId"), Equals, "")
-
- // Response test
- expected := &cf.DescribeStackResourcesResponse{
- StackResources: []cf.StackResource{
- {
- StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83",
- StackName: "MyStack",
- LogicalResourceId: "MyDBInstance",
- PhysicalResourceId: "MyStack_DB1",
- ResourceType: "AWS::DBInstance",
- Timestamp: t1,
- ResourceStatus: "CREATE_COMPLETE",
- },
- {
- StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83",
- StackName: "MyStack",
- LogicalResourceId: "MyAutoScalingGroup",
- PhysicalResourceId: "MyStack_ASG1",
- ResourceType: "AWS::AutoScalingGroup",
- Timestamp: t2,
- ResourceStatus: "CREATE_IN_PROGRESS",
- },
- },
- RequestId: "4af14eec-350e-11e4-b260-EXAMPLE",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeStacks(c *C) {
- testServer.Response(200, nil, DescribeStacksResponse)
-
- resp, err := s.cf.DescribeStacks("MyStack", "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
-
- // Post request test
- t, _ := time.Parse(time.RFC3339, "2010-07-27T22:28:28Z")
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "DescribeStacks")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("NextToken"), Equals, "")
-
- // Response test
- expected := &cf.DescribeStacksResponse{
- Stacks: []cf.Stack{
- {
- StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83",
- StackName: "MyStack",
- Description: "My Description",
- Capabilities: []string{"CAPABILITY_IAM"},
- NotificationARNs: []string{"arn:aws:sns:region-name:account-name:topic-name"},
- Parameters: []cf.Parameter{
- {
- ParameterKey: "MyKey",
- ParameterValue: "MyValue",
- },
- },
- Tags: []cf.Tag{
- {
- Key: "MyTagKey",
- Value: "MyTagValue",
- },
- },
- CreationTime: t,
- StackStatus: "CREATE_COMPLETE",
- DisableRollback: false,
- Outputs: []cf.Output{
- {
- Description: "ServerUrl",
- OutputKey: "StartPage",
- OutputValue: "http://my-load-balancer.amazonaws.com:80/index.html",
- },
- },
- },
- },
- NextToken: "",
- RequestId: "4af14eec-350e-11e4-b260-EXAMPLE",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestEstimateTemplateCost(c *C) {
- testServer.Response(200, nil, EstimateTemplateCostResponse)
-
- resp, err := s.cf.EstimateTemplateCost(nil, "", "https://s3.amazonaws.com/cloudformation-samples-us-east-1/Drupal_Simple.template")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "EstimateTemplateCost")
- c.Assert(values.Get("TemplateBody"), Equals, "")
- c.Assert(values.Get("TemplateURL"), Equals, "https://s3.amazonaws.com/cloudformation-samples-us-east-1/Drupal_Simple.template")
- // Response test
- c.Assert(resp.Url, Equals, "http://calculator.s3.amazonaws.com/calc5.html?key=cf-2e351785-e821-450c-9d58-625e1e1ebfb6")
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
-}
-
-func (s *S) TestGetStackPolicy(c *C) {
- testServer.Response(200, nil, GetStackPolicyResponse)
-
- resp, err := s.cf.GetStackPolicy("MyStack")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "GetStackPolicy")
-
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- // Response test
- policy := `{
- "Statement" : [
- {
- "Effect" : "Deny",
- "Action" : "Update:*",
- "Principal" : "*",
- "Resource" : "LogicalResourceId/ProductionDatabase"
- },
- {
- "Effect" : "Allow",
- "Action" : "Update:*",
- "Principal" : "*",
- "Resource" : "*"
- }
- ]
- }`
- c.Assert(resp.StackPolicyBody, Equals, policy)
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
-}
-
-func (s *S) TestGetTemplate(c *C) {
- testServer.Response(200, nil, GetTemplateResponse)
-
- resp, err := s.cf.GetTemplate("MyStack")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "GetTemplate")
-
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- // Response test
- templateBody := `{
- "AWSTemplateFormatVersion" : "2010-09-09",
- "Description" : "Simple example",
- "Resources" : {
- "MySQS" : {
- "Type" : "AWS::SQS::Queue",
- "Properties" : {
- }
- }
- }
- }`
- c.Assert(resp.TemplateBody, Equals, templateBody)
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
-}
-
-func (s *S) TestListStackResources(c *C) {
- testServer.Response(200, nil, ListStackResourcesResponse)
-
- resp, err := s.cf.ListStackResources("MyStack", "4dad1-32131da-d-31")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
-
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "ListStackResources")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("NextToken"), Equals, "4dad1-32131da-d-31")
-
- // Response test
- t1, _ := time.Parse(time.RFC3339, "2011-06-21T20:15:58Z")
- t2, _ := time.Parse(time.RFC3339, "2011-06-21T20:25:57Z")
- t3, _ := time.Parse(time.RFC3339, "2011-06-21T20:26:12Z")
- t4, _ := time.Parse(time.RFC3339, "2011-06-21T20:28:48Z")
- t5, _ := time.Parse(time.RFC3339, "2011-06-21T20:29:06Z")
- t6, _ := time.Parse(time.RFC3339, "2011-06-21T20:29:23Z")
-
- expected := &cf.ListStackResourcesResponse{
- StackResourceSummaries: []cf.StackResourceSummary{
- {
- LogicalResourceId: "DBSecurityGroup",
- PhysicalResourceId: "gmarcteststack-dbsecuritygroup-1s5m0ez5lkk6w",
- ResourceType: "AWS::RDS::DBSecurityGroup",
- LastUpdatedTimestamp: t1,
- ResourceStatus: "CREATE_COMPLETE",
- },
- {
- LogicalResourceId: "SampleDB",
- PhysicalResourceId: "MyStack-sampledb-ycwhk1v830lx",
- ResourceType: "AWS::RDS::DBInstance",
- LastUpdatedTimestamp: t2,
- ResourceStatus: "CREATE_COMPLETE",
- },
- {
- LogicalResourceId: "SampleApplication",
- PhysicalResourceId: "MyStack-SampleApplication-1MKNASYR3RBQL",
- ResourceType: "AWS::ElasticBeanstalk::Application",
- LastUpdatedTimestamp: t3,
- ResourceStatus: "CREATE_COMPLETE",
- },
- {
- LogicalResourceId: "SampleEnvironment",
- PhysicalResourceId: "myst-Samp-1AGU6ERZX6M3Q",
- ResourceType: "AWS::ElasticBeanstalk::Environment",
- LastUpdatedTimestamp: t4,
- ResourceStatus: "CREATE_COMPLETE",
- },
- {
- LogicalResourceId: "AlarmTopic",
- PhysicalResourceId: "arn:aws:sns:us-east-1:803981987763:MyStack-AlarmTopic-SW4IQELG7RPJ",
- ResourceType: "AWS::SNS::Topic",
- LastUpdatedTimestamp: t5,
- ResourceStatus: "CREATE_COMPLETE",
- },
- {
- LogicalResourceId: "CPUAlarmHigh",
- PhysicalResourceId: "MyStack-CPUAlarmHigh-POBWQPDJA81F",
- ResourceType: "AWS::CloudWatch::Alarm",
- LastUpdatedTimestamp: t6,
- ResourceStatus: "CREATE_COMPLETE",
- },
- },
- NextToken: "",
- RequestId: "2d06e36c-ac1d-11e0-a958-f9382b6eb86b",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestListStacks(c *C) {
- testServer.Response(200, nil, ListStacksResponse)
-
- resp, err := s.cf.ListStacks([]string{"CREATE_IN_PROGRESS", "DELETE_COMPLETE"}, "4dad1-32131da-d-31")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
-
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "ListStacks")
- c.Assert(values.Get("StackStatusFilter.member.1"), Equals, "CREATE_IN_PROGRESS")
- c.Assert(values.Get("StackStatusFilter.member.2"), Equals, "DELETE_COMPLETE")
- c.Assert(values.Get("NextToken"), Equals, "4dad1-32131da-d-31")
-
- // Response test
- c1, _ := time.Parse(time.RFC3339, "2011-05-23T15:47:44Z")
- c2, _ := time.Parse(time.RFC3339, "2011-03-05T19:57:58Z")
- d2, _ := time.Parse(time.RFC3339, "2011-03-10T16:20:51Z")
-
- expected := &cf.ListStacksResponse{
- StackSummaries: []cf.StackSummary{
- {
- StackId: "arn:aws:cloudformation:us-east-1:1234567:stack/TestCreate1/aaaaa",
- StackName: "vpc1",
- StackStatus: "CREATE_IN_PROGRESS",
- CreationTime: c1,
- TemplateDescription: "Creates one EC2 instance and a load balancer.",
- },
- {
- StackId: "arn:aws:cloudformation:us-east-1:1234567:stack/TestDelete2/bbbbb",
- StackName: "WP1",
- StackStatus: "DELETE_COMPLETE",
- CreationTime: c2,
- DeletionTime: d2,
- TemplateDescription: "A simple basic Cloudformation Template.",
- },
- },
- NextToken: "",
- RequestId: "2d06e36c-ac1d-11e0-a958-f9382b6eb86b",
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestSetStackPolicy(c *C) {
- testServer.Response(200, nil, SetStackPolicyResponse)
-
- resp, err := s.cf.SetStackPolicy("MyStack", "[Stack Policy Document]", "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "SetStackPolicy")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("StackPolicyBody"), Equals, "[Stack Policy Document]")
- c.Assert(values.Get("StackPolicyUrl"), Equals, "")
- // Response test
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
-}
-
-func (s *S) TestUpdateStack(c *C) {
- testServer.Response(200, nil, UpdateStackResponse)
-
- stackParams := &cf.UpdateStackParams{
- Capabilities: []string{"CAPABILITY_IAM"},
- NotificationARNs: []string{"arn:aws:sns:us-east-1:1234567890:my-topic"},
- StackPolicyBody: "{PolicyBody}",
- StackPolicyDuringUpdateBody: "{PolicyDuringUpdateBody}",
- Parameters: []cf.Parameter{
- {
- ParameterKey: "AvailabilityZone",
- ParameterValue: "us-east-1a",
- },
- },
- UsePreviousTemplate: true,
- StackName: "MyStack",
- TemplateBody: "[Template Document]",
- }
- resp, err := s.cf.UpdateStack(stackParams)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "UpdateStack")
- c.Assert(values.Get("StackName"), Equals, "MyStack")
- c.Assert(values.Get("NotificationARNs.member.1"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic")
- c.Assert(values.Get("TemplateBody"), Equals, "[Template Document]")
- c.Assert(values.Get("Parameters.member.1.ParameterKey"), Equals, "AvailabilityZone")
- c.Assert(values.Get("Parameters.member.1.ParameterValue"), Equals, "us-east-1a")
- c.Assert(values.Get("Capabilities.member.1"), Equals, "CAPABILITY_IAM")
- c.Assert(values.Get("StackPolicyBody"), Equals, "{PolicyBody}")
- c.Assert(values.Get("StackPolicyDuringUpdateBody"), Equals, "{PolicyDuringUpdateBody}")
- c.Assert(values.Get("UsePreviousTemplate"), Equals, "true")
-
- // Response test
- c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE")
- c.Assert(resp.StackId, Equals, "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83")
-}
-
-func (s *S) TestValidateTemplate(c *C) {
- testServer.Response(200, nil, ValidateTemplateResponse)
-
- resp, err := s.cf.ValidateTemplate("", "http://myTemplateRepository/TemplateOne.template")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
-
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2010-05-15")
- c.Assert(values.Get("Action"), Equals, "ValidateTemplate")
- c.Assert(values.Get("TemplateURL"), Equals, "http://myTemplateRepository/TemplateOne.template")
- c.Assert(values.Get("TemplateBody"), Equals, "")
-
- // Response test
- expected := &cf.ValidateTemplateResponse{
- Description: "Test",
- Capabilities: []string{"CAPABILITY_IAM"},
- Parameters: []cf.TemplateParameter{
- {
- NoEcho: false,
- ParameterKey: "InstanceType",
- Description: "Type of instance to launch",
- DefaultValue: "m1.small",
- },
- {
- NoEcho: false,
- ParameterKey: "WebServerPort",
- Description: "The TCP port for the Web Server",
- DefaultValue: "8888",
- },
- {
- NoEcho: false,
- ParameterKey: "KeyName",
- Description: "Name of an existing EC2 KeyPair to enable SSH access into the server",
- },
- },
- RequestId: "0be7b6e8-e4a0-11e0-a5bd-9f8d5a7dbc91",
- }
- c.Assert(resp, DeepEquals, expected)
-}
diff --git a/vendor/github.com/goamz/goamz/cloudformation/responses_test.go b/vendor/github.com/goamz/goamz/cloudformation/responses_test.go
deleted file mode 100644
index 705b1d976..000000000
--- a/vendor/github.com/goamz/goamz/cloudformation/responses_test.go
+++ /dev/null
@@ -1,371 +0,0 @@
-package cloudformation_test
-
-var CancelUpdateStackResponse = `
-<CancelUpdateStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <CancelUpdateStackResult/>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</CancelUpdateStackResponse>
-`
-
-var CreateStackResponse = `
-<CreateStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
-<CreateStackResult>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
-</CreateStackResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateStackResponse>
-`
-
-var CreateStackWithInvalidParamsResponse = `
-<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <Error>
- <Type>Sender</Type>
- <Code>ValidationError</Code>
- <Message>Either Template URL or Template Body must be specified.</Message>
- </Error>
- <RequestId>70a76d42-9665-11e2-9fdf-211deEXAMPLE</RequestId>
-</ErrorResponse>
-`
-
-var DeleteStackResponse = `
-<DeleteStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <DeleteStackResult/>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</DeleteStackResponse>
-`
-var DescribeStackEventsResponse = `
-<DescribeStackEventsResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <DescribeStackEventsResult>
- <StackEvents>
- <member>
- <EventId>Event-1-Id</EventId>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- <StackName>MyStack</StackName>
- <LogicalResourceId>MyStack</LogicalResourceId>
- <PhysicalResourceId>MyStack_One</PhysicalResourceId>
- <ResourceType>AWS::CloudFormation::Stack</ResourceType>
- <Timestamp>2010-07-27T22:26:28Z</Timestamp>
- <ResourceStatus>CREATE_IN_PROGRESS</ResourceStatus>
- <ResourceStatusReason>User initiated</ResourceStatusReason>
- </member>
- <member>
- <EventId>Event-2-Id</EventId>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- <StackName>MyStack</StackName>
- <LogicalResourceId>MyDBInstance</LogicalResourceId>
- <PhysicalResourceId>MyStack_DB1</PhysicalResourceId>
- <ResourceType>AWS::SecurityGroup</ResourceType>
- <Timestamp>2010-07-27T22:27:28Z</Timestamp>
- <ResourceStatus>CREATE_IN_PROGRESS</ResourceStatus>
- <ResourceProperties>{"GroupDescription":...}</ResourceProperties>
- </member>
- <member>
- <EventId>Event-3-Id</EventId>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- <StackName>MyStack</StackName>
- <LogicalResourceId>MySG1</LogicalResourceId>
- <PhysicalResourceId>MyStack_SG1</PhysicalResourceId>
- <ResourceType>AWS::SecurityGroup</ResourceType>
- <Timestamp>2010-07-27T22:28:28Z</Timestamp>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- </member>
- </StackEvents>
- <NextToken/>
- </DescribeStackEventsResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeStackEventsResponse>
-`
-
-var DescribeStackResourceResponse = `
-<DescribeStackResourceResponse>
- <DescribeStackResourceResult>
- <StackResourceDetail>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- <StackName>MyStack</StackName>
- <LogicalResourceId>MyDBInstance</LogicalResourceId>
- <PhysicalResourceId>MyStack_DB1</PhysicalResourceId>
- <ResourceType>AWS::RDS::DBInstance</ResourceType>
- <LastUpdatedTimestamp>2011-07-07T22:27:28Z</LastUpdatedTimestamp>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- </StackResourceDetail>
- </DescribeStackResourceResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeStackResourceResponse>
-`
-var DescribeStackResourcesResponse = `
-<DescribeStackResourcesResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <DescribeStackResourcesResult>
- <StackResources>
- <member>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- <StackName>MyStack</StackName>
- <LogicalResourceId>MyDBInstance</LogicalResourceId>
- <PhysicalResourceId>MyStack_DB1</PhysicalResourceId>
- <ResourceType>AWS::DBInstance</ResourceType>
- <Timestamp>2010-07-27T22:27:28Z</Timestamp>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- </member>
- <member>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- <StackName>MyStack</StackName>
- <LogicalResourceId>MyAutoScalingGroup</LogicalResourceId>
- <PhysicalResourceId>MyStack_ASG1</PhysicalResourceId>
- <ResourceType>AWS::AutoScalingGroup</ResourceType>
- <Timestamp>2010-07-27T22:28:28Z</Timestamp>
- <ResourceStatus>CREATE_IN_PROGRESS</ResourceStatus>
- </member>
- </StackResources>
- </DescribeStackResourcesResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeStackResourcesResponse>
-`
-
-var DescribeStacksResponse = `
-<DescribeStacksResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <DescribeStacksResult>
- <Stacks>
- <member>
- <StackName>MyStack</StackName>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- <StackStatusReason/>
- <Description>My Description</Description>
- <Capabilities>
- <member>CAPABILITY_IAM</member>
- </Capabilities>
- <NotificationARNs>
- <member>arn:aws:sns:region-name:account-name:topic-name</member>
- </NotificationARNs>
- <Parameters>
- <member>
- <ParameterValue>MyValue</ParameterValue>
- <ParameterKey>MyKey</ParameterKey>
- </member>
- </Parameters>
- <Tags>
- <member>
- <Key>MyTagKey</Key>
- <Value>MyTagValue</Value>
- </member>
- </Tags>
- <CreationTime>2010-07-27T22:28:28Z</CreationTime>
- <StackStatus>CREATE_COMPLETE</StackStatus>
- <DisableRollback>false</DisableRollback>
- <Outputs>
- <member>
- <Description>ServerUrl</Description>
- <OutputKey>StartPage</OutputKey>
- <OutputValue>http://my-load-balancer.amazonaws.com:80/index.html</OutputValue>
- </member>
- </Outputs>
- </member>
- </Stacks>
- <NextToken/>
- </DescribeStacksResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeStacksResponse>
-`
-
-var EstimateTemplateCostResponse = `
-<EstimateTemplateCostResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <EstimateTemplateCostResult>
- <Url>http://calculator.s3.amazonaws.com/calc5.html?key=cf-2e351785-e821-450c-9d58-625e1e1ebfb6</Url>
- </EstimateTemplateCostResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</EstimateTemplateCostResponse>
-`
-
-var GetStackPolicyResponse = `
-<GetStackPolicyResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <GetStackPolicyResult>
- <StackPolicyBody>{
- "Statement" : [
- {
- "Effect" : "Deny",
- "Action" : "Update:*",
- "Principal" : "*",
- "Resource" : "LogicalResourceId/ProductionDatabase"
- },
- {
- "Effect" : "Allow",
- "Action" : "Update:*",
- "Principal" : "*",
- "Resource" : "*"
- }
- ]
- }</StackPolicyBody>
- </GetStackPolicyResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</GetStackPolicyResponse>
-`
-
-var GetTemplateResponse = `
-<GetTemplateResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <GetTemplateResult>
- <TemplateBody>{
- "AWSTemplateFormatVersion" : "2010-09-09",
- "Description" : "Simple example",
- "Resources" : {
- "MySQS" : {
- "Type" : "AWS::SQS::Queue",
- "Properties" : {
- }
- }
- }
- }</TemplateBody>
- </GetTemplateResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</GetTemplateResponse>
-`
-
-var ListStackResourcesResponse = `
-<ListStackResourcesResponse>
- <ListStackResourcesResult>
- <StackResourceSummaries>
- <member>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- <LogicalResourceId>DBSecurityGroup</LogicalResourceId>
- <LastUpdatedTimestamp>2011-06-21T20:15:58Z</LastUpdatedTimestamp>
- <PhysicalResourceId>gmarcteststack-dbsecuritygroup-1s5m0ez5lkk6w</PhysicalResourceId>
- <ResourceType>AWS::RDS::DBSecurityGroup</ResourceType>
- </member>
- <member>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- <LogicalResourceId>SampleDB</LogicalResourceId>
- <LastUpdatedTimestamp>2011-06-21T20:25:57Z</LastUpdatedTimestamp>
- <PhysicalResourceId>MyStack-sampledb-ycwhk1v830lx</PhysicalResourceId>
- <ResourceType>AWS::RDS::DBInstance</ResourceType>
- </member>
- <member>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- <LogicalResourceId>SampleApplication</LogicalResourceId>
- <LastUpdatedTimestamp>2011-06-21T20:26:12Z</LastUpdatedTimestamp>
- <PhysicalResourceId>MyStack-SampleApplication-1MKNASYR3RBQL</PhysicalResourceId>
- <ResourceType>AWS::ElasticBeanstalk::Application</ResourceType>
- </member>
- <member>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- <LogicalResourceId>SampleEnvironment</LogicalResourceId>
- <LastUpdatedTimestamp>2011-06-21T20:28:48Z</LastUpdatedTimestamp>
- <PhysicalResourceId>myst-Samp-1AGU6ERZX6M3Q</PhysicalResourceId>
- <ResourceType>AWS::ElasticBeanstalk::Environment</ResourceType>
- </member>
- <member>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- <LogicalResourceId>AlarmTopic</LogicalResourceId>
- <LastUpdatedTimestamp>2011-06-21T20:29:06Z</LastUpdatedTimestamp>
- <PhysicalResourceId>arn:aws:sns:us-east-1:803981987763:MyStack-AlarmTopic-SW4IQELG7RPJ</PhysicalResourceId>
- <ResourceType>AWS::SNS::Topic</ResourceType>
- </member>
- <member>
- <ResourceStatus>CREATE_COMPLETE</ResourceStatus>
- <LogicalResourceId>CPUAlarmHigh</LogicalResourceId>
- <LastUpdatedTimestamp>2011-06-21T20:29:23Z</LastUpdatedTimestamp>
- <PhysicalResourceId>MyStack-CPUAlarmHigh-POBWQPDJA81F</PhysicalResourceId>
- <ResourceType>AWS::CloudWatch::Alarm</ResourceType>
- </member>
- </StackResourceSummaries>
- </ListStackResourcesResult>
- <ResponseMetadata>
- <RequestId>2d06e36c-ac1d-11e0-a958-f9382b6eb86b</RequestId>
- </ResponseMetadata>
-</ListStackResourcesResponse>
-`
-
-var ListStacksResponse = `
-<ListStacksResponse>
- <ListStacksResult>
- <StackSummaries>
- <member>
- <StackId>arn:aws:cloudformation:us-east-1:1234567:stack/TestCreate1/aaaaa</StackId>
- <StackStatus>CREATE_IN_PROGRESS</StackStatus>
- <StackName>vpc1</StackName>
- <CreationTime>2011-05-23T15:47:44Z</CreationTime>
- <TemplateDescription>Creates one EC2 instance and a load balancer.</TemplateDescription>
- </member>
- <member>
- <StackId>arn:aws:cloudformation:us-east-1:1234567:stack/TestDelete2/bbbbb</StackId>
- <StackStatus>DELETE_COMPLETE</StackStatus>
- <DeletionTime>2011-03-10T16:20:51Z</DeletionTime>
- <StackName>WP1</StackName>
- <CreationTime>2011-03-05T19:57:58Z</CreationTime>
- <TemplateDescription>A simple basic Cloudformation Template.</TemplateDescription>
- </member>
- </StackSummaries>
- </ListStacksResult>
- <ResponseMetadata>
- <RequestId>2d06e36c-ac1d-11e0-a958-f9382b6eb86b</RequestId>
- </ResponseMetadata>
-</ListStacksResponse>
-`
-
-var SetStackPolicyResponse = `
-<SetStackPolicyResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <SetStackPolicyResponse/>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</SetStackPolicyResponse>
-`
-
-var UpdateStackResponse = `
-<UpdateStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <UpdateStackResult>
- <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId>
- </UpdateStackResult>
- <ResponseMetadata>
- <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId>
- </ResponseMetadata>
-</UpdateStackResponse>
-`
-var ValidateTemplateResponse = `
-<ValidateTemplateResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
- <ValidateTemplateResult>
- <Description>Test</Description>
- <Capabilities>
- <member>CAPABILITY_IAM</member>
- </Capabilities>
- <Parameters>
- <member>
- <NoEcho>false</NoEcho>
- <ParameterKey>InstanceType</ParameterKey>
- <Description>Type of instance to launch</Description>
- <DefaultValue>m1.small</DefaultValue>
- </member>
- <member>
- <NoEcho>false</NoEcho>
- <ParameterKey>WebServerPort</ParameterKey>
- <Description>The TCP port for the Web Server</Description>
- <DefaultValue>8888</DefaultValue>
- </member>
- <member>
- <NoEcho>false</NoEcho>
- <ParameterKey>KeyName</ParameterKey>
- <Description>Name of an existing EC2 KeyPair to enable SSH access into the server</Description>
- </member>
- </Parameters>
- </ValidateTemplateResult>
- <ResponseMetadata>
- <RequestId>0be7b6e8-e4a0-11e0-a5bd-9f8d5a7dbc91</RequestId>
- </ResponseMetadata>
-</ValidateTemplateResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/cloudfront/cloudfront.go b/vendor/github.com/goamz/goamz/cloudfront/cloudfront.go
deleted file mode 100644
index 745060f1c..000000000
--- a/vendor/github.com/goamz/goamz/cloudfront/cloudfront.go
+++ /dev/null
@@ -1,135 +0,0 @@
-package cloudfront
-
-import (
- "crypto"
- "crypto/rand"
- "crypto/rsa"
- "crypto/sha1"
- "encoding/base64"
- "encoding/json"
- "fmt"
- "net/url"
- "strconv"
- "strings"
- "time"
-)
-
-type CloudFront struct {
- BaseURL string
- keyPairId string
- key *rsa.PrivateKey
-}
-
-var base64Replacer = strings.NewReplacer("=", "_", "+", "-", "/", "~")
-
-func New(baseurl string, key *rsa.PrivateKey, keyPairId string) *CloudFront {
- return &CloudFront{
- BaseURL: baseurl,
- keyPairId: keyPairId,
- key: key,
- }
-}
-
-type epochTime struct {
- EpochTime int64 `json:"AWS:EpochTime"`
-}
-
-type condition struct {
- DateLessThan epochTime
-}
-
-type statement struct {
- Resource string
- Condition condition
-}
-
-type policy struct {
- Statement []statement
-}
-
-func buildPolicy(resource string, expireTime time.Time) ([]byte, error) {
- p := &policy{
- Statement: []statement{
- statement{
- Resource: resource,
- Condition: condition{
- DateLessThan: epochTime{
- EpochTime: expireTime.Truncate(time.Millisecond).Unix(),
- },
- },
- },
- },
- }
-
- return json.Marshal(p)
-}
-
-func (cf *CloudFront) generateSignature(policy []byte) (string, error) {
- hash := sha1.New()
- if _, err := hash.Write(policy); err != nil {
- return "", err
- }
-
- hashed := hash.Sum(nil)
-
- signed, err := rsa.SignPKCS1v15(rand.Reader, cf.key, crypto.SHA1, hashed)
- if err != nil {
- return "", err
- }
-
- encoded := base64Replacer.Replace(base64.StdEncoding.EncodeToString(signed))
-
- return encoded, nil
-}
-
-// Creates a signed url using RSAwithSHA1 as specified by
-// http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-canned-policy.html#private-content-canned-policy-creating-signature
-func (cf *CloudFront) CannedSignedURL(path, queryString string, expires time.Time) (string, error) {
- resource := cf.BaseURL + path
- if queryString != "" {
- resource = path + "?" + queryString
- }
-
- policy, err := buildPolicy(resource, expires)
- if err != nil {
- return "", err
- }
-
- signature, err := cf.generateSignature(policy)
- if err != nil {
- return "", err
- }
-
- // TOOD: Do this once
- uri, err := url.Parse(cf.BaseURL)
- if err != nil {
- return "", err
- }
-
- uri.RawQuery = queryString
- if queryString != "" {
- uri.RawQuery += "&"
- }
-
- expireTime := expires.Truncate(time.Millisecond).Unix()
-
- uri.Path = path
- uri.RawQuery += fmt.Sprintf("Expires=%d&Signature=%s&Key-Pair-Id=%s", expireTime, signature, cf.keyPairId)
-
- return uri.String(), nil
-}
-
-func (cloudfront *CloudFront) SignedURL(path, querystrings string, expires time.Time) string {
- policy := `{"Statement":[{"Resource":"` + path + "?" + querystrings + `,"Condition":{"DateLessThan":{"AWS:EpochTime":` + strconv.FormatInt(expires.Truncate(time.Millisecond).Unix(), 10) + `}}}]}`
-
- hash := sha1.New()
- hash.Write([]byte(policy))
- b := hash.Sum(nil)
- he := base64.StdEncoding.EncodeToString(b)
-
- policySha1 := he
-
- url := cloudfront.BaseURL + path + "?" + querystrings + "&Expires=" + strconv.FormatInt(expires.Unix(), 10) + "&Signature=" + policySha1 + "&Key-Pair-Id=" + cloudfront.keyPairId
-
- return url
-}
diff --git a/vendor/github.com/goamz/goamz/cloudfront/cloudfront_test.go b/vendor/github.com/goamz/goamz/cloudfront/cloudfront_test.go
deleted file mode 100644
index 63744d1cb..000000000
--- a/vendor/github.com/goamz/goamz/cloudfront/cloudfront_test.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package cloudfront
-
-import (
- "crypto/x509"
- "encoding/pem"
- "io/ioutil"
- "net/url"
- "testing"
- "time"
-)
-
-func TestSignedCannedURL(t *testing.T) {
- rawKey, err := ioutil.ReadFile("testdata/key.pem")
- if err != nil {
- t.Fatal(err)
- }
-
- pemKey, _ := pem.Decode(rawKey)
- privateKey, err := x509.ParsePKCS1PrivateKey(pemKey.Bytes)
- if err != nil {
- t.Fatal(err)
- }
-
- cf := &CloudFront{
- key: privateKey,
- keyPairId: "test-key-pair-1231245",
- BaseURL: "https://cloudfront.com",
- }
-
- expireTime, err := time.Parse(time.RFC3339, "2014-03-28T14:00:21Z")
- if err != nil {
- t.Fatal(err)
- }
-
- query := make(url.Values)
- query.Add("test", "value")
-
- uri, err := cf.CannedSignedURL("test", "test=value", expireTime)
- if err != nil {
- t.Fatal(err)
- }
-
- parsed, err := url.Parse(uri)
- if err != nil {
- t.Fatal(err)
- }
-
- signature := parsed.Query().Get("Signature")
- if signature == "" {
- t.Fatal("Encoded signature is empty")
- }
-}
diff --git a/vendor/github.com/goamz/goamz/cloudfront/testdata/key.pem b/vendor/github.com/goamz/goamz/cloudfront/testdata/key.pem
deleted file mode 100644
index 96e820a2c..000000000
--- a/vendor/github.com/goamz/goamz/cloudfront/testdata/key.pem
+++ /dev/null
@@ -1,15 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQC0yMzp9DkPAE99DhsEaGkqougLvtmDKri4bZj0fFjmGmjyyjz9
-hlrsr87LHVWzH/7igK7040HG1UqypX3ijtJa9+6BKHwBBctboU3y4GfwFwVAOumY
-9UytFpyPlgUFrffZLQAywKkT24OgcfEj0G5kiQn760wFnmSUtOuITo708QIDAQAB
-AoGAJUA6+PoZx72Io3wElSPuh5qJteHdb+mdpmLu4XG936wRc/W4G4VTtvGC6tdg
-kUhGfOWHJ26sXwwUGDuBdO146m0DkBTuIooy97afpL6hXgL5v4ELHbbuFJcf4Geg
-/UAuexvRT1HenYFQ/iXM0LlqI33i8cFRc1A+j0Gseo07gAECQQDYFCn7OUokX+Q8
-M2Cwhu7JT1obmP2HwsBtXl0CDDxtOQkuYJP/UqvtdYPz/kRn3yQjoynaCTHYrFz/
-H8oN1nNhAkEA1i9TEpo7RbanIyT4vbc1/5xfjE7Pj0lnGku0QXFp/S+8YxbqhjrQ
-4Qp7TTXIPPqvQhhEpAGGspM460K3F6h7kQJBANJCbMeFa9wRY2ohJIkiA+HoUWph
-aPNeUxkZpa+EcJhn08NJPzpIG/ypSYl3duEMhYIYF3WPVO3ea2/mYxsr/oECQFj5
-td/fdEoEk7AU1sQxDNyPwF2QC8dxbcRNuKcLD0Wfg/oB9hEm88jYytoLQpCabx3c
-6P7cp3EdmaKZx2erlRECQDYTSK2tS0+VoXSV9JbU08Pbu53j3Zhmp4l0csP+l7EU
-U+rRQzKho4X9vpR/VpRGXbw8tTIhojNpHh5ofryVfgk=
------END RSA PRIVATE KEY-----
diff --git a/vendor/github.com/goamz/goamz/cloudfront/testdata/key.pub b/vendor/github.com/goamz/goamz/cloudfront/testdata/key.pub
deleted file mode 100644
index 7d0b5b4d6..000000000
--- a/vendor/github.com/goamz/goamz/cloudfront/testdata/key.pub
+++ /dev/null
@@ -1,6 +0,0 @@
------BEGIN PUBLIC KEY-----
-MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0yMzp9DkPAE99DhsEaGkqougL
-vtmDKri4bZj0fFjmGmjyyjz9hlrsr87LHVWzH/7igK7040HG1UqypX3ijtJa9+6B
-KHwBBctboU3y4GfwFwVAOumY9UytFpyPlgUFrffZLQAywKkT24OgcfEj0G5kiQn7
-60wFnmSUtOuITo708QIDAQAB
------END PUBLIC KEY-----
diff --git a/vendor/github.com/goamz/goamz/cloudwatch/ChangeLog b/vendor/github.com/goamz/goamz/cloudwatch/ChangeLog
deleted file mode 100644
index 46fea639e..000000000
--- a/vendor/github.com/goamz/goamz/cloudwatch/ChangeLog
+++ /dev/null
@@ -1,7 +0,0 @@
-2013-10-21 Carlos Salguero <cfsalguero@gmail.com>
-
-* Removed Namespace from the constructor as not all AWS API method needs it
- and methods like ListMetrics you could need to call the method without a
- Namespace to list all available metrics
-
-* Added ListMetrics method
diff --git a/vendor/github.com/goamz/goamz/cloudwatch/README.md b/vendor/github.com/goamz/goamz/cloudwatch/README.md
deleted file mode 100644
index dc837b4c7..000000000
--- a/vendor/github.com/goamz/goamz/cloudwatch/README.md
+++ /dev/null
@@ -1,109 +0,0 @@
-#GoLang AWS Cloudwatch
-
-## Installation
-Please refer to the project's main page at [https://github.com/goamz/goamz](https://github.com/goamz/goamz) for instructions about how to install.
-
-## Available methods
-
-<table>
- <tr>
- <td>GetMetricStatistics</td>
- <td>Gets statistics for the specified metric.</td>
- </tr>
- <tr>
- <td>ListMetrics</td>
- <td>Returns a list of valid metrics stored for the AWS account.</td>
- </tr>
- <tr>
- <td>PutMetricData</td>
- <td>Publishes metric data points to Amazon CloudWatch.</td>
- </tr>
- <tr>
- <td>PutMetricAlarm</td>
- <td>Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric.</td>
- </tr>
- </table>
-
-[Please refer to AWS Cloudwatch's documentation for more info](http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Operations.html)
-
-##Examples
-####Get Metric Statistics
-
-```
-import (
- "fmt"
- "time"
- "os"
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/cloudwatch"
-)
-
-func test_get_metric_statistics() {
- region := aws.Regions["a_region"]
- namespace:= "AWS/ELB"
- dimension := &cloudwatch.Dimension{
- Name: "LoadBalancerName",
- Value: "your_value",
- }
- metricName := "RequestCount"
- now := time.Now()
- prev := now.Add(time.Duration(600)*time.Second*-1) // 600 secs = 10 minutes
-
- auth, err := aws.GetAuth("your_AccessKeyId", "your_SecretAccessKey", "", now)
- if err != nil {
- fmt.Printf("Error: %+v\n", err)
- os.Exit(1)
- }
-
- cw, err := cloudwatch.NewCloudWatch(auth, region.CloudWatchServicepoint)
- request := &cloudwatch.GetMetricStatisticsRequest {
- Dimensions: []cloudwatch.Dimension{*dimension},
- EndTime: now,
- StartTime: prev,
- MetricName: metricName,
- Unit: "Count", // Not mandatory
- Period: 60,
- Statistics: []string{"Sum"},
- Namespace: namespace,
- }
-
- response, err := cw.GetMetricStatistics(request)
- if err == nil {
- fmt.Printf("%+v\n", response)
- } else {
- fmt.Printf("Error: %+v\n", err)
- }
-}
-
-```
-####List Metrics
-
-```
-import (
- "fmt"
- "time"
- "os"
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/cloudwatch"
-)
-
-func test_list_metrics() {
- region := aws.Regions["us-east-1"] // Any region here
- now := time.Now()
-
- auth, err := aws.GetAuth("an AccessKeyId", "a SecretAccessKey", "", now)
- if err != nil {
- fmt.Printf("Error: %+v\n", err)
- os.Exit(1)
- }
- cw, err := cloudwatch.NewCloudWatch(auth, region.CloudWatchServicepoint)
- request := &cloudwatch.ListMetricsRequest{Namespace: "AWS/EC2"}
-
- response, err := cw.ListMetrics(request)
- if err == nil {
- fmt.Printf("%+v\n", response)
- } else {
- fmt.Printf("Error: %+v\n", err)
- }
-}
-```
diff --git a/vendor/github.com/goamz/goamz/cloudwatch/cloudwatch.go b/vendor/github.com/goamz/goamz/cloudwatch/cloudwatch.go
deleted file mode 100644
index 461d6a102..000000000
--- a/vendor/github.com/goamz/goamz/cloudwatch/cloudwatch.go
+++ /dev/null
@@ -1,404 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this file,
-# You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# The Initial Developer of the Original Code is the Mozilla Foundation.
-# Portions created by the Initial Developer are Copyright (C) 2012
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Ben Bangert (bbangert@mozilla.com)
-# Logan Owen (lsowen@s1network.com)
-#
-# ***** END LICENSE BLOCK *****/
-
-package cloudwatch
-
-import (
- "encoding/xml"
- "errors"
- "fmt"
- "github.com/feyeleanor/sets"
- "github.com/goamz/goamz/aws"
- "strconv"
- "time"
-)
-
-// The CloudWatch type encapsulates all the CloudWatch operations in a region.
-type CloudWatch struct {
- Service aws.AWSService
-}
-
-type Dimension struct {
- Name string
- Value string
-}
-
-type StatisticSet struct {
- Maximum float64
- Minimum float64
- SampleCount float64
- Sum float64
-}
-
-type MetricDatum struct {
- Dimensions []Dimension
- MetricName string
- StatisticValues *StatisticSet
- Timestamp time.Time
- Unit string
- Value float64
-}
-
-type Datapoint struct {
- Average float64
- Maximum float64
- Minimum float64
- SampleCount float64
- Sum float64
- Timestamp time.Time
- Unit string
-}
-
-type GetMetricStatisticsRequest struct {
- Dimensions []Dimension
- EndTime time.Time
- StartTime time.Time
- MetricName string
- Unit string
- Period int
- Statistics []string
- Namespace string
-}
-
-type GetMetricStatisticsResult struct {
- Datapoints []Datapoint `xml:"Datapoints>member"`
- NextToken string `xml:"NextToken"`
-}
-
-type GetMetricStatisticsResponse struct {
- GetMetricStatisticsResult GetMetricStatisticsResult
- ResponseMetadata aws.ResponseMetadata
-}
-
-type Metric struct {
- Dimensions []Dimension `xml:"Dimensions>member"`
- MetricName string
- Namespace string
-}
-
-type ListMetricsResult struct {
- Metrics []Metric `xml:"Metrics>member"`
- NextToken string
-}
-
-type ListMetricsResponse struct {
- ListMetricsResult ListMetricsResult
- ResponseMetadata aws.ResponseMetadata
-}
-
-type ListMetricsRequest struct {
- Dimensions []Dimension
- MetricName string
- Namespace string
- NextToken string
-}
-
-type AlarmAction struct {
- ARN string
-}
-
-type MetricAlarm struct {
- AlarmActions []AlarmAction
- AlarmDescription string
- AlarmName string
- ComparisonOperator string
- Dimensions []Dimension
- EvaluationPeriods int
- InsufficientDataActions []AlarmAction
- MetricName string
- Namespace string
- OkActions []AlarmAction
- Period int
- Statistic string
- Threshold float64
- Unit string
-}
-
-var attempts = aws.AttemptStrategy{
- Min: 5,
- Total: 5 * time.Second,
- Delay: 200 * time.Millisecond,
-}
-
-var validUnits = sets.SSet(
- "Seconds",
- "Microseconds",
- "Milliseconds",
- "Bytes",
- "Kilobytes",
- "Megabytes",
- "Gigabytes",
- "Terabytes",
- "Bits",
- "Kilobits",
- "Megabits",
- "Gigabits",
- "Terabits",
- "Percent",
- "Count",
- "Bytes/Second",
- "Kilobytes/Second",
- "Megabytes/Second",
- "Gigabytes/Second",
- "Terabytes/Second",
- "Bits/Second",
- "Kilobits/Second",
- "Megabits/Second",
- "Gigabits/Second",
- "Terabits/Second",
- "Count/Second",
-)
-
-var validMetricStatistics = sets.SSet(
- "Average",
- "Sum",
- "SampleCount",
- "Maximum",
- "Minimum",
-)
-
-var validComparisonOperators = sets.SSet(
- "LessThanThreshold",
- "LessThanOrEqualToThreshold",
- "GreaterThanThreshold",
- "GreaterThanOrEqualToThreshold",
-)
-
-// Create a new CloudWatch object for a given namespace
-func NewCloudWatch(auth aws.Auth, region aws.ServiceInfo) (*CloudWatch, error) {
- service, err := aws.NewService(auth, region)
- if err != nil {
- return nil, err
- }
- return &CloudWatch{
- Service: service,
- }, nil
-}
-
-func (c *CloudWatch) query(method, path string, params map[string]string, resp interface{}) error {
- // Add basic Cloudwatch param
- params["Version"] = "2010-08-01"
-
- r, err := c.Service.Query(method, path, params)
- if err != nil {
- return err
- }
- defer r.Body.Close()
-
- if r.StatusCode != 200 {
- return c.Service.BuildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-// Get statistics for specified metric
-//
-// If the arguments are invalid or the server returns an error, the error will
-// be set and the other values undefined.
-func (c *CloudWatch) GetMetricStatistics(req *GetMetricStatisticsRequest) (result *GetMetricStatisticsResponse, err error) {
- statisticsSet := sets.SSet(req.Statistics...)
- // Kick out argument errors
- switch {
- case req.EndTime.IsZero():
- err = errors.New("No endTime specified")
- case req.StartTime.IsZero():
- err = errors.New("No startTime specified")
- case req.MetricName == "":
- err = errors.New("No metricName specified")
- case req.Namespace == "":
- err = errors.New("No Namespace specified")
- case req.Period < 60 || req.Period%60 != 0:
- err = errors.New("Period not 60 seconds or a multiple of 60 seconds")
- case len(req.Statistics) < 1:
- err = errors.New("No statistics supplied")
- case validMetricStatistics.Union(statisticsSet).Len() != validMetricStatistics.Len():
- err = errors.New("Invalid statistic values supplied")
- case req.Unit != "" && !validUnits.Member(req.Unit):
- err = errors.New("Unit is not a valid value")
- }
- if err != nil {
- return
- }
-
- // Serialize all the params
- params := aws.MakeParams("GetMetricStatistics")
- params["EndTime"] = req.EndTime.UTC().Format(time.RFC3339)
- params["StartTime"] = req.StartTime.UTC().Format(time.RFC3339)
- params["MetricName"] = req.MetricName
- params["Namespace"] = req.Namespace
- params["Period"] = strconv.Itoa(req.Period)
- if req.Unit != "" {
- params["Unit"] = req.Unit
- }
-
- // Serialize the lists of data
- for i, d := range req.Dimensions {
- prefix := "Dimensions.member." + strconv.Itoa(i+1)
- params[prefix+".Name"] = d.Name
- params[prefix+".Value"] = d.Value
- }
- for i, d := range req.Statistics {
- prefix := "Statistics.member." + strconv.Itoa(i+1)
- params[prefix] = d
- }
- result = new(GetMetricStatisticsResponse)
- err = c.query("GET", "/", params, result)
- return
-}
-
-// Returns a list of valid metrics stored for the AWS account owner.
-// Returned metrics can be used with GetMetricStatistics to obtain statistical data for a given metric.
-
-func (c *CloudWatch) ListMetrics(req *ListMetricsRequest) (result *ListMetricsResponse, err error) {
-
- // Serialize all the params
- params := aws.MakeParams("ListMetrics")
- if req.Namespace != "" {
- params["Namespace"] = req.Namespace
- }
- if len(req.Dimensions) > 0 {
- for i, d := range req.Dimensions {
- prefix := "Dimensions.member." + strconv.Itoa(i+1)
- params[prefix+".Name"] = d.Name
- params[prefix+".Value"] = d.Value
- }
- }
-
- result = new(ListMetricsResponse)
- err = c.query("GET", "/", params, &result)
- metrics := result.ListMetricsResult.Metrics
- if result.ListMetricsResult.NextToken != "" {
- params = aws.MakeParams("ListMetrics")
- params["NextToken"] = result.ListMetricsResult.NextToken
- for result.ListMetricsResult.NextToken != "" && err == nil {
- result = new(ListMetricsResponse)
- err = c.query("GET", "/", params, &result)
- if err == nil {
- newslice := make([]Metric, len(metrics)+len(result.ListMetricsResult.Metrics))
- copy(newslice, metrics)
- copy(newslice[len(metrics):], result.ListMetricsResult.Metrics)
- metrics = newslice
- }
- }
- result.ListMetricsResult.Metrics = metrics
- }
- return
-}
-
-func (c *CloudWatch) PutMetricData(metrics []MetricDatum) (result *aws.BaseResponse, err error) {
- return c.PutMetricDataNamespace(metrics, "")
-}
-
-func (c *CloudWatch) PutMetricDataNamespace(metrics []MetricDatum, namespace string) (result *aws.BaseResponse, err error) {
- // Serialize the params
- params := aws.MakeParams("PutMetricData")
- if namespace != "" {
- params["Namespace"] = namespace
- }
- for i, metric := range metrics {
- prefix := "MetricData.member." + strconv.Itoa(i+1)
- if metric.MetricName == "" {
- err = fmt.Errorf("No metric name supplied for metric: %d", i)
- return
- }
- params[prefix+".MetricName"] = metric.MetricName
- if metric.Unit != "" {
- params[prefix+".Unit"] = metric.Unit
- }
- params[prefix+".Value"] = strconv.FormatFloat(metric.Value, 'E', 10, 64)
- if !metric.Timestamp.IsZero() {
- params[prefix+".Timestamp"] = metric.Timestamp.UTC().Format(time.RFC3339)
- }
- for j, dim := range metric.Dimensions {
- dimprefix := prefix + ".Dimensions.member." + strconv.Itoa(j+1)
- params[dimprefix+".Name"] = dim.Name
- params[dimprefix+".Value"] = dim.Value
- }
- if metric.StatisticValues != nil {
- statprefix := prefix + ".StatisticValues"
- params[statprefix+".Maximum"] = strconv.FormatFloat(metric.StatisticValues.Maximum, 'E', 10, 64)
- params[statprefix+".Minimum"] = strconv.FormatFloat(metric.StatisticValues.Minimum, 'E', 10, 64)
- params[statprefix+".SampleCount"] = strconv.FormatFloat(metric.StatisticValues.SampleCount, 'E', 10, 64)
- params[statprefix+".Sum"] = strconv.FormatFloat(metric.StatisticValues.Sum, 'E', 10, 64)
- }
- }
- result = new(aws.BaseResponse)
- err = c.query("POST", "/", params, result)
- return
-}
-
-func (c *CloudWatch) PutMetricAlarm(alarm *MetricAlarm) (result *aws.BaseResponse, err error) {
- // Serialize the params
- params := aws.MakeParams("PutMetricAlarm")
-
- switch {
- case alarm.AlarmName == "":
- err = errors.New("No AlarmName supplied")
- case !validComparisonOperators.Member(alarm.ComparisonOperator):
- err = errors.New("ComparisonOperator is not valid")
- case alarm.EvaluationPeriods == 0:
- err = errors.New("No number of EvaluationPeriods specified")
- case alarm.MetricName == "":
- err = errors.New("No MetricName specified")
- case alarm.Namespace == "":
- err = errors.New("No Namespace specified")
- case alarm.Period == 0:
- err = errors.New("No Period over which statistic should apply was specified")
- case !validMetricStatistics.Member(alarm.Statistic):
- err = errors.New("Invalid statistic value supplied")
- case alarm.Threshold == 0:
- err = errors.New("No Threshold value specified")
- case alarm.Unit != "" && !validUnits.Member(alarm.Unit):
- err = errors.New("Unit is not a valid value")
- }
- if err != nil {
- return
- }
-
- for i, action := range alarm.AlarmActions {
- params["AlarmActions.member."+strconv.Itoa(i+1)] = action.ARN
- }
- for i, action := range alarm.InsufficientDataActions {
- params["InsufficientDataActions.member."+strconv.Itoa(i+1)] = action.ARN
- }
- for i, action := range alarm.OkActions {
- params["OKActions.member."+strconv.Itoa(i+1)] = action.ARN
- }
- if alarm.AlarmDescription != "" {
- params["AlarmDescription"] = alarm.AlarmDescription
- }
- params["AlarmDescription"] = alarm.AlarmDescription
- params["AlarmName"] = alarm.AlarmName
- params["ComparisonOperator"] = alarm.ComparisonOperator
- for i, dim := range alarm.Dimensions {
- dimprefix := "Dimensions.member." + strconv.Itoa(i+1)
- params[dimprefix+".Name"] = dim.Name
- params[dimprefix+".Value"] = dim.Value
- }
- params["EvaluationPeriods"] = strconv.Itoa(alarm.EvaluationPeriods)
- params["MetricName"] = alarm.MetricName
- params["Namespace"] = alarm.Namespace
- params["Period"] = strconv.Itoa(alarm.Period)
- params["Statistic"] = alarm.Statistic
- params["Threshold"] = strconv.FormatFloat(alarm.Threshold, 'E', 10, 64)
- if alarm.Unit != "" {
- params["Unit"] = alarm.Unit
- }
-
- result = new(aws.BaseResponse)
- err = c.query("POST", "/", params, result)
- return
-}
diff --git a/vendor/github.com/goamz/goamz/cloudwatch/cloudwatch_test.go b/vendor/github.com/goamz/goamz/cloudwatch/cloudwatch_test.go
deleted file mode 100644
index a4271f1ea..000000000
--- a/vendor/github.com/goamz/goamz/cloudwatch/cloudwatch_test.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package cloudwatch_test
-
-import (
- "testing"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/cloudwatch"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-type S struct {
- cw *cloudwatch.CloudWatch
-}
-
-var _ = Suite(&S{})
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.cw, _ = cloudwatch.NewCloudWatch(auth, aws.ServiceInfo{testServer.URL, aws.V2Signature})
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func getTestAlarm() *cloudwatch.MetricAlarm {
- alarm := new(cloudwatch.MetricAlarm)
-
- alarm.AlarmName = "TestAlarm"
- alarm.MetricName = "TestMetric"
- alarm.Namespace = "TestNamespace"
- alarm.ComparisonOperator = "LessThanThreshold"
- alarm.Threshold = 1
- alarm.EvaluationPeriods = 5
- alarm.Period = 60
- alarm.Statistic = "Sum"
-
- return alarm
-}
-
-func (s *S) TestPutAlarm(c *C) {
- testServer.Response(200, nil, "<RequestId>123</RequestId>")
-
- alarm := getTestAlarm()
-
- _, err := s.cw.PutMetricAlarm(alarm)
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Form["Action"], DeepEquals, []string{"PutMetricAlarm"})
- c.Assert(req.Form["AlarmName"], DeepEquals, []string{"TestAlarm"})
- c.Assert(req.Form["ComparisonOperator"], DeepEquals, []string{"LessThanThreshold"})
- c.Assert(req.Form["EvaluationPeriods"], DeepEquals, []string{"5"})
- c.Assert(req.Form["Threshold"], DeepEquals, []string{"1.0000000000E+00"})
- c.Assert(req.Form["Period"], DeepEquals, []string{"60"})
- c.Assert(req.Form["Statistic"], DeepEquals, []string{"Sum"})
-}
-
-func (s *S) TestPutAlarmWithAction(c *C) {
- testServer.Response(200, nil, "<RequestId>123</RequestId>")
-
- alarm := getTestAlarm()
-
- alarm.AlarmActions = []cloudwatch.AlarmAction{
- cloudwatch.AlarmAction{
- ARN: "123",
- },
- }
-
- alarm.OkActions = []cloudwatch.AlarmAction{
- cloudwatch.AlarmAction{
- ARN: "456",
- },
- }
-
- alarm.InsufficientDataActions = []cloudwatch.AlarmAction{
- cloudwatch.AlarmAction{
- ARN: "789",
- },
- }
-
- _, err := s.cw.PutMetricAlarm(alarm)
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Form["Action"], DeepEquals, []string{"PutMetricAlarm"})
- c.Assert(req.Form["AlarmActions.member.1"], DeepEquals, []string{"123"})
- c.Assert(req.Form["OKActions.member.1"], DeepEquals, []string{"456"})
- c.Assert(req.Form["InsufficientDataActions.member.1"], DeepEquals, []string{"789"})
- c.Assert(req.Form["AlarmName"], DeepEquals, []string{"TestAlarm"})
- c.Assert(req.Form["ComparisonOperator"], DeepEquals, []string{"LessThanThreshold"})
- c.Assert(req.Form["EvaluationPeriods"], DeepEquals, []string{"5"})
- c.Assert(req.Form["Threshold"], DeepEquals, []string{"1.0000000000E+00"})
- c.Assert(req.Form["Period"], DeepEquals, []string{"60"})
- c.Assert(req.Form["Statistic"], DeepEquals, []string{"Sum"})
-}
-
-func (s *S) TestPutAlarmInvalidComapirsonOperator(c *C) {
- testServer.Response(200, nil, "<RequestId>123</RequestId>")
-
- alarm := getTestAlarm()
-
- alarm.ComparisonOperator = "LessThan"
-
- _, err := s.cw.PutMetricAlarm(alarm)
- c.Assert(err, NotNil)
- c.Assert(err.Error(), Equals, "ComparisonOperator is not valid")
-}
-
-func (s *S) TestPutAlarmInvalidStatistic(c *C) {
- testServer.Response(200, nil, "<RequestId>123</RequestId>")
-
- alarm := getTestAlarm()
-
- alarm.Statistic = "Count"
-
- _, err := s.cw.PutMetricAlarm(alarm)
- c.Assert(err, NotNil)
- c.Assert(err.Error(), Equals, "Invalid statistic value supplied")
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/.gitignore b/vendor/github.com/goamz/goamz/dynamodb/.gitignore
deleted file mode 100644
index 2385ddf57..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-dynamodb_local*
diff --git a/vendor/github.com/goamz/goamz/dynamodb/Makefile b/vendor/github.com/goamz/goamz/dynamodb/Makefile
deleted file mode 100644
index 4c02cd4b7..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-DYNAMODB_LOCAL_VERSION = 2013-12-12
-
-launch: DynamoDBLocal.jar
- cd dynamodb_local_$(DYNAMODB_LOCAL_VERSION) && java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar
-
-DynamoDBLocal.jar: dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz
- [ -d dynamodb_local_$(DYNAMODB_LOCAL_VERSION) ] || tar -zxf dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz
-
-dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz:
- curl -O https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_$(DYNAMODB_LOCAL_VERSION).tar.gz
-
-clean:
- rm -rf dynamodb_local_$(DYNAMODB_LOCAL_VERSION)*
diff --git a/vendor/github.com/goamz/goamz/dynamodb/README.md b/vendor/github.com/goamz/goamz/dynamodb/README.md
deleted file mode 100644
index 5896d67b6..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Running integration tests
-
-## against DynamoDB local
-
-To download and launch DynamoDB local:
-
-```sh
-$ make
-```
-
-To test:
-
-```sh
-$ go test -v -amazon
-```
-
-## against real DynamoDB server on us-east
-
-_WARNING_: Some dangerous operations such as `DeleteTable` will be performed during the tests. Please be careful.
-
-To test:
-
-```sh
-$ go test -v -amazon -local=false
-```
-
-_Note_: Running tests against real DynamoDB will take several minutes.
diff --git a/vendor/github.com/goamz/goamz/dynamodb/attribute.go b/vendor/github.com/goamz/goamz/dynamodb/attribute.go
deleted file mode 100755
index 38389ada2..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/attribute.go
+++ /dev/null
@@ -1,185 +0,0 @@
-package dynamodb
-
-import (
- "strconv"
-)
-
-const (
- TYPE_STRING = "S"
- TYPE_NUMBER = "N"
- TYPE_BINARY = "B"
-
- TYPE_STRING_SET = "SS"
- TYPE_NUMBER_SET = "NS"
- TYPE_BINARY_SET = "BS"
-
- COMPARISON_EQUAL = "EQ"
- COMPARISON_NOT_EQUAL = "NE"
- COMPARISON_LESS_THAN_OR_EQUAL = "LE"
- COMPARISON_LESS_THAN = "LT"
- COMPARISON_GREATER_THAN_OR_EQUAL = "GE"
- COMPARISON_GREATER_THAN = "GT"
- COMPARISON_ATTRIBUTE_EXISTS = "NOT_NULL"
- COMPARISON_ATTRIBUTE_DOES_NOT_EXIST = "NULL"
- COMPARISON_CONTAINS = "CONTAINS"
- COMPARISON_DOES_NOT_CONTAIN = "NOT_CONTAINS"
- COMPARISON_BEGINS_WITH = "BEGINS_WITH"
- COMPARISON_IN = "IN"
- COMPARISON_BETWEEN = "BETWEEN"
-)
-
-type Key struct {
- HashKey string
- RangeKey string
-}
-
-type PrimaryKey struct {
- KeyAttribute *Attribute
- RangeAttribute *Attribute
-}
-
-type Attribute struct {
- Type string
- Name string
- Value string
- SetValues []string
- Exists string // exists on dynamodb? Values: "true", "false", or ""
-}
-
-type AttributeComparison struct {
- AttributeName string
- ComparisonOperator string
- AttributeValueList []Attribute // contains attributes with only types and names (value ignored)
-}
-
-func NewEqualInt64AttributeComparison(attributeName string, equalToValue int64) *AttributeComparison {
- numeric := NewNumericAttribute(attributeName, strconv.FormatInt(equalToValue, 10))
- return &AttributeComparison{attributeName,
- COMPARISON_EQUAL,
- []Attribute{*numeric},
- }
-}
-
-func NewEqualStringAttributeComparison(attributeName string, equalToValue string) *AttributeComparison {
- str := NewStringAttribute(attributeName, equalToValue)
- return &AttributeComparison{attributeName,
- COMPARISON_EQUAL,
- []Attribute{*str},
- }
-}
-
-func NewStringAttributeComparison(attributeName string, comparisonOperator string, value string) *AttributeComparison {
- valueToCompare := NewStringAttribute(attributeName, value)
- return &AttributeComparison{attributeName,
- comparisonOperator,
- []Attribute{*valueToCompare},
- }
-}
-
-func NewNumericAttributeComparison(attributeName string, comparisonOperator string, value int64) *AttributeComparison {
- valueToCompare := NewNumericAttribute(attributeName, strconv.FormatInt(value, 10))
- return &AttributeComparison{attributeName,
- comparisonOperator,
- []Attribute{*valueToCompare},
- }
-}
-
-func NewBinaryAttributeComparison(attributeName string, comparisonOperator string, value bool) *AttributeComparison {
- valueToCompare := NewBinaryAttribute(attributeName, strconv.FormatBool(value))
- return &AttributeComparison{attributeName,
- comparisonOperator,
- []Attribute{*valueToCompare},
- }
-}
-
-func NewStringAttribute(name string, value string) *Attribute {
- return &Attribute{
- Type: TYPE_STRING,
- Name: name,
- Value: value,
- }
-}
-
-func NewNumericAttribute(name string, value string) *Attribute {
- return &Attribute{
- Type: TYPE_NUMBER,
- Name: name,
- Value: value,
- }
-}
-
-func NewBinaryAttribute(name string, value string) *Attribute {
- return &Attribute{
- Type: TYPE_BINARY,
- Name: name,
- Value: value,
- }
-}
-
-func NewStringSetAttribute(name string, values []string) *Attribute {
- return &Attribute{
- Type: TYPE_STRING_SET,
- Name: name,
- SetValues: values,
- }
-}
-
-func NewNumericSetAttribute(name string, values []string) *Attribute {
- return &Attribute{
- Type: TYPE_NUMBER_SET,
- Name: name,
- SetValues: values,
- }
-}
-
-func NewBinarySetAttribute(name string, values []string) *Attribute {
- return &Attribute{
- Type: TYPE_BINARY_SET,
- Name: name,
- SetValues: values,
- }
-}
-
-func (a *Attribute) SetType() bool {
- switch a.Type {
- case TYPE_BINARY_SET, TYPE_NUMBER_SET, TYPE_STRING_SET:
- return true
- }
- return false
-}
-
-func (a *Attribute) SetExists(exists bool) *Attribute {
- if exists {
- a.Exists = "true"
- } else {
- a.Exists = "false"
- }
- return a
-}
-
-func (k *PrimaryKey) HasRange() bool {
- return k.RangeAttribute != nil
-}
-
-// Useful when you may have many goroutines using a primary key, so they don't fuxor up your values.
-func (k *PrimaryKey) Clone(h string, r string) []Attribute {
- pk := &Attribute{
- Type: k.KeyAttribute.Type,
- Name: k.KeyAttribute.Name,
- Value: h,
- }
-
- result := []Attribute{*pk}
-
- if k.HasRange() {
- rk := &Attribute{
- Type: k.RangeAttribute.Type,
- Name: k.RangeAttribute.Name,
- Value: r,
- }
-
- result = append(result, *rk)
- }
-
- return result
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/const.go b/vendor/github.com/goamz/goamz/dynamodb/const.go
deleted file mode 100644
index b070d44cb..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/const.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package dynamodb
-
-type ReturnValues string
-
-const (
- NONE ReturnValues = "NONE"
- ALL_OLD ReturnValues = "ALL_HOLD"
- UPDATED_OLD ReturnValues = "UPDATED_OLD"
- ALL_NEW ReturnValues = "ALL_NEW"
- UPDATED_NEW ReturnValues = "UPDATED_NEW"
-)
diff --git a/vendor/github.com/goamz/goamz/dynamodb/dynamodb.go b/vendor/github.com/goamz/goamz/dynamodb/dynamodb.go
deleted file mode 100755
index 7881e8dc1..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/dynamodb.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package dynamodb
-
-import simplejson "github.com/bitly/go-simplejson"
-import (
- "errors"
- "github.com/goamz/goamz/aws"
- "io/ioutil"
- "log"
- "net/http"
- "strings"
- "time"
-)
-
-type Server struct {
- Auth aws.Auth
- Region aws.Region
-}
-
-/*
-type Query struct {
- Query string
-}
-*/
-
-/*
-func NewQuery(queryParts []string) *Query {
- return &Query{
- "{" + strings.Join(queryParts, ",") + "}",
- }
-}
-*/
-
-const (
- // DynamoDBAPIPrefix is the versioned prefix for DynamoDB API commands.
- DynamoDBAPIPrefix = "DynamoDB_20120810."
- // DynamoDBStreamsAPIPrefix is the versioned prefix for DynamoDB Streams API commands.
- DynamoDBStreamsAPIPrefix = "DynamoDBStreams_20120810."
-)
-
-// Specific error constants
-var ErrNotFound = errors.New("Item not found")
-
-// Error represents an error in an operation with Dynamodb (following goamz/s3)
-type Error struct {
- StatusCode int // HTTP status code (200, 403, ...)
- Status string
- Code string // Dynamodb error code ("MalformedQueryString", ...)
- Message string // The human-oriented error message
-}
-
-func (e *Error) Error() string {
- return e.Code + ": " + e.Message
-}
-
-func buildError(r *http.Response, jsonBody []byte) error {
-
- ddbError := Error{
- StatusCode: r.StatusCode,
- Status: r.Status,
- }
- // TODO return error if Unmarshal fails?
-
- json, err := simplejson.NewJson(jsonBody)
- if err != nil {
- log.Printf("Failed to parse body as JSON")
- return err
- }
- ddbError.Message = json.Get("message").MustString()
-
- // Of the form: com.amazon.coral.validate#ValidationException
- // We only want the last part
- codeStr := json.Get("__type").MustString()
- hashIndex := strings.Index(codeStr, "#")
- if hashIndex > 0 {
- codeStr = codeStr[hashIndex+1:]
- }
- ddbError.Code = codeStr
-
- return &ddbError
-}
-
-func (s *Server) queryServer(target string, query *Query) ([]byte, error) {
- data := strings.NewReader(query.String())
- var endpoint string
- if isStreamsTarget(target) {
- endpoint = s.Region.DynamoDBStreamsEndpoint
- } else {
- endpoint = s.Region.DynamoDBEndpoint
- }
- hreq, err := http.NewRequest("POST", endpoint+"/", data)
- if err != nil {
- return nil, err
- }
-
- hreq.Header.Set("Content-Type", "application/x-amz-json-1.0")
- hreq.Header.Set("X-Amz-Date", time.Now().UTC().Format(aws.ISO8601BasicFormat))
- hreq.Header.Set("X-Amz-Target", target)
-
- token := s.Auth.Token()
- if token != "" {
- hreq.Header.Set("X-Amz-Security-Token", token)
- }
-
- signer := aws.NewV4Signer(s.Auth, "dynamodb", s.Region)
- signer.Sign(hreq)
-
- resp, err := http.DefaultClient.Do(hreq)
-
- if err != nil {
- log.Printf("Error calling Amazon")
- return nil, err
- }
-
- defer resp.Body.Close()
-
- body, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- log.Printf("Could not read response body")
- return nil, err
- }
-
- // http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html
- // "A response code of 200 indicates the operation was successful."
- if resp.StatusCode != 200 {
- ddbErr := buildError(resp, body)
- return nil, ddbErr
- }
-
- return body, nil
-}
-
-func target(name string) string {
- return DynamoDBAPIPrefix + name
-}
-
-func streamsTarget(name string) string {
- return DynamoDBStreamsAPIPrefix + name
-}
-
-func isStreamsTarget(target string) bool {
- return strings.HasPrefix(target, DynamoDBStreamsAPIPrefix)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/dynamodb_test.go b/vendor/github.com/goamz/goamz/dynamodb/dynamodb_test.go
deleted file mode 100755
index 63dd03da3..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/dynamodb_test.go
+++ /dev/null
@@ -1,166 +0,0 @@
-package dynamodb_test
-
-import (
- "flag"
- "testing"
- "time"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/dynamodb"
- . "gopkg.in/check.v1"
-)
-
-const TIMEOUT = 3 * time.Minute
-
-var amazon = flag.Bool("amazon", false, "Enable tests against dynamodb")
-var local = flag.Bool("local", true, "Use DynamoDB local on 8080 instead of real server on us-east.")
-
-var dynamodb_region aws.Region
-var dynamodb_auth aws.Auth
-
-type DynamoDBTest struct {
- server *dynamodb.Server
- aws.Region // Exports Region
- TableDescriptionT dynamodb.TableDescriptionT
- table *dynamodb.Table
-}
-
-// Delete all items in the table
-func (s *DynamoDBTest) TearDownTest(c *C) {
- pk, err := s.TableDescriptionT.BuildPrimaryKey()
- if err != nil {
- c.Fatal(err)
- }
-
- attrs, err := s.table.Scan(nil)
- if err != nil {
- c.Fatal(err)
- }
- for _, a := range attrs {
- key := &dynamodb.Key{
- HashKey: a[pk.KeyAttribute.Name].Value,
- }
- if pk.HasRange() {
- key.RangeKey = a[pk.RangeAttribute.Name].Value
- }
- if ok, err := s.table.DeleteItem(key); !ok {
- c.Fatal(err)
- }
- }
-}
-
-func (s *DynamoDBTest) TearDownSuite(c *C) {
- // return immediately in the case of calling c.Skip() in SetUpSuite()
- if s.server == nil {
- return
- }
-
- // check whether the table exists
- if tables, err := s.server.ListTables(); err != nil {
- c.Fatal(err)
- } else {
- if !findTableByName(tables, s.TableDescriptionT.TableName) {
- return
- }
- }
-
- // Delete the table and wait
- if _, err := s.server.DeleteTable(s.TableDescriptionT); err != nil {
- c.Fatal(err)
- }
-
- done := make(chan bool)
- timeout := time.After(TIMEOUT)
- go func() {
- for {
- select {
- case <-done:
- return
- default:
- tables, err := s.server.ListTables()
- if err != nil {
- c.Fatal(err)
- }
- if findTableByName(tables, s.TableDescriptionT.TableName) {
- time.Sleep(5 * time.Second)
- } else {
- done <- true
- return
- }
- }
- }
- }()
- select {
- case <-done:
- break
- case <-timeout:
- c.Error("Expect the table to be deleted but timed out")
- close(done)
- }
-}
-
-func (s *DynamoDBTest) WaitUntilStatus(c *C, status string) {
- // We should wait until the table is in specified status because a real DynamoDB has some delay for ready
- done := make(chan bool)
- timeout := time.After(TIMEOUT)
- go func() {
- for {
- select {
- case <-done:
- return
- default:
- desc, err := s.table.DescribeTable()
- if err != nil {
- c.Fatal(err)
- }
- if desc.TableStatus == status {
- done <- true
- return
- }
- time.Sleep(5 * time.Second)
- }
- }
- }()
- select {
- case <-done:
- break
- case <-timeout:
- c.Errorf("Expect a status to be %s, but timed out", status)
- close(done)
- }
-}
-
-func setUpAuth(c *C) {
- if !*amazon {
- c.Skip("Test against amazon not enabled.")
- }
- if *local {
- c.Log("Using local server")
- dynamodb_region = aws.Region{
- DynamoDBEndpoint: "http://127.0.0.1:8000",
- DynamoDBStreamsEndpoint: "http://127.0.0.1:8000",
- }
- dynamodb_auth = aws.Auth{AccessKey: "DUMMY_KEY", SecretKey: "DUMMY_SECRET"}
- } else {
- c.Log("Using REAL AMAZON SERVER")
- dynamodb_region = aws.USEast
- auth, err := aws.EnvAuth()
- if err != nil {
- c.Fatal(err)
- }
- dynamodb_auth = auth
- }
-}
-
-func findTableByName(tables []string, name string) bool {
- for _, t := range tables {
- if t == name {
- return true
- }
- }
- return false
-}
-
-func Test(t *testing.T) {
- TestingT(t)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/item.go b/vendor/github.com/goamz/goamz/dynamodb/item.go
deleted file mode 100755
index a3814d9ad..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/item.go
+++ /dev/null
@@ -1,351 +0,0 @@
-package dynamodb
-
-import simplejson "github.com/bitly/go-simplejson"
-import (
- "errors"
- "fmt"
- "log"
-)
-
-type BatchGetItem struct {
- Server *Server
- Keys map[*Table][]Key
-}
-
-type BatchWriteItem struct {
- Server *Server
- ItemActions map[*Table]map[string][][]Attribute
-}
-
-func (t *Table) BatchGetItems(keys []Key) *BatchGetItem {
- batchGetItem := &BatchGetItem{t.Server, make(map[*Table][]Key)}
-
- batchGetItem.Keys[t] = keys
- return batchGetItem
-}
-
-func (t *Table) BatchWriteItems(itemActions map[string][][]Attribute) *BatchWriteItem {
- batchWriteItem := &BatchWriteItem{t.Server, make(map[*Table]map[string][][]Attribute)}
-
- batchWriteItem.ItemActions[t] = itemActions
- return batchWriteItem
-}
-
-func (batchGetItem *BatchGetItem) AddTable(t *Table, keys *[]Key) *BatchGetItem {
- batchGetItem.Keys[t] = *keys
- return batchGetItem
-}
-
-func (batchWriteItem *BatchWriteItem) AddTable(t *Table, itemActions *map[string][][]Attribute) *BatchWriteItem {
- batchWriteItem.ItemActions[t] = *itemActions
- return batchWriteItem
-}
-
-func (batchGetItem *BatchGetItem) Execute() (map[string][]map[string]*Attribute, error) {
- q := NewEmptyQuery()
- q.AddGetRequestItems(batchGetItem.Keys)
-
- jsonResponse, err := batchGetItem.Server.queryServer("DynamoDB_20120810.BatchGetItem", q)
- if err != nil {
- return nil, err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
-
- if err != nil {
- return nil, err
- }
-
- results := make(map[string][]map[string]*Attribute)
-
- tables, err := json.Get("Responses").Map()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- for table, entries := range tables {
- var tableResult []map[string]*Attribute
-
- jsonEntriesArray, ok := entries.([]interface{})
- if !ok {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- for _, entry := range jsonEntriesArray {
- item, ok := entry.(map[string]interface{})
- if !ok {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- unmarshalledItem := parseAttributes(item)
- tableResult = append(tableResult, unmarshalledItem)
- }
-
- results[table] = tableResult
- }
-
- return results, nil
-}
-
-func (batchWriteItem *BatchWriteItem) Execute() (map[string]interface{}, error) {
- q := NewEmptyQuery()
- q.AddWriteRequestItems(batchWriteItem.ItemActions)
-
- jsonResponse, err := batchWriteItem.Server.queryServer("DynamoDB_20120810.BatchWriteItem", q)
-
- if err != nil {
- return nil, err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
-
- if err != nil {
- return nil, err
- }
-
- unprocessed, err := json.Get("UnprocessedItems").Map()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- if len(unprocessed) == 0 {
- return nil, nil
- } else {
- return unprocessed, errors.New("One or more unprocessed items.")
- }
-
-}
-
-func (t *Table) GetItem(key *Key) (map[string]*Attribute, error) {
- return t.getItem(key, false)
-}
-
-func (t *Table) GetItemConsistent(key *Key, consistentRead bool) (map[string]*Attribute, error) {
- return t.getItem(key, consistentRead)
-}
-
-func (t *Table) getItem(key *Key, consistentRead bool) (map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKey(t, key)
-
- if consistentRead {
- q.ConsistentRead(consistentRead)
- }
-
- jsonResponse, err := t.Server.queryServer(target("GetItem"), q)
- if err != nil {
- return nil, err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
- if err != nil {
- return nil, err
- }
-
- itemJson, ok := json.CheckGet("Item")
- if !ok {
- // We got an empty from amz. The item doesn't exist.
- return nil, ErrNotFound
- }
-
- item, err := itemJson.Map()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- return parseAttributes(item), nil
-
-}
-
-func (t *Table) PutItem(hashKey string, rangeKey string, attributes []Attribute) (bool, error) {
- return t.putItem(hashKey, rangeKey, attributes, nil)
-}
-
-func (t *Table) ConditionalPutItem(hashKey, rangeKey string, attributes, expected []Attribute) (bool, error) {
- return t.putItem(hashKey, rangeKey, attributes, expected)
-}
-
-func (t *Table) putItem(hashKey, rangeKey string, attributes, expected []Attribute) (bool, error) {
- if len(attributes) == 0 {
- return false, errors.New("At least one attribute is required.")
- }
-
- q := NewQuery(t)
-
- keys := t.Key.Clone(hashKey, rangeKey)
- attributes = append(attributes, keys...)
-
- q.AddItem(attributes)
- if expected != nil {
- q.AddExpected(expected)
- }
-
- jsonResponse, err := t.Server.queryServer(target("PutItem"), q)
-
- if err != nil {
- return false, err
- }
-
- _, err = simplejson.NewJson(jsonResponse)
- if err != nil {
- return false, err
- }
-
- return true, nil
-}
-
-func (t *Table) deleteItem(key *Key, expected []Attribute) (bool, error) {
- q := NewQuery(t)
- q.AddKey(t, key)
-
- if expected != nil {
- q.AddExpected(expected)
- }
-
- jsonResponse, err := t.Server.queryServer(target("DeleteItem"), q)
-
- if err != nil {
- return false, err
- }
-
- _, err = simplejson.NewJson(jsonResponse)
- if err != nil {
- return false, err
- }
-
- return true, nil
-}
-
-func (t *Table) DeleteItem(key *Key) (bool, error) {
- return t.deleteItem(key, nil)
-}
-
-func (t *Table) ConditionalDeleteItem(key *Key, expected []Attribute) (bool, error) {
- return t.deleteItem(key, expected)
-}
-
-func (t *Table) AddAttributes(key *Key, attributes []Attribute) (bool, error) {
- return t.modifyAttributes(key, attributes, nil, "ADD")
-}
-
-func (t *Table) UpdateAttributes(key *Key, attributes []Attribute) (bool, error) {
- return t.modifyAttributes(key, attributes, nil, "PUT")
-}
-
-func (t *Table) DeleteAttributes(key *Key, attributes []Attribute) (bool, error) {
- return t.modifyAttributes(key, attributes, nil, "DELETE")
-}
-
-func (t *Table) ConditionalAddAttributes(key *Key, attributes, expected []Attribute) (bool, error) {
- return t.modifyAttributes(key, attributes, expected, "ADD")
-}
-
-func (t *Table) ConditionalUpdateAttributes(key *Key, attributes, expected []Attribute) (bool, error) {
- return t.modifyAttributes(key, attributes, expected, "PUT")
-}
-
-func (t *Table) ConditionalDeleteAttributes(key *Key, attributes, expected []Attribute) (bool, error) {
- return t.modifyAttributes(key, attributes, expected, "DELETE")
-}
-
-func (t *Table) modifyAttributes(key *Key, attributes, expected []Attribute, action string) (bool, error) {
-
- if len(attributes) == 0 {
- return false, errors.New("At least one attribute is required.")
- }
-
- q := NewQuery(t)
- q.AddKey(t, key)
- q.AddUpdates(attributes, action)
-
- if expected != nil {
- q.AddExpected(expected)
- }
-
- jsonResponse, err := t.Server.queryServer(target("UpdateItem"), q)
-
- if err != nil {
- return false, err
- }
-
- _, err = simplejson.NewJson(jsonResponse)
- if err != nil {
- return false, err
- }
-
- return true, nil
-}
-
-func parseAttributes(s map[string]interface{}) map[string]*Attribute {
- results := map[string]*Attribute{}
-
- for key, value := range s {
- if v, ok := value.(map[string]interface{}); ok {
- if val, ok := v[TYPE_STRING].(string); ok {
- results[key] = &Attribute{
- Type: TYPE_STRING,
- Name: key,
- Value: val,
- }
- } else if val, ok := v[TYPE_NUMBER].(string); ok {
- results[key] = &Attribute{
- Type: TYPE_NUMBER,
- Name: key,
- Value: val,
- }
- } else if val, ok := v[TYPE_BINARY].(string); ok {
- results[key] = &Attribute{
- Type: TYPE_BINARY,
- Name: key,
- Value: val,
- }
- } else if vals, ok := v[TYPE_STRING_SET].([]interface{}); ok {
- arry := make([]string, len(vals))
- for i, ivalue := range vals {
- if val, ok := ivalue.(string); ok {
- arry[i] = val
- }
- }
- results[key] = &Attribute{
- Type: TYPE_STRING_SET,
- Name: key,
- SetValues: arry,
- }
- } else if vals, ok := v[TYPE_NUMBER_SET].([]interface{}); ok {
- arry := make([]string, len(vals))
- for i, ivalue := range vals {
- if val, ok := ivalue.(string); ok {
- arry[i] = val
- }
- }
- results[key] = &Attribute{
- Type: TYPE_NUMBER_SET,
- Name: key,
- SetValues: arry,
- }
- } else if vals, ok := v[TYPE_BINARY_SET].([]interface{}); ok {
- arry := make([]string, len(vals))
- for i, ivalue := range vals {
- if val, ok := ivalue.(string); ok {
- arry[i] = val
- }
- }
- results[key] = &Attribute{
- Type: TYPE_BINARY_SET,
- Name: key,
- SetValues: arry,
- }
- }
- } else {
- log.Printf("type assertion to map[string] interface{} failed for : %s\n ", value)
- }
-
- }
-
- return results
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/item_test.go b/vendor/github.com/goamz/goamz/dynamodb/item_test.go
deleted file mode 100644
index 37b4b8838..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/item_test.go
+++ /dev/null
@@ -1,446 +0,0 @@
-package dynamodb_test
-
-import (
- "github.com/goamz/goamz/dynamodb"
- . "gopkg.in/check.v1"
-)
-
-type ItemSuite struct {
- TableDescriptionT dynamodb.TableDescriptionT
- DynamoDBTest
- WithRange bool
-}
-
-func (s *ItemSuite) SetUpSuite(c *C) {
- setUpAuth(c)
- s.DynamoDBTest.TableDescriptionT = s.TableDescriptionT
- s.server = &dynamodb.Server{dynamodb_auth, dynamodb_region}
- pk, err := s.TableDescriptionT.BuildPrimaryKey()
- if err != nil {
- c.Skip(err.Error())
- }
- s.table = s.server.NewTable(s.TableDescriptionT.TableName, pk)
-
- // Cleanup
- s.TearDownSuite(c)
- _, err = s.server.CreateTable(s.TableDescriptionT)
- if err != nil {
- c.Fatal(err)
- }
- s.WaitUntilStatus(c, "ACTIVE")
-}
-
-var item_suite = &ItemSuite{
- TableDescriptionT: dynamodb.TableDescriptionT{
- TableName: "DynamoDBTestMyTable",
- AttributeDefinitions: []dynamodb.AttributeDefinitionT{
- dynamodb.AttributeDefinitionT{"TestHashKey", "S"},
- dynamodb.AttributeDefinitionT{"TestRangeKey", "N"},
- },
- KeySchema: []dynamodb.KeySchemaT{
- dynamodb.KeySchemaT{"TestHashKey", "HASH"},
- dynamodb.KeySchemaT{"TestRangeKey", "RANGE"},
- },
- ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
- ReadCapacityUnits: 1,
- WriteCapacityUnits: 1,
- },
- },
- WithRange: true,
-}
-
-var item_without_range_suite = &ItemSuite{
- TableDescriptionT: dynamodb.TableDescriptionT{
- TableName: "DynamoDBTestMyTable",
- AttributeDefinitions: []dynamodb.AttributeDefinitionT{
- dynamodb.AttributeDefinitionT{"TestHashKey", "S"},
- },
- KeySchema: []dynamodb.KeySchemaT{
- dynamodb.KeySchemaT{"TestHashKey", "HASH"},
- },
- ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
- ReadCapacityUnits: 1,
- WriteCapacityUnits: 1,
- },
- },
- WithRange: false,
-}
-
-var _ = Suite(item_suite)
-var _ = Suite(item_without_range_suite)
-
-func (s *ItemSuite) TestConditionalPutUpdateDeleteItem(c *C) {
- if s.WithRange {
- // No rangekey test required
- return
- }
-
- attrs := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "Attr1Val"),
- }
- pk := &dynamodb.Key{HashKey: "NewHashKeyVal"}
-
- // Put
- if ok, err := s.table.PutItem("NewHashKeyVal", "", attrs); !ok {
- c.Fatal(err)
- }
-
- {
- // Put with condition failed
- expected := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "expectedAttr1Val").SetExists(true),
- *dynamodb.NewStringAttribute("AttrNotExists", "").SetExists(false),
- }
- if ok, err := s.table.ConditionalPutItem("NewHashKeyVal", "", attrs, expected); ok {
- c.Errorf("Expect condition does not meet.")
- } else {
- c.Check(err.Error(), Matches, "ConditionalCheckFailedException.*")
- }
-
- // Add attributes with condition failed
- if ok, err := s.table.ConditionalAddAttributes(pk, attrs, expected); ok {
- c.Errorf("Expect condition does not meet.")
- } else {
- c.Check(err.Error(), Matches, "ConditionalCheckFailedException.*")
- }
-
- // Update attributes with condition failed
- if ok, err := s.table.ConditionalUpdateAttributes(pk, attrs, expected); ok {
- c.Errorf("Expect condition does not meet.")
- } else {
- c.Check(err.Error(), Matches, "ConditionalCheckFailedException.*")
- }
-
- // Delete attributes with condition failed
- if ok, err := s.table.ConditionalDeleteAttributes(pk, attrs, expected); ok {
- c.Errorf("Expect condition does not meet.")
- } else {
- c.Check(err.Error(), Matches, "ConditionalCheckFailedException.*")
- }
- }
-
- {
- expected := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "Attr1Val").SetExists(true),
- }
-
- // Add attributes with condition met
- addNewAttrs := []dynamodb.Attribute{
- *dynamodb.NewNumericAttribute("AddNewAttr1", "10"),
- *dynamodb.NewNumericAttribute("AddNewAttr2", "20"),
- }
- if ok, err := s.table.ConditionalAddAttributes(pk, addNewAttrs, nil); !ok {
- c.Errorf("Expect condition met. %s", err)
- }
-
- // Update attributes with condition met
- updateAttrs := []dynamodb.Attribute{
- *dynamodb.NewNumericAttribute("AddNewAttr1", "100"),
- }
- if ok, err := s.table.ConditionalUpdateAttributes(pk, updateAttrs, expected); !ok {
- c.Errorf("Expect condition met. %s", err)
- }
-
- // Delete attributes with condition met
- deleteAttrs := []dynamodb.Attribute{
- *dynamodb.NewNumericAttribute("AddNewAttr2", ""),
- }
- if ok, err := s.table.ConditionalDeleteAttributes(pk, deleteAttrs, expected); !ok {
- c.Errorf("Expect condition met. %s", err)
- }
-
- // Get to verify operations that condition are met
- item, err := s.table.GetItem(pk)
- if err != nil {
- c.Fatal(err)
- }
-
- if val, ok := item["AddNewAttr1"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewNumericAttribute("AddNewAttr1", "100"))
- } else {
- c.Error("Expect AddNewAttr1 attribute to be added and updated")
- }
-
- if _, ok := item["AddNewAttr2"]; ok {
- c.Error("Expect AddNewAttr2 attribute to be deleted")
- }
- }
-
- {
- // Put with condition met
- expected := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "Attr1Val").SetExists(true),
- }
- newattrs := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "Attr2Val"),
- }
- if ok, err := s.table.ConditionalPutItem("NewHashKeyVal", "", newattrs, expected); !ok {
- c.Errorf("Expect condition met. %s", err)
- }
-
- // Get to verify Put operation that condition are met
- item, err := s.table.GetItem(pk)
- if err != nil {
- c.Fatal(err)
- }
-
- if val, ok := item["Attr1"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewStringAttribute("Attr1", "Attr2Val"))
- } else {
- c.Error("Expect Attr1 attribute to be updated")
- }
- }
-
- {
- // Delete with condition failed
- expected := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "expectedAttr1Val").SetExists(true),
- }
- if ok, err := s.table.ConditionalDeleteItem(pk, expected); ok {
- c.Errorf("Expect condition does not meet.")
- } else {
- c.Check(err.Error(), Matches, "ConditionalCheckFailedException.*")
- }
- }
-
- {
- // Delete with condition met
- expected := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "Attr2Val").SetExists(true),
- }
- if ok, _ := s.table.ConditionalDeleteItem(pk, expected); !ok {
- c.Errorf("Expect condition met.")
- }
-
- // Get to verify Delete operation
- _, err := s.table.GetItem(pk)
- c.Check(err.Error(), Matches, "Item not found")
- }
-}
-
-func (s *ItemSuite) TestPutGetDeleteItem(c *C) {
- attrs := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("Attr1", "Attr1Val"),
- }
-
- var rk string
- if s.WithRange {
- rk = "1"
- }
-
- // Put
- if ok, err := s.table.PutItem("NewHashKeyVal", rk, attrs); !ok {
- c.Fatal(err)
- }
-
- // Get to verify Put operation
- pk := &dynamodb.Key{HashKey: "NewHashKeyVal", RangeKey: rk}
- item, err := s.table.GetItem(pk)
- if err != nil {
- c.Fatal(err)
- }
-
- if val, ok := item["TestHashKey"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewStringAttribute("TestHashKey", "NewHashKeyVal"))
- } else {
- c.Error("Expect TestHashKey to be found")
- }
-
- if s.WithRange {
- if val, ok := item["TestRangeKey"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewNumericAttribute("TestRangeKey", "1"))
- } else {
- c.Error("Expect TestRangeKey to be found")
- }
- }
-
- // Delete
- if ok, _ := s.table.DeleteItem(pk); !ok {
- c.Fatal(err)
- }
-
- // Get to verify Delete operation
- _, err = s.table.GetItem(pk)
- c.Check(err.Error(), Matches, "Item not found")
-}
-
-func (s *ItemSuite) TestUpdateItem(c *C) {
- attrs := []dynamodb.Attribute{
- *dynamodb.NewNumericAttribute("count", "0"),
- }
-
- var rk string
- if s.WithRange {
- rk = "1"
- }
-
- if ok, err := s.table.PutItem("NewHashKeyVal", rk, attrs); !ok {
- c.Fatal(err)
- }
-
- // UpdateItem with Add
- attrs = []dynamodb.Attribute{
- *dynamodb.NewNumericAttribute("count", "10"),
- }
- pk := &dynamodb.Key{HashKey: "NewHashKeyVal", RangeKey: rk}
- if ok, err := s.table.AddAttributes(pk, attrs); !ok {
- c.Error(err)
- }
-
- // Get to verify Add operation
- if item, err := s.table.GetItemConsistent(pk, true); err != nil {
- c.Error(err)
- } else {
- if val, ok := item["count"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewNumericAttribute("count", "10"))
- } else {
- c.Error("Expect count to be found")
- }
- }
-
- // UpdateItem with Put
- attrs = []dynamodb.Attribute{
- *dynamodb.NewNumericAttribute("count", "100"),
- }
- if ok, err := s.table.UpdateAttributes(pk, attrs); !ok {
- c.Error(err)
- }
-
- // Get to verify Put operation
- if item, err := s.table.GetItem(pk); err != nil {
- c.Fatal(err)
- } else {
- if val, ok := item["count"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewNumericAttribute("count", "100"))
- } else {
- c.Error("Expect count to be found")
- }
- }
-
- // UpdateItem with Delete
- attrs = []dynamodb.Attribute{
- *dynamodb.NewNumericAttribute("count", ""),
- }
- if ok, err := s.table.DeleteAttributes(pk, attrs); !ok {
- c.Error(err)
- }
-
- // Get to verify Delete operation
- if item, err := s.table.GetItem(pk); err != nil {
- c.Error(err)
- } else {
- if _, ok := item["count"]; ok {
- c.Error("Expect count not to be found")
- }
- }
-}
-
-func (s *ItemSuite) TestUpdateItemWithSet(c *C) {
- attrs := []dynamodb.Attribute{
- *dynamodb.NewStringSetAttribute("list", []string{"A", "B"}),
- }
-
- var rk string
- if s.WithRange {
- rk = "1"
- }
-
- if ok, err := s.table.PutItem("NewHashKeyVal", rk, attrs); !ok {
- c.Error(err)
- }
-
- // UpdateItem with Add
- attrs = []dynamodb.Attribute{
- *dynamodb.NewStringSetAttribute("list", []string{"C"}),
- }
- pk := &dynamodb.Key{HashKey: "NewHashKeyVal", RangeKey: rk}
- if ok, err := s.table.AddAttributes(pk, attrs); !ok {
- c.Error(err)
- }
-
- // Get to verify Add operation
- if item, err := s.table.GetItem(pk); err != nil {
- c.Error(err)
- } else {
- if val, ok := item["list"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewStringSetAttribute("list", []string{"A", "B", "C"}))
- } else {
- c.Error("Expect count to be found")
- }
- }
-
- // UpdateItem with Delete
- attrs = []dynamodb.Attribute{
- *dynamodb.NewStringSetAttribute("list", []string{"A"}),
- }
- if ok, err := s.table.DeleteAttributes(pk, attrs); !ok {
- c.Error(err)
- }
-
- // Get to verify Delete operation
- if item, err := s.table.GetItem(pk); err != nil {
- c.Error(err)
- } else {
- if val, ok := item["list"]; ok {
- c.Check(val, DeepEquals, dynamodb.NewStringSetAttribute("list", []string{"B", "C"}))
- } else {
- c.Error("Expect list to be remained")
- }
- }
-}
-
-func (s *ItemSuite) TestUpdateItem_new(c *C) {
- attrs := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("intval", "1"),
- }
- var rk string
- if s.WithRange {
- rk = "1"
- }
- pk := &dynamodb.Key{HashKey: "UpdateKeyVal", RangeKey: rk}
-
- num := func(a, b string) dynamodb.Attribute {
- return *dynamodb.NewNumericAttribute(a, b)
- }
-
- checkVal := func(i string) {
- if item, err := s.table.GetItem(pk); err != nil {
- c.Error(err)
- } else {
- c.Check(item["intval"], DeepEquals, dynamodb.NewNumericAttribute("intval", i))
- }
- }
-
- if ok, err := s.table.PutItem("UpdateKeyVal", rk, attrs); !ok {
- c.Error(err)
- }
- checkVal("1")
-
- // Simple Increment
- s.table.UpdateItem(pk).UpdateExpression("SET intval = intval + :incr", num(":incr", "5")).Execute()
- checkVal("6")
-
- conditionalUpdate := func(check string) {
- s.table.UpdateItem(pk).
- ConditionExpression("intval = :check").
- UpdateExpression("SET intval = intval + :incr").
- ExpressionAttributes(num(":check", check), num(":incr", "4")).
- Execute()
- }
- // Conditional increment should be a no-op.
- conditionalUpdate("42")
- checkVal("6")
-
- // conditional increment should succeed this time
- conditionalUpdate("6")
- checkVal("10")
-
- // Update with new values getting values
- result, err := s.table.UpdateItem(pk).
- ReturnValues(dynamodb.UPDATED_NEW).
- UpdateExpression("SET intval = intval + :incr", num(":incr", "2")).
- Execute()
- c.Check(err, IsNil)
- c.Check(result.Attributes["intval"], DeepEquals, num("intval", "12"))
- checkVal("12")
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/marshaller.go b/vendor/github.com/goamz/goamz/dynamodb/marshaller.go
deleted file mode 100644
index 2898fbda9..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/marshaller.go
+++ /dev/null
@@ -1,626 +0,0 @@
-package dynamodb
-
-import (
- "encoding/base64"
- "encoding/json"
- "fmt"
- "math"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "sync"
- "unicode"
-)
-
-func MarshalAttributes(m interface{}) ([]Attribute, error) {
- v := reflect.ValueOf(m).Elem()
-
- builder := &attributeBuilder{}
- builder.buffer = []Attribute{}
- for _, f := range cachedTypeFields(v.Type()) { // loop on each field
- fv := fieldByIndex(v, f.index)
- if !fv.IsValid() || isEmptyValueToOmit(fv) {
- continue
- }
-
- err := builder.reflectToDynamoDBAttribute(f.name, fv)
- if err != nil {
- return builder.buffer, err
- }
- }
-
- return builder.buffer, nil
-}
-
-func UnmarshalAttributes(attributesRef *map[string]*Attribute, m interface{}) error {
- rv := reflect.ValueOf(m)
- if rv.Kind() != reflect.Ptr || rv.IsNil() {
- return fmt.Errorf("InvalidUnmarshalError reflect.ValueOf(v): %#v, m interface{}: %#v", rv, reflect.TypeOf(m))
- }
-
- v := reflect.ValueOf(m).Elem()
-
- attributes := *attributesRef
- for _, f := range cachedTypeFields(v.Type()) { // loop on each field
- fv := fieldByIndex(v, f.index)
- correlatedAttribute := attributes[f.name]
- if correlatedAttribute == nil {
- continue
- }
- err := unmarshallAttribute(correlatedAttribute, fv)
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-type attributeBuilder struct {
- buffer []Attribute
-}
-
-func (builder *attributeBuilder) Push(attribute *Attribute) {
- builder.buffer = append(builder.buffer, *attribute)
-}
-
-func unmarshallAttribute(a *Attribute, v reflect.Value) error {
- switch v.Kind() {
- case reflect.Bool:
- n, err := strconv.ParseInt(a.Value, 10, 64)
- if err != nil {
- return fmt.Errorf("UnmarshalTypeError (bool) %#v: %#v", a.Value, err)
- }
- v.SetBool(n != 0)
-
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- n, err := strconv.ParseInt(a.Value, 10, 64)
- if err != nil || v.OverflowInt(n) {
- return fmt.Errorf("UnmarshalTypeError (number) %#v: %#v", a.Value, err)
- }
- v.SetInt(n)
-
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- n, err := strconv.ParseUint(a.Value, 10, 64)
- if err != nil || v.OverflowUint(n) {
- return fmt.Errorf("UnmarshalTypeError (number) %#v: %#v", a.Value, err)
- }
- v.SetUint(n)
-
- case reflect.Float32, reflect.Float64:
- n, err := strconv.ParseFloat(a.Value, v.Type().Bits())
- if err != nil || v.OverflowFloat(n) {
- return fmt.Errorf("UnmarshalTypeError (number) %#v: %#v", a.Value, err)
- }
- v.SetFloat(n)
-
- case reflect.String:
- v.SetString(a.Value)
-
- case reflect.Slice:
- if v.Type().Elem().Kind() == reflect.Uint8 { // byte arrays are a special case
- b := make([]byte, base64.StdEncoding.DecodedLen(len(a.Value)))
- n, err := base64.StdEncoding.Decode(b, []byte(a.Value))
- if err != nil {
- return fmt.Errorf("UnmarshalTypeError (byte) %#v: %#v", a.Value, err)
- }
- v.Set(reflect.ValueOf(b[0:n]))
- break
- }
-
- if a.SetType() { // Special NS and SS types should be correctly handled
- nativeSetCreated := false
- switch v.Type().Elem().Kind() {
- case reflect.Bool:
- nativeSetCreated = true
- arry := reflect.MakeSlice(v.Type(), len(a.SetValues), len(a.SetValues))
- for i, aval := range a.SetValues {
- n, err := strconv.ParseInt(aval, 10, 64)
- if err != nil {
- return fmt.Errorf("UnmarshalSetTypeError (bool) %#v: %#v", aval, err)
- }
- arry.Index(i).SetBool(n != 0)
- }
- v.Set(arry)
-
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- nativeSetCreated = true
- arry := reflect.MakeSlice(v.Type(), len(a.SetValues), len(a.SetValues))
- for i, aval := range a.SetValues {
- n, err := strconv.ParseInt(aval, 10, 64)
- if err != nil || arry.Index(i).OverflowInt(n) {
- return fmt.Errorf("UnmarshalSetTypeError (number) %#v: %#v", aval, err)
- }
- arry.Index(i).SetInt(n)
- }
- v.Set(arry)
-
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- nativeSetCreated = true
- arry := reflect.MakeSlice(v.Type(), len(a.SetValues), len(a.SetValues))
- for i, aval := range a.SetValues {
- n, err := strconv.ParseUint(aval, 10, 64)
- if err != nil || arry.Index(i).OverflowUint(n) {
- return fmt.Errorf("UnmarshalSetTypeError (number) %#v: %#v", aval, err)
- }
- arry.Index(i).SetUint(n)
- }
- v.Set(arry)
-
- case reflect.Float32, reflect.Float64:
- nativeSetCreated = true
- arry := reflect.MakeSlice(v.Type(), len(a.SetValues), len(a.SetValues))
- for i, aval := range a.SetValues {
- n, err := strconv.ParseFloat(aval, arry.Index(i).Type().Bits())
- if err != nil || arry.Index(i).OverflowFloat(n) {
- return fmt.Errorf("UnmarshalSetTypeError (number) %#v: %#v", aval, err)
- }
- arry.Index(i).SetFloat(n)
- }
- v.Set(arry)
-
- case reflect.String:
- nativeSetCreated = true
- arry := reflect.MakeSlice(v.Type(), len(a.SetValues), len(a.SetValues))
- for i, aval := range a.SetValues {
- arry.Index(i).SetString(aval)
- }
- v.Set(arry)
- }
-
- if nativeSetCreated {
- break
- }
- }
-
- // Slices can be marshalled as nil, but otherwise are handled
- // as arrays.
- fallthrough
- case reflect.Array, reflect.Struct, reflect.Map, reflect.Interface, reflect.Ptr:
- unmarshalled := reflect.New(v.Type())
- err := json.Unmarshal([]byte(a.Value), unmarshalled.Interface())
- if err != nil {
- return err
- }
- v.Set(unmarshalled.Elem())
-
- default:
- return fmt.Errorf("UnsupportedTypeError %#v", v.Type())
- }
-
- return nil
-}
-
-// reflectValueQuoted writes the value in v to the output.
-// If quoted is true, the serialization is wrapped in a JSON string.
-func (e *attributeBuilder) reflectToDynamoDBAttribute(name string, v reflect.Value) error {
- if !v.IsValid() {
- return nil
- } // don't build
-
- switch v.Kind() {
- case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
- rv, err := numericReflectedValueString(v)
- if err != nil {
- return err
- }
- e.Push(NewNumericAttribute(name, rv))
-
- case reflect.String:
- e.Push(NewStringAttribute(name, v.String()))
-
- case reflect.Slice:
- if v.IsNil() {
- break
- }
- if v.Type().Elem().Kind() == reflect.Uint8 {
- // Byte slices are treated as errors
- s := v.Bytes()
- dst := make([]byte, base64.StdEncoding.EncodedLen(len(s)))
- base64.StdEncoding.Encode(dst, s)
- e.Push(NewStringAttribute(name, string(dst)))
- break
- }
-
- // Special NS and SS types should be correctly handled
- nativeSetCreated := false
- switch v.Type().Elem().Kind() {
- case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
- nativeSetCreated = true
- arrystrings := make([]string, v.Len())
- for i, _ := range arrystrings {
- var err error
- arrystrings[i], err = numericReflectedValueString(v.Index(i))
- if err != nil {
- return err
- }
- }
- e.Push(NewNumericSetAttribute(name, arrystrings))
- case reflect.String: // simple copy will suffice
- nativeSetCreated = true
- arrystrings := make([]string, v.Len())
- for i, _ := range arrystrings {
- arrystrings[i] = v.Index(i).String()
- }
- e.Push(NewStringSetAttribute(name, arrystrings))
- }
-
- if nativeSetCreated {
- break
- }
-
- // Slices can be marshalled as nil, but otherwise are handled
- // as arrays.
- fallthrough
- case reflect.Array, reflect.Struct, reflect.Map, reflect.Interface, reflect.Ptr:
- jsonVersion, err := json.Marshal(v.Interface())
- if err != nil {
- return err
- }
- escapedJson := `"` + string(jsonVersion) + `"` // strconv.Quote not required because the entire string is escaped from json Marshall
- e.Push(NewStringAttribute(name, escapedJson[1:len(escapedJson)-1]))
-
- default:
- return fmt.Errorf("UnsupportedTypeError %#v", v.Type())
- }
- return nil
-}
-
-func numericReflectedValueString(v reflect.Value) (string, error) {
- switch v.Kind() {
- case reflect.Bool:
- x := v.Bool()
- if x {
- return "1", nil
- } else {
- return "0", nil
- }
-
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return strconv.FormatInt(v.Int(), 10), nil
-
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return strconv.FormatUint(v.Uint(), 10), nil
-
- case reflect.Float32, reflect.Float64:
- f := v.Float()
- if math.IsInf(f, 0) || math.IsNaN(f) {
- return "", fmt.Errorf("UnsupportedValueError %#v (formatted float: %s)", v, strconv.FormatFloat(f, 'g', -1, v.Type().Bits()))
- }
- return strconv.FormatFloat(f, 'g', -1, v.Type().Bits()), nil
- }
- return "", fmt.Errorf("UnsupportedNumericValueError %#v", v.Type())
-}
-
-// In DynamoDB we should omit empty value in some type
-// See http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
-func isEmptyValueToOmit(v reflect.Value) bool {
- switch v.Kind() {
- case reflect.Array, reflect.Map, reflect.Slice, reflect.String, reflect.Interface, reflect.Ptr:
- // should omit if empty value
- return isEmptyValue(v)
- }
- // otherwise should not omit
- return false
-}
-
-// ---------------- Below are copied handy functions from http://golang.org/src/pkg/encoding/json/encode.go --------------------------------
-func isEmptyValue(v reflect.Value) bool {
- switch v.Kind() {
- case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
- return v.Len() == 0
- case reflect.Bool:
- return !v.Bool()
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return v.Int() == 0
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return v.Uint() == 0
- case reflect.Float32, reflect.Float64:
- return v.Float() == 0
- case reflect.Interface, reflect.Ptr:
- return v.IsNil()
- }
- return false
-}
-
-func fieldByIndex(v reflect.Value, index []int) reflect.Value {
- for _, i := range index {
- if v.Kind() == reflect.Ptr {
- if v.IsNil() {
- return reflect.Value{}
- }
- v = v.Elem()
- }
- v = v.Field(i)
- }
- return v
-}
-
-// A field represents a single field found in a struct.
-type field struct {
- name string
- tag bool
- index []int
- typ reflect.Type
- omitEmpty bool
- quoted bool
-}
-
-// byName sorts field by name, breaking ties with depth,
-// then breaking ties with "name came from json tag", then
-// breaking ties with index sequence.
-type byName []field
-
-func (x byName) Len() int { return len(x) }
-
-func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-
-func (x byName) Less(i, j int) bool {
- if x[i].name != x[j].name {
- return x[i].name < x[j].name
- }
- if len(x[i].index) != len(x[j].index) {
- return len(x[i].index) < len(x[j].index)
- }
- if x[i].tag != x[j].tag {
- return x[i].tag
- }
- return byIndex(x).Less(i, j)
-}
-
-// byIndex sorts field by index sequence.
-type byIndex []field
-
-func (x byIndex) Len() int { return len(x) }
-
-func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-
-func (x byIndex) Less(i, j int) bool {
- for k, xik := range x[i].index {
- if k >= len(x[j].index) {
- return false
- }
- if xik != x[j].index[k] {
- return xik < x[j].index[k]
- }
- }
- return len(x[i].index) < len(x[j].index)
-}
-
-func isValidTag(s string) bool {
- if s == "" {
- return false
- }
- for _, c := range s {
- switch {
- case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c):
- // Backslash and quote chars are reserved, but
- // otherwise any punctuation chars are allowed
- // in a tag name.
- default:
- if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
- return false
- }
- }
- }
- return true
-}
-
-// tagOptions is the string following a comma in a struct field's "json"
-// tag, or the empty string. It does not include the leading comma.
-type tagOptions string
-
-// Contains returns whether checks that a comma-separated list of options
-// contains a particular substr flag. substr must be surrounded by a
-// string boundary or commas.
-func (o tagOptions) Contains(optionName string) bool {
- if len(o) == 0 {
- return false
- }
- s := string(o)
- for s != "" {
- var next string
- i := strings.Index(s, ",")
- if i >= 0 {
- s, next = s[:i], s[i+1:]
- }
- if s == optionName {
- return true
- }
- s = next
- }
- return false
-}
-
-// parseTag splits a struct field's json tag into its name and
-// comma-separated options.
-func parseTag(tag string) (string, tagOptions) {
- if idx := strings.Index(tag, ","); idx != -1 {
- return tag[:idx], tagOptions(tag[idx+1:])
- }
- return tag, tagOptions("")
-}
-
-// typeFields returns a list of fields that JSON should recognize for the given type.
-// The algorithm is breadth-first search over the set of structs to include - the top struct
-// and then any reachable anonymous structs.
-func typeFields(t reflect.Type) []field {
- // Anonymous fields to explore at the current level and the next.
- current := []field{}
- next := []field{{typ: t}}
-
- // Count of queued names for current level and the next.
- count := map[reflect.Type]int{}
- nextCount := map[reflect.Type]int{}
-
- // Types already visited at an earlier level.
- visited := map[reflect.Type]bool{}
-
- // Fields found.
- var fields []field
-
- for len(next) > 0 {
- current, next = next, current[:0]
- count, nextCount = nextCount, map[reflect.Type]int{}
-
- for _, f := range current {
- if visited[f.typ] {
- continue
- }
- visited[f.typ] = true
-
- // Scan f.typ for fields to include.
- for i := 0; i < f.typ.NumField(); i++ {
- sf := f.typ.Field(i)
- if sf.PkgPath != "" { // unexported
- continue
- }
- tag := sf.Tag.Get("json")
- if tag == "-" {
- continue
- }
- name, opts := parseTag(tag)
- if !isValidTag(name) {
- name = ""
- }
- index := make([]int, len(f.index)+1)
- copy(index, f.index)
- index[len(f.index)] = i
-
- ft := sf.Type
- if ft.Name() == "" && ft.Kind() == reflect.Ptr {
- // Follow pointer.
- ft = ft.Elem()
- }
-
- // Record found field and index sequence.
- if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct {
- tagged := name != ""
- if name == "" {
- name = sf.Name
- }
- fields = append(fields, field{name, tagged, index, ft,
- opts.Contains("omitempty"), opts.Contains("string")})
- if count[f.typ] > 1 {
- // If there were multiple instances, add a second,
- // so that the annihilation code will see a duplicate.
- // It only cares about the distinction between 1 or 2,
- // so don't bother generating any more copies.
- fields = append(fields, fields[len(fields)-1])
- }
- continue
- }
-
- // Record new anonymous struct to explore in next round.
- nextCount[ft]++
- if nextCount[ft] == 1 {
- next = append(next, field{name: ft.Name(), index: index, typ: ft})
- }
- }
- }
- }
-
- sort.Sort(byName(fields))
-
- // Delete all fields that are hidden by the Go rules for embedded fields,
- // except that fields with JSON tags are promoted.
-
- // The fields are sorted in primary order of name, secondary order
- // of field index length. Loop over names; for each name, delete
- // hidden fields by choosing the one dominant field that survives.
- out := fields[:0]
- for advance, i := 0, 0; i < len(fields); i += advance {
- // One iteration per name.
- // Find the sequence of fields with the name of this first field.
- fi := fields[i]
- name := fi.name
- for advance = 1; i+advance < len(fields); advance++ {
- fj := fields[i+advance]
- if fj.name != name {
- break
- }
- }
- if advance == 1 { // Only one field with this name
- out = append(out, fi)
- continue
- }
- dominant, ok := dominantField(fields[i : i+advance])
- if ok {
- out = append(out, dominant)
- }
- }
-
- fields = out
- sort.Sort(byIndex(fields))
-
- return fields
-}
-
-// dominantField looks through the fields, all of which are known to
-// have the same name, to find the single field that dominates the
-// others using Go's embedding rules, modified by the presence of
-// JSON tags. If there are multiple top-level fields, the boolean
-// will be false: This condition is an error in Go and we skip all
-// the fields.
-func dominantField(fields []field) (field, bool) {
- // The fields are sorted in increasing index-length order. The winner
- // must therefore be one with the shortest index length. Drop all
- // longer entries, which is easy: just truncate the slice.
- length := len(fields[0].index)
- tagged := -1 // Index of first tagged field.
- for i, f := range fields {
- if len(f.index) > length {
- fields = fields[:i]
- break
- }
- if f.tag {
- if tagged >= 0 {
- // Multiple tagged fields at the same level: conflict.
- // Return no field.
- return field{}, false
- }
- tagged = i
- }
- }
- if tagged >= 0 {
- return fields[tagged], true
- }
- // All remaining fields have the same length. If there's more than one,
- // we have a conflict (two fields named "X" at the same level) and we
- // return no field.
- if len(fields) > 1 {
- return field{}, false
- }
- return fields[0], true
-}
-
-var fieldCache struct {
- sync.RWMutex
- m map[reflect.Type][]field
-}
-
-// cachedTypeFields is like typeFields but uses a cache to avoid repeated work.
-func cachedTypeFields(t reflect.Type) []field {
- fieldCache.RLock()
- f := fieldCache.m[t]
- fieldCache.RUnlock()
- if f != nil {
- return f
- }
-
- // Compute fields without lock.
- // Might duplicate effort but won't hold other computations back.
- f = typeFields(t)
- if f == nil {
- f = []field{}
- }
-
- fieldCache.Lock()
- if fieldCache.m == nil {
- fieldCache.m = map[reflect.Type][]field{}
- }
- fieldCache.m[t] = f
- fieldCache.Unlock()
- return f
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/marshaller_test.go b/vendor/github.com/goamz/goamz/dynamodb/marshaller_test.go
deleted file mode 100644
index 8b9d2fc08..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/marshaller_test.go
+++ /dev/null
@@ -1,283 +0,0 @@
-package dynamodb_test
-
-import (
- "time"
-
- "github.com/goamz/goamz/dynamodb"
- . "gopkg.in/check.v1"
-)
-
-type TestSubStruct struct {
- SubBool bool
- SubInt int
- SubString string
- SubStringArray []string
-}
-
-type TestStruct struct {
- TestBool bool
- TestInt int
- TestInt32 int32
- TestInt64 int64
- TestUint uint
- TestFloat32 float32
- TestFloat64 float64
- TestString string
- TestByteArray []byte
- TestStringArray []string
- TestIntArray []int
- TestInt8Array []int8
- TestFloatArray []float64
- TestSub TestSubStruct
-}
-
-type TestStructTime struct {
- TestTime time.Time
-}
-
-func testObject() *TestStruct {
- return &TestStruct{
- TestBool: true,
- TestInt: -99,
- TestInt32: 999,
- TestInt64: 9999,
- TestUint: 99,
- TestFloat32: 9.9999,
- TestFloat64: 99.999999,
- TestString: "test",
- TestByteArray: []byte("bytes"),
- TestStringArray: []string{"test1", "test2", "test3", "test4"},
- TestIntArray: []int{0, 1, 12, 123, 1234, 12345},
- TestInt8Array: []int8{0, 1, 12, 123},
- TestFloatArray: []float64{0.1, 1.1, 1.2, 1.23, 1.234, 1.2345},
- TestSub: TestSubStruct{
- SubBool: true,
- SubInt: 2,
- SubString: "subtest",
- SubStringArray: []string{"sub1", "sub2", "sub3"},
- },
- }
-}
-
-func testObjectTime() *TestStructTime {
- t, _ := time.Parse("Jan 2, 2006 at 3:04pm", "Mar 3, 2003 at 5:03pm")
- return &TestStructTime{
- TestTime: t,
- }
-}
-
-func testObjectWithZeroValues() *TestStruct {
- return &TestStruct{}
-}
-
-func testObjectWithNilSets() *TestStruct {
- return &TestStruct{
- TestBool: true,
- TestInt: -99,
- TestInt32: 999,
- TestInt64: 9999,
- TestUint: 99,
- TestFloat32: 9.9999,
- TestFloat64: 99.999999,
- TestString: "test",
- TestByteArray: []byte("bytes"),
- TestStringArray: []string(nil),
- TestIntArray: []int(nil),
- TestFloatArray: []float64(nil),
- TestSub: TestSubStruct{
- SubBool: true,
- SubInt: 2,
- SubString: "subtest",
- SubStringArray: []string{"sub1", "sub2", "sub3"},
- },
- }
-}
-func testObjectWithEmptySets() *TestStruct {
- return &TestStruct{
- TestBool: true,
- TestInt: -99,
- TestInt32: 999,
- TestInt64: 9999,
- TestUint: 99,
- TestFloat32: 9.9999,
- TestFloat64: 99.999999,
- TestString: "test",
- TestByteArray: []byte("bytes"),
- TestStringArray: []string{},
- TestIntArray: []int{},
- TestFloatArray: []float64{},
- TestSub: TestSubStruct{
- SubBool: true,
- SubInt: 2,
- SubString: "subtest",
- SubStringArray: []string{"sub1", "sub2", "sub3"},
- },
- }
-}
-
-func testAttrs() []dynamodb.Attribute {
- return []dynamodb.Attribute{
- dynamodb.Attribute{Type: "N", Name: "TestBool", Value: "1", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt", Value: "-99", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt32", Value: "999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt64", Value: "9999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestUint", Value: "99", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestFloat32", Value: "9.9999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestFloat64", Value: "99.999999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "S", Name: "TestString", Value: "test", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "S", Name: "TestByteArray", Value: "Ynl0ZXM=", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "SS", Name: "TestStringArray", Value: "", SetValues: []string{"test1", "test2", "test3", "test4"}},
- dynamodb.Attribute{Type: "NS", Name: "TestIntArray", Value: "", SetValues: []string{"0", "1", "12", "123", "1234", "12345"}},
- dynamodb.Attribute{Type: "NS", Name: "TestInt8Array", Value: "", SetValues: []string{"0", "1", "12", "123"}},
- dynamodb.Attribute{Type: "NS", Name: "TestFloatArray", Value: "", SetValues: []string{"0.1", "1.1", "1.2", "1.23", "1.234", "1.2345"}},
- dynamodb.Attribute{Type: "S", Name: "TestSub", Value: `{"SubBool":true,"SubInt":2,"SubString":"subtest","SubStringArray":["sub1","sub2","sub3"]}`, SetValues: []string(nil)},
- }
-}
-
-func testAttrsTime() []dynamodb.Attribute {
- return []dynamodb.Attribute{
- dynamodb.Attribute{Type: "S", Name: "TestTime", Value: "\"2003-03-03T17:03:00Z\"", SetValues: []string(nil)},
- }
-}
-
-func testAttrsWithZeroValues() []dynamodb.Attribute {
- return []dynamodb.Attribute{
- dynamodb.Attribute{Type: "N", Name: "TestBool", Value: "0", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt", Value: "0", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt32", Value: "0", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt64", Value: "0", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestUint", Value: "0", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestFloat32", Value: "0", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestFloat64", Value: "0", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "S", Name: "TestSub", Value: `{"SubBool":false,"SubInt":0,"SubString":"","SubStringArray":null}`, SetValues: []string(nil)},
- }
-}
-
-func testAttrsWithNilSets() []dynamodb.Attribute {
- return []dynamodb.Attribute{
- dynamodb.Attribute{Type: "N", Name: "TestBool", Value: "1", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt", Value: "-99", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt32", Value: "999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestInt64", Value: "9999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestUint", Value: "99", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestFloat32", Value: "9.9999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "N", Name: "TestFloat64", Value: "99.999999", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "S", Name: "TestString", Value: "test", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "S", Name: "TestByteArray", Value: "Ynl0ZXM=", SetValues: []string(nil)},
- dynamodb.Attribute{Type: "S", Name: "TestSub", Value: `{"SubBool":true,"SubInt":2,"SubString":"subtest","SubStringArray":["sub1","sub2","sub3"]}`, SetValues: []string(nil)},
- }
-}
-
-type MarshallerSuite struct {
-}
-
-var _ = Suite(&MarshallerSuite{})
-
-func (s *MarshallerSuite) TestMarshal(c *C) {
- testObj := testObject()
- attrs, err := dynamodb.MarshalAttributes(testObj)
- if err != nil {
- c.Errorf("Error from dynamodb.MarshalAttributes: %#v", err)
- }
-
- expected := testAttrs()
- c.Check(attrs, DeepEquals, expected)
-}
-
-func (s *MarshallerSuite) TestUnmarshal(c *C) {
- testObj := &TestStruct{}
-
- attrMap := map[string]*dynamodb.Attribute{}
- attrs := testAttrs()
- for i, _ := range attrs {
- attrMap[attrs[i].Name] = &attrs[i]
- }
-
- err := dynamodb.UnmarshalAttributes(&attrMap, testObj)
- if err != nil {
- c.Fatalf("Error from dynamodb.UnmarshalAttributes: %#v (Built: %#v)", err, testObj)
- }
-
- expected := testObject()
- c.Check(testObj, DeepEquals, expected)
-}
-
-func (s *MarshallerSuite) TestMarshalTime(c *C) {
- testObj := testObjectTime()
- attrs, err := dynamodb.MarshalAttributes(testObj)
- if err != nil {
- c.Errorf("Error from dynamodb.MarshalAttributes: %#v", err)
- }
-
- expected := testAttrsTime()
- c.Check(attrs, DeepEquals, expected)
-}
-
-func (s *MarshallerSuite) TestUnmarshalTime(c *C) {
- testObj := &TestStructTime{}
-
- attrMap := map[string]*dynamodb.Attribute{}
- attrs := testAttrsTime()
- for i, _ := range attrs {
- attrMap[attrs[i].Name] = &attrs[i]
- }
-
- err := dynamodb.UnmarshalAttributes(&attrMap, testObj)
- if err != nil {
- c.Fatalf("Error from dynamodb.UnmarshalAttributes: %#v (Built: %#v)", err, testObj)
- }
-
- expected := testObjectTime()
- c.Check(testObj, DeepEquals, expected)
-}
-
-func (s *MarshallerSuite) TestMarshalNilSets(c *C) {
- testObj := testObjectWithNilSets()
- attrs, err := dynamodb.MarshalAttributes(testObj)
- if err != nil {
- c.Errorf("Error from dynamodb.MarshalAttributes: %#v", err)
- }
-
- expected := testAttrsWithNilSets()
- c.Check(attrs, DeepEquals, expected)
-}
-
-func (s *MarshallerSuite) TestMarshalZeroValues(c *C) {
- testObj := testObjectWithZeroValues()
- attrs, err := dynamodb.MarshalAttributes(testObj)
- if err != nil {
- c.Errorf("Error from dynamodb.MarshalAttributes: %#v", err)
- }
-
- expected := testAttrsWithZeroValues()
- c.Check(attrs, DeepEquals, expected)
-}
-
-func (s *MarshallerSuite) TestMarshalEmptySets(c *C) {
- testObj := testObjectWithEmptySets()
- attrs, err := dynamodb.MarshalAttributes(testObj)
- if err != nil {
- c.Errorf("Error from dynamodb.MarshalAttributes: %#v", err)
- }
-
- expected := testAttrsWithNilSets()
- c.Check(attrs, DeepEquals, expected)
-}
-
-func (s *MarshallerSuite) TestUnmarshalEmptySets(c *C) {
- testObj := &TestStruct{}
-
- attrMap := map[string]*dynamodb.Attribute{}
- attrs := testAttrsWithNilSets()
- for i, _ := range attrs {
- attrMap[attrs[i].Name] = &attrs[i]
- }
-
- err := dynamodb.UnmarshalAttributes(&attrMap, testObj)
- if err != nil {
- c.Fatalf("Error from dynamodb.UnmarshalAttributes: %#v (Built: %#v)", err, testObj)
- }
-
- expected := testObjectWithNilSets()
- c.Check(testObj, DeepEquals, expected)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/query.go b/vendor/github.com/goamz/goamz/dynamodb/query.go
deleted file mode 100644
index 453e38733..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/query.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package dynamodb
-
-import (
- "errors"
- "fmt"
- simplejson "github.com/bitly/go-simplejson"
-)
-
-func (t *Table) Query(attributeComparisons []AttributeComparison) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- return runQuery(q, t)
-}
-
-func (t *Table) QueryOnIndex(attributeComparisons []AttributeComparison, indexName string) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- q.AddIndex(indexName)
- return runQuery(q, t)
-}
-
-func (t *Table) QueryOnIndexDescending(attributeComparisons []AttributeComparison, indexName string) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- q.AddIndex(indexName)
- q.ScanIndexDescending()
- return runQuery(q, t)
-}
-
-func (t *Table) LimitedQuery(attributeComparisons []AttributeComparison, limit int64) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- q.AddLimit(limit)
- return runQuery(q, t)
-}
-
-func (t *Table) LimitedQueryOnIndex(attributeComparisons []AttributeComparison, indexName string, limit int64) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- q.AddIndex(indexName)
- q.AddLimit(limit)
- return runQuery(q, t)
-}
-
-func (t *Table) LimitedQueryDescending(attributeComparisons []AttributeComparison, limit int64) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- q.AddLimit(limit)
- q.ScanIndexDescending()
- return runQuery(q, t)
-}
-
-func (t *Table) LimitedQueryOnIndexDescending(attributeComparisons []AttributeComparison, indexName string, limit int64) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- q.AddIndex(indexName)
- q.AddLimit(limit)
- q.ScanIndexDescending()
- return runQuery(q, t)
-}
-
-func (t *Table) CountQuery(attributeComparisons []AttributeComparison) (int64, error) {
- q := NewQuery(t)
- q.AddKeyConditions(attributeComparisons)
- q.AddSelect("COUNT")
- jsonResponse, err := t.Server.queryServer("DynamoDB_20120810.Query", q)
- if err != nil {
- return 0, err
- }
- json, err := simplejson.NewJson(jsonResponse)
- if err != nil {
- return 0, err
- }
-
- itemCount, err := json.Get("Count").Int64()
- if err != nil {
- return 0, err
- }
-
- return itemCount, nil
-}
-
-func runQuery(q *Query, t *Table) ([]map[string]*Attribute, error) {
- jsonResponse, err := t.Server.queryServer("DynamoDB_20120810.Query", q)
- if err != nil {
- return nil, err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
- if err != nil {
- return nil, err
- }
-
- itemCount, err := json.Get("Count").Int()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- results := make([]map[string]*Attribute, itemCount)
-
- for i, _ := range results {
- item, err := json.Get("Items").GetIndex(i).Map()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
- results[i] = parseAttributes(item)
- }
- return results, nil
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/query_builder.go b/vendor/github.com/goamz/goamz/dynamodb/query_builder.go
deleted file mode 100644
index 47a90bb1c..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/query_builder.go
+++ /dev/null
@@ -1,362 +0,0 @@
-package dynamodb
-
-import (
- "encoding/json"
- "sort"
-)
-
-type msi map[string]interface{}
-type Query struct {
- buffer msi
-}
-
-func NewEmptyQuery() *Query {
- return &Query{msi{}}
-}
-
-func NewQuery(t *Table) *Query {
- q := &Query{msi{}}
- q.addTable(t)
- return q
-}
-
-// This way of specifing the key is used when doing a Get.
-// If rangeKey is "", it is assumed to not want to be used
-func (q *Query) AddKey(t *Table, key *Key) {
- k := t.Key
- keymap := msi{
- k.KeyAttribute.Name: msi{
- k.KeyAttribute.Type: key.HashKey},
- }
- if k.HasRange() {
- keymap[k.RangeAttribute.Name] = msi{k.RangeAttribute.Type: key.RangeKey}
- }
-
- q.buffer["Key"] = keymap
-}
-
-func keyAttributes(t *Table, key *Key) msi {
- k := t.Key
-
- out := msi{}
- out[k.KeyAttribute.Name] = msi{k.KeyAttribute.Type: key.HashKey}
- if k.HasRange() {
- out[k.RangeAttribute.Name] = msi{k.RangeAttribute.Type: key.RangeKey}
- }
- return out
-}
-
-func (q *Query) AddAttributesToGet(attributes []string) {
- if len(attributes) == 0 {
- return
- }
-
- q.buffer["AttributesToGet"] = attributes
-}
-
-func (q *Query) ConsistentRead(c bool) {
- if c == true {
- q.buffer["ConsistentRead"] = "true" //String "true", not bool true
- }
-}
-
-func (q *Query) AddGetRequestItems(tableKeys map[*Table][]Key) {
- requestitems := msi{}
- for table, keys := range tableKeys {
- keyslist := []msi{}
- for _, key := range keys {
- keyslist = append(keyslist, keyAttributes(table, &key))
- }
- requestitems[table.Name] = msi{"Keys": keyslist}
- }
- q.buffer["RequestItems"] = requestitems
-}
-
-func (q *Query) AddWriteRequestItems(tableItems map[*Table]map[string][][]Attribute) {
- b := q.buffer
-
- b["RequestItems"] = func() msi {
- out := msi{}
- for table, itemActions := range tableItems {
- out[table.Name] = func() interface{} {
- out2 := []interface{}{}
-
- // here breaks an order of array....
- // For now, we iterate over sorted key by action for stable testing
- keys := []string{}
- for k := range itemActions {
- keys = append(keys, k)
- }
- sort.Strings(keys)
-
- for ki := range keys {
- action := keys[ki]
- items := itemActions[action]
- for _, attributes := range items {
- Item_or_Key := map[bool]string{true: "Item", false: "Key"}[action == "Put"]
- out2 = append(out2, msi{action + "Request": msi{Item_or_Key: attributeList(attributes)}})
- }
- }
- return out2
- }()
- }
- return out
- }()
-}
-
-func (q *Query) AddCreateRequestTable(description TableDescriptionT) {
- b := q.buffer
-
- attDefs := []interface{}{}
- for _, attr := range description.AttributeDefinitions {
- attDefs = append(attDefs, msi{
- "AttributeName": attr.Name,
- "AttributeType": attr.Type,
- })
- }
- b["AttributeDefinitions"] = attDefs
- b["KeySchema"] = description.KeySchema
- b["TableName"] = description.TableName
- b["ProvisionedThroughput"] = msi{
- "ReadCapacityUnits": int(description.ProvisionedThroughput.ReadCapacityUnits),
- "WriteCapacityUnits": int(description.ProvisionedThroughput.WriteCapacityUnits),
- }
-
- if description.StreamSpecification.StreamEnabled {
- b["StreamSpecification"] = msi{
- "StreamEnabled": "true",
- "StreamViewType": description.StreamSpecification.StreamViewType,
- }
- }
-
- localSecondaryIndexes := []interface{}{}
-
- for _, ind := range description.LocalSecondaryIndexes {
- localSecondaryIndexes = append(localSecondaryIndexes, msi{
- "IndexName": ind.IndexName,
- "KeySchema": ind.KeySchema,
- "Projection": ind.Projection,
- })
- }
-
- globalSecondaryIndexes := []interface{}{}
- intmax := func(x, y int64) int64 {
- if x > y {
- return x
- }
- return y
- }
- for _, ind := range description.GlobalSecondaryIndexes {
- rec := msi{
- "IndexName": ind.IndexName,
- "KeySchema": ind.KeySchema,
- "Projection": ind.Projection,
- }
- // need at least one unit, and since go's max() is float based.
- rec["ProvisionedThroughput"] = msi{
- "ReadCapacityUnits": intmax(1, ind.ProvisionedThroughput.ReadCapacityUnits),
- "WriteCapacityUnits": intmax(1, ind.ProvisionedThroughput.WriteCapacityUnits),
- }
- globalSecondaryIndexes = append(globalSecondaryIndexes, rec)
- }
-
- if len(localSecondaryIndexes) > 0 {
- b["LocalSecondaryIndexes"] = localSecondaryIndexes
- }
-
- if len(globalSecondaryIndexes) > 0 {
- b["GlobalSecondaryIndexes"] = globalSecondaryIndexes
- }
-}
-
-func (q *Query) AddDeleteRequestTable(description TableDescriptionT) {
- b := q.buffer
- b["TableName"] = description.TableName
-}
-
-func (q *Query) AddUpdateRequestTable(description TableDescriptionT) {
- b := q.buffer
-
- attDefs := []interface{}{}
- for _, attr := range description.AttributeDefinitions {
- attDefs = append(attDefs, msi{
- "AttributeName": attr.Name,
- "AttributeType": attr.Type,
- })
- }
- if len(attDefs) > 0 {
- b["AttributeDefinitions"] = attDefs
- }
- b["TableName"] = description.TableName
- b["ProvisionedThroughput"] = msi{
- "ReadCapacityUnits": int(description.ProvisionedThroughput.ReadCapacityUnits),
- "WriteCapacityUnits": int(description.ProvisionedThroughput.WriteCapacityUnits),
- }
-
-}
-
-func (q *Query) AddKeyConditions(comparisons []AttributeComparison) {
- q.buffer["KeyConditions"] = buildComparisons(comparisons)
-}
-
-func (q *Query) AddLimit(limit int64) {
- q.buffer["Limit"] = limit
-}
-func (q *Query) AddSelect(value string) {
- q.buffer["Select"] = value
-}
-
-func (q *Query) AddIndex(value string) {
- q.buffer["IndexName"] = value
-}
-
-func (q *Query) ScanIndexDescending() {
- q.buffer["ScanIndexForward"] = "false"
-}
-
-/*
- "ScanFilter":{
- "AttributeName1":{"AttributeValueList":[{"S":"AttributeValue"}],"ComparisonOperator":"EQ"}
- },
-*/
-func (q *Query) AddScanFilter(comparisons []AttributeComparison) {
- q.buffer["ScanFilter"] = buildComparisons(comparisons)
-}
-
-func (q *Query) AddParallelScanConfiguration(segment int, totalSegments int) {
- q.buffer["Segment"] = segment
- q.buffer["TotalSegments"] = totalSegments
-}
-
-func buildComparisons(comparisons []AttributeComparison) msi {
- out := msi{}
-
- for _, c := range comparisons {
- avlist := []interface{}{}
- for _, attributeValue := range c.AttributeValueList {
- avlist = append(avlist, msi{attributeValue.Type: attributeValue.Value})
- }
- out[c.AttributeName] = msi{
- "AttributeValueList": avlist,
- "ComparisonOperator": c.ComparisonOperator,
- }
- }
-
- return out
-}
-
-// The primary key must be included in attributes.
-func (q *Query) AddItem(attributes []Attribute) {
- q.buffer["Item"] = attributeList(attributes)
-}
-
-func (q *Query) AddUpdates(attributes []Attribute, action string) {
- updates := msi{}
- for _, a := range attributes {
- au := msi{
- "Value": msi{
- a.Type: map[bool]interface{}{true: a.SetValues, false: a.Value}[a.SetType()],
- },
- "Action": action,
- }
- // Delete 'Value' from AttributeUpdates if Type is not Set
- if action == "DELETE" && !a.SetType() {
- delete(au, "Value")
- }
- updates[a.Name] = au
- }
-
- q.buffer["AttributeUpdates"] = updates
-}
-
-func (q *Query) AddExpected(attributes []Attribute) {
- expected := msi{}
- for _, a := range attributes {
- value := msi{}
- if a.Exists != "" {
- value["Exists"] = a.Exists
- }
- // If set Exists to false, we must remove Value
- if value["Exists"] != "false" {
- value["Value"] = msi{a.Type: map[bool]interface{}{true: a.SetValues, false: a.Value}[a.SetType()]}
- }
- expected[a.Name] = value
- }
- q.buffer["Expected"] = expected
-}
-
-// Add the ReturnValues parameter, used in UpdateItem queries.
-func (q *Query) AddReturnValues(returnValues ReturnValues) {
- q.buffer["ReturnValues"] = string(returnValues)
-}
-
-// Add the UpdateExpression parameter, used in UpdateItem queries.
-func (q *Query) AddUpdateExpression(expression string) {
- q.buffer["UpdateExpression"] = expression
-}
-
-// Add the ConditionExpression parameter, used in UpdateItem queries.
-func (q *Query) AddConditionExpression(expression string) {
- q.buffer["ConditionExpression"] = expression
-}
-
-func (q *Query) AddExpressionAttributes(attributes []Attribute) {
- existing, ok := q.buffer["ExpressionAttributes"].(msi)
- if !ok {
- existing = msi{}
- q.buffer["ExpressionAttributes"] = existing
- }
- for key, val := range attributeList(attributes) {
- existing[key] = val
- }
-}
-
-func (q *Query) AddExclusiveStartStreamArn(arn string) {
- q.buffer["ExclusiveStartStreamArn"] = arn
-}
-
-func (q *Query) AddStreamArn(arn string) {
- q.buffer["StreamArn"] = arn
-}
-
-func (q *Query) AddExclusiveStartShardId(shardId string) {
- q.buffer["ExclusiveStartShardId"] = shardId
-}
-
-func (q *Query) AddShardId(shardId string) {
- q.buffer["ShardId"] = shardId
-}
-
-func (q *Query) AddShardIteratorType(shardIteratorType string) {
- q.buffer["ShardIteratorType"] = shardIteratorType
-}
-
-func (q *Query) AddSequenceNumber(sequenceNumber string) {
- q.buffer["SequenceNumber"] = sequenceNumber
-}
-
-func (q *Query) AddShardIterator(shardIterator string) {
- q.buffer["ShardIterator"] = shardIterator
-}
-
-func attributeList(attributes []Attribute) msi {
- b := msi{}
- for _, a := range attributes {
- //UGH!! (I miss the query operator)
- b[a.Name] = msi{a.Type: map[bool]interface{}{true: a.SetValues, false: a.Value}[a.SetType()]}
- }
- return b
-}
-
-func (q *Query) addTable(t *Table) {
- q.addTableByName(t.Name)
-}
-
-func (q *Query) addTableByName(tableName string) {
- q.buffer["TableName"] = tableName
-}
-
-func (q *Query) String() string {
- bytes, _ := json.Marshal(q.buffer)
- return string(bytes)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/query_builder_test.go b/vendor/github.com/goamz/goamz/dynamodb/query_builder_test.go
deleted file mode 100755
index 9a1f6f2c5..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/query_builder_test.go
+++ /dev/null
@@ -1,380 +0,0 @@
-package dynamodb_test
-
-import (
- simplejson "github.com/bitly/go-simplejson"
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/dynamodb"
- . "gopkg.in/check.v1"
-)
-
-type QueryBuilderSuite struct {
- server *dynamodb.Server
-}
-
-var _ = Suite(&QueryBuilderSuite{})
-
-func (s *QueryBuilderSuite) SetUpSuite(c *C) {
- auth := &aws.Auth{AccessKey: "", SecretKey: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"}
- s.server = &dynamodb.Server{*auth, aws.USEast}
-}
-
-func (s *QueryBuilderSuite) TestEmptyQuery(c *C) {
- q := dynamodb.NewEmptyQuery()
- queryString := q.String()
- expectedString := "{}"
- c.Check(queryString, Equals, expectedString)
-
- if expectedString != queryString {
- c.Fatalf("Unexpected Query String : %s\n", queryString)
- }
-}
-
-func (s *QueryBuilderSuite) TestAddWriteRequestItems(c *C) {
- primary := dynamodb.NewStringAttribute("WidgetFoo", "")
- secondary := dynamodb.NewNumericAttribute("Created", "")
- key := dynamodb.PrimaryKey{primary, secondary}
- table := s.server.NewTable("FooData", key)
-
- primary2 := dynamodb.NewStringAttribute("TestHashKey", "")
- secondary2 := dynamodb.NewNumericAttribute("TestRangeKey", "")
- key2 := dynamodb.PrimaryKey{primary2, secondary2}
- table2 := s.server.NewTable("TestTable", key2)
-
- q := dynamodb.NewEmptyQuery()
-
- attribute1 := dynamodb.NewNumericAttribute("testing", "4")
- attribute2 := dynamodb.NewNumericAttribute("testingbatch", "2111")
- attribute3 := dynamodb.NewStringAttribute("testingstrbatch", "mystr")
- item1 := []dynamodb.Attribute{*attribute1, *attribute2, *attribute3}
-
- attribute4 := dynamodb.NewNumericAttribute("testing", "444")
- attribute5 := dynamodb.NewNumericAttribute("testingbatch", "93748249272")
- attribute6 := dynamodb.NewStringAttribute("testingstrbatch", "myotherstr")
- item2 := []dynamodb.Attribute{*attribute4, *attribute5, *attribute6}
-
- attributeDel1 := dynamodb.NewStringAttribute("TestHashKeyDel", "DelKey")
- attributeDel2 := dynamodb.NewNumericAttribute("TestRangeKeyDel", "7777777")
- itemDel := []dynamodb.Attribute{*attributeDel1, *attributeDel2}
-
- attributeTest1 := dynamodb.NewStringAttribute("TestHashKey", "MyKey")
- attributeTest2 := dynamodb.NewNumericAttribute("TestRangeKey", "0193820384293")
- itemTest := []dynamodb.Attribute{*attributeTest1, *attributeTest2}
-
- tableItems := map[*dynamodb.Table]map[string][][]dynamodb.Attribute{}
- actionItems := make(map[string][][]dynamodb.Attribute)
- actionItems["Put"] = [][]dynamodb.Attribute{item1, item2}
- actionItems["Delete"] = [][]dynamodb.Attribute{itemDel}
- tableItems[table] = actionItems
-
- actionItems2 := make(map[string][][]dynamodb.Attribute)
- actionItems2["Put"] = [][]dynamodb.Attribute{itemTest}
- tableItems[table2] = actionItems2
-
- q.AddWriteRequestItems(tableItems)
-
- queryJson, err := simplejson.NewJson([]byte(q.String()))
- if err != nil {
- c.Fatal(err)
- }
-
- expectedJson, err := simplejson.NewJson([]byte(`
-{
- "RequestItems": {
- "TestTable": [
- {
- "PutRequest": {
- "Item": {
- "TestRangeKey": {
- "N": "0193820384293"
- },
- "TestHashKey": {
- "S": "MyKey"
- }
- }
- }
- }
- ],
- "FooData": [
- {
- "DeleteRequest": {
- "Key": {
- "TestRangeKeyDel": {
- "N": "7777777"
- },
- "TestHashKeyDel": {
- "S": "DelKey"
- }
- }
- }
- },
- {
- "PutRequest": {
- "Item": {
- "testingstrbatch": {
- "S": "mystr"
- },
- "testingbatch": {
- "N": "2111"
- },
- "testing": {
- "N": "4"
- }
- }
- }
- },
- {
- "PutRequest": {
- "Item": {
- "testingstrbatch": {
- "S": "myotherstr"
- },
- "testingbatch": {
- "N": "93748249272"
- },
- "testing": {
- "N": "444"
- }
- }
- }
- }
- ]
- }
-}
- `))
- if err != nil {
- c.Fatal(err)
- }
- c.Check(queryJson, DeepEquals, expectedJson)
-}
-
-func (s *QueryBuilderSuite) TestAddExpectedQuery(c *C) {
- primary := dynamodb.NewStringAttribute("domain", "")
- key := dynamodb.PrimaryKey{primary, nil}
- table := s.server.NewTable("sites", key)
-
- q := dynamodb.NewQuery(table)
- q.AddKey(table, &dynamodb.Key{HashKey: "test"})
-
- expected := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("domain", "expectedTest").SetExists(true),
- *dynamodb.NewStringAttribute("testKey", "").SetExists(false),
- }
- q.AddExpected(expected)
-
- queryJson, err := simplejson.NewJson([]byte(q.String()))
- if err != nil {
- c.Fatal(err)
- }
-
- expectedJson, err := simplejson.NewJson([]byte(`
- {
- "Expected": {
- "domain": {
- "Exists": "true",
- "Value": {
- "S": "expectedTest"
- }
- },
- "testKey": {
- "Exists": "false"
- }
- },
- "Key": {
- "domain": {
- "S": "test"
- }
- },
- "TableName": "sites"
- }
- `))
- if err != nil {
- c.Fatal(err)
- }
- c.Check(queryJson, DeepEquals, expectedJson)
-}
-
-func (s *QueryBuilderSuite) TestGetItemQuery(c *C) {
- primary := dynamodb.NewStringAttribute("domain", "")
- key := dynamodb.PrimaryKey{primary, nil}
- table := s.server.NewTable("sites", key)
-
- q := dynamodb.NewQuery(table)
- q.AddKey(table, &dynamodb.Key{HashKey: "test"})
-
- {
- queryJson, err := simplejson.NewJson([]byte(q.String()))
- if err != nil {
- c.Fatal(err)
- }
-
- expectedJson, err := simplejson.NewJson([]byte(`
- {
- "Key": {
- "domain": {
- "S": "test"
- }
- },
- "TableName": "sites"
- }
- `))
- if err != nil {
- c.Fatal(err)
- }
- c.Check(queryJson, DeepEquals, expectedJson)
- }
-
- // Use ConsistentRead
- {
- q.ConsistentRead(true)
- queryJson, err := simplejson.NewJson([]byte(q.String()))
- if err != nil {
- c.Fatal(err)
- }
-
- expectedJson, err := simplejson.NewJson([]byte(`
- {
- "ConsistentRead": "true",
- "Key": {
- "domain": {
- "S": "test"
- }
- },
- "TableName": "sites"
- }
- `))
- if err != nil {
- c.Fatal(err)
- }
- c.Check(queryJson, DeepEquals, expectedJson)
- }
-}
-
-func (s *QueryBuilderSuite) TestUpdateQuery(c *C) {
- primary := dynamodb.NewStringAttribute("domain", "")
- rangek := dynamodb.NewNumericAttribute("time", "")
- key := dynamodb.PrimaryKey{primary, rangek}
- table := s.server.NewTable("sites", key)
-
- countAttribute := dynamodb.NewNumericAttribute("count", "4")
- attributes := []dynamodb.Attribute{*countAttribute}
-
- q := dynamodb.NewQuery(table)
- q.AddKey(table, &dynamodb.Key{HashKey: "test", RangeKey: "1234"})
- q.AddUpdates(attributes, "ADD")
-
- queryJson, err := simplejson.NewJson([]byte(q.String()))
- if err != nil {
- c.Fatal(err)
- }
- expectedJson, err := simplejson.NewJson([]byte(`
-{
- "AttributeUpdates": {
- "count": {
- "Action": "ADD",
- "Value": {
- "N": "4"
- }
- }
- },
- "Key": {
- "domain": {
- "S": "test"
- },
- "time": {
- "N": "1234"
- }
- },
- "TableName": "sites"
-}
- `))
- if err != nil {
- c.Fatal(err)
- }
- c.Check(queryJson, DeepEquals, expectedJson)
-}
-
-func (s *QueryBuilderSuite) TestAddUpdates(c *C) {
- primary := dynamodb.NewStringAttribute("domain", "")
- key := dynamodb.PrimaryKey{primary, nil}
- table := s.server.NewTable("sites", key)
-
- q := dynamodb.NewQuery(table)
- q.AddKey(table, &dynamodb.Key{HashKey: "test"})
-
- attr := dynamodb.NewStringSetAttribute("StringSet", []string{"str", "str2"})
-
- q.AddUpdates([]dynamodb.Attribute{*attr}, "ADD")
-
- queryJson, err := simplejson.NewJson([]byte(q.String()))
- if err != nil {
- c.Fatal(err)
- }
- expectedJson, err := simplejson.NewJson([]byte(`
-{
- "AttributeUpdates": {
- "StringSet": {
- "Action": "ADD",
- "Value": {
- "SS": ["str", "str2"]
- }
- }
- },
- "Key": {
- "domain": {
- "S": "test"
- }
- },
- "TableName": "sites"
-}
- `))
- if err != nil {
- c.Fatal(err)
- }
- c.Check(queryJson, DeepEquals, expectedJson)
-}
-
-func (s *QueryBuilderSuite) TestAddKeyConditions(c *C) {
- primary := dynamodb.NewStringAttribute("domain", "")
- key := dynamodb.PrimaryKey{primary, nil}
- table := s.server.NewTable("sites", key)
-
- q := dynamodb.NewQuery(table)
- acs := []dynamodb.AttributeComparison{
- *dynamodb.NewStringAttributeComparison("domain", "EQ", "example.com"),
- *dynamodb.NewStringAttributeComparison("path", "EQ", "/"),
- }
- q.AddKeyConditions(acs)
- queryJson, err := simplejson.NewJson([]byte(q.String()))
-
- if err != nil {
- c.Fatal(err)
- }
-
- expectedJson, err := simplejson.NewJson([]byte(`
-{
- "KeyConditions": {
- "domain": {
- "AttributeValueList": [
- {
- "S": "example.com"
- }
- ],
- "ComparisonOperator": "EQ"
- },
- "path": {
- "AttributeValueList": [
- {
- "S": "/"
- }
- ],
- "ComparisonOperator": "EQ"
- }
- },
- "TableName": "sites"
-}
- `))
- if err != nil {
- c.Fatal(err)
- }
- c.Check(queryJson, DeepEquals, expectedJson)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/scan.go b/vendor/github.com/goamz/goamz/dynamodb/scan.go
deleted file mode 100644
index e8ed62363..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/scan.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package dynamodb
-
-import (
- "errors"
- "fmt"
- simplejson "github.com/bitly/go-simplejson"
-)
-
-func (t *Table) FetchResults(query *Query) ([]map[string]*Attribute, error) {
- jsonResponse, err := t.Server.queryServer(target("Scan"), query)
- if err != nil {
- return nil, err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
- if err != nil {
- return nil, err
- }
-
- itemCount, err := json.Get("Count").Int()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- results := make([]map[string]*Attribute, itemCount)
-
- for i, _ := range results {
- item, err := json.Get("Items").GetIndex(i).Map()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
- results[i] = parseAttributes(item)
- }
- return results, nil
-
-}
-
-func (t *Table) Scan(attributeComparisons []AttributeComparison) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddScanFilter(attributeComparisons)
- return t.FetchResults(q)
-}
-
-func (t *Table) ParallelScan(attributeComparisons []AttributeComparison, segment int, totalSegments int) ([]map[string]*Attribute, error) {
- q := NewQuery(t)
- q.AddScanFilter(attributeComparisons)
- q.AddParallelScanConfiguration(segment, totalSegments)
- return t.FetchResults(q)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/stream.go b/vendor/github.com/goamz/goamz/dynamodb/stream.go
deleted file mode 100644
index 57f3a145f..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/stream.go
+++ /dev/null
@@ -1,307 +0,0 @@
-package dynamodb
-
-import (
- "encoding/json"
- "errors"
- "fmt"
- "reflect"
-
- simplejson "github.com/bitly/go-simplejson"
-)
-
-type Stream struct {
- Server *Server
- Arn string
-}
-
-type StreamListItemT struct {
- StreamArn string
- StreamLabel string
- TableName string
-}
-
-type SequenceNumberRangeT struct {
- EndingSequenceNumber string
- StartingSequenceNumber string
-}
-
-type ShardT struct {
- ParentShardId string
- SequenceNumberRange SequenceNumberRangeT
- ShardId string
-}
-
-type StreamDescriptionT struct {
- CreationDateTime float64
- KeySchema []KeySchemaT
- LastEvaluatedShardId string
- Shards []ShardT
- StreamArn string
- StreamLabel string
- StreamStatus string
- StreamViewType string
- TableName string
-}
-
-type RecordT struct {
- AwsRegion string
- EventID string
- EventName string
- EventSource string
- EventVersion string
- StreamRecord *StreamRecordT
-}
-
-type StreamRecordT struct {
- Keys map[string]*Attribute
- NewImage map[string]*Attribute
- OldImage map[string]*Attribute
- SequenceNumber string
- StreamViewType string
- SizeBytes int64
-}
-
-type listStreamsResponse struct {
- Streams []StreamListItemT
-}
-
-type describeStreamResponse struct {
- StreamDescription StreamDescriptionT
-}
-
-var ErrNoRecords = errors.New("No records")
-
-func (s *Server) ListStreams(startArn string) ([]StreamListItemT, error) {
- return s.LimitedListTableStreams("", startArn, 0)
-}
-
-func (s *Server) LimitedListStreams(startArn string, limit int64) ([]StreamListItemT, error) {
- return s.LimitedListTableStreams("", startArn, limit)
-}
-
-func (s *Server) ListTableStreams(table, startArn string) ([]StreamListItemT, error) {
- return s.LimitedListTableStreams(table, startArn, 0)
-}
-
-func (s *Server) LimitedListTableStreams(table, startArn string, limit int64) ([]StreamListItemT, error) {
- query := NewEmptyQuery()
-
- if len(table) != 0 {
- query.addTableByName(table)
- }
-
- if len(startArn) != 0 {
- query.AddExclusiveStartStreamArn(startArn)
- }
-
- if limit > 0 {
- query.AddLimit(limit)
- }
-
- jsonResponse, err := s.queryServer(streamsTarget("ListStreams"), query)
- if err != nil {
- return nil, err
- }
-
- var r listStreamsResponse
- err = json.Unmarshal(jsonResponse, &r)
- if err != nil {
- return nil, err
- }
-
- return r.Streams, nil
-}
-
-func (s *Server) DescribeStream(arn, startShardId string) (*StreamDescriptionT, error) {
- return s.LimitedDescribeStream(arn, startShardId, 0)
-}
-
-func (s *Server) LimitedDescribeStream(arn, startShardId string, limit int64) (*StreamDescriptionT, error) {
- query := NewEmptyQuery()
- query.AddStreamArn(arn)
-
- if len(startShardId) != 0 {
- query.AddExclusiveStartShardId(startShardId)
- }
-
- if limit > 0 {
- query.AddLimit(limit)
- }
-
- jsonResponse, err := s.queryServer(streamsTarget("DescribeStream"), query)
- if err != nil {
- return nil, err
- }
-
- var r describeStreamResponse
- err = json.Unmarshal(jsonResponse, &r)
- if err != nil {
- return nil, err
- }
-
- return &r.StreamDescription, nil
-}
-
-func (s *Server) NewStream(streamArn string) *Stream {
- return &Stream{s, streamArn}
-}
-
-func (s *Stream) DescribeStream(startShardId string) (*StreamDescriptionT, error) {
- return s.Server.DescribeStream(s.Arn, startShardId)
-}
-
-func (s *Stream) LimitedDescribeStream(startShardId string, limit int64) (*StreamDescriptionT, error) {
- return s.Server.LimitedDescribeStream(s.Arn, startShardId, limit)
-}
-
-func (s *Server) GetShardIterator(streamArn, shardId, shardIteratorType, sequenceNumber string) (string, error) {
- query := NewEmptyQuery()
- query.AddStreamArn(streamArn)
- query.AddShardId(shardId)
- query.AddShardIteratorType(shardIteratorType)
-
- if len(sequenceNumber) != 0 {
- query.AddSequenceNumber(sequenceNumber)
- }
-
- jsonResponse, err := s.queryServer(streamsTarget("GetShardIterator"), query)
-
- if err != nil {
- return "unknown", err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
-
- if err != nil {
- return "unknown", err
- }
-
- return json.Get("ShardIterator").MustString(), nil
-}
-
-func (s *Stream) GetShardIterator(shardId, shardIteratorType, sequenceNumber string) (string, error) {
- return s.Server.GetShardIterator(s.Arn, shardId, shardIteratorType, sequenceNumber)
-}
-
-func (s *Server) GetRecords(shardIterator string) (string, []*RecordT, error) {
- return s.LimitedGetRecords(shardIterator, 0)
-}
-
-func (s *Server) LimitedGetRecords(shardIterator string, limit int64) (string, []*RecordT, error) {
- query := NewEmptyQuery()
- query.AddShardIterator(shardIterator)
-
- if limit > 0 {
- query.AddLimit(limit)
- }
-
- jsonResponse, err := s.queryServer(streamsTarget("GetRecords"), query)
- if err != nil {
- return "", nil, err
- }
-
- jsonParsed, err := simplejson.NewJson(jsonResponse)
- if err != nil {
- return "", nil, err
- }
-
- nextShardIt := ""
- nextShardItJson, ok := jsonParsed.CheckGet("NextShardIterator")
- if ok {
- nextShardIt, err = nextShardItJson.String()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return "", nil, errors.New(message)
- }
- }
-
- recordsJson, ok := jsonParsed.CheckGet("Records")
- if !ok {
- return nextShardIt, nil, ErrNoRecords
- }
-
- recordsArray, err := recordsJson.Array()
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nextShardIt, nil, errors.New(message)
- }
-
- var records []*RecordT
- for _, record := range recordsArray {
- if recordMap, ok := record.(map[string]interface{}); ok {
- r := parseRecord(recordMap)
- records = append(records, r)
- }
- }
-
- return nextShardIt, records, nil
-}
-
-func (s *Stream) GetRecords(shardIterator string) (string, []*RecordT, error) {
- return s.Server.GetRecords(shardIterator)
-}
-
-func (s *Stream) LimitedGetRecords(shardIterator string, limit int64) (string, []*RecordT, error) {
- return s.Server.LimitedGetRecords(shardIterator, limit)
-}
-
-func parseRecord(r map[string]interface{}) *RecordT {
- record := RecordT{}
- rValue := reflect.ValueOf(&record)
-
- keys := []string{"awsRegion", "eventID", "eventName", "eventSource", "eventVersion"}
- for i, key := range keys {
- if value, ok := r[key]; ok {
- if valueStr, ok := value.(string); ok {
- rValue.Elem().Field(i).SetString(valueStr)
- }
- }
- }
-
- if streamRecord, ok := r["dynamodb"]; ok {
- if streamRecordMap, ok := streamRecord.(map[string]interface{}); ok {
- record.StreamRecord = parseStreamRecord(streamRecordMap)
- }
- }
-
- return &record
-}
-
-func parseStreamRecord(s map[string]interface{}) *StreamRecordT {
- sr := StreamRecordT{}
- rValue := reflect.ValueOf(&sr)
-
- attrKeys := []string{"Keys", "NewImage", "OldImage"}
- numAttrKeys := len(attrKeys)
- for i, key := range attrKeys {
- if value, ok := s[key]; ok {
- if valueMap, ok := value.(map[string]interface{}); ok {
- attrs := parseAttributes(valueMap)
- rValue.Elem().Field(i).Set(reflect.ValueOf(attrs))
- }
- }
- }
-
- strKeys := []string{"SequenceNumber", "StreamViewType"}
- numStrKeys := len(strKeys)
- for i, key := range strKeys {
- if value, ok := s[key]; ok {
- if valueStr, ok := value.(string); ok {
- rValue.Elem().Field(i + numAttrKeys).SetString(valueStr)
- }
- }
- }
-
- intKeys := []string{"SizeBytes"}
- for i, key := range intKeys {
- if value, ok := s[key]; ok {
- if valueNumber, ok := value.(json.Number); ok {
- if valueInt, err := valueNumber.Int64(); err == nil {
- rValue.Elem().Field(i + numAttrKeys + numStrKeys).SetInt(valueInt)
- }
- }
- }
- }
-
- return &sr
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/stream_test.go b/vendor/github.com/goamz/goamz/dynamodb/stream_test.go
deleted file mode 100755
index a982ffa65..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/stream_test.go
+++ /dev/null
@@ -1,198 +0,0 @@
-package dynamodb_test
-
-import (
- "strconv"
-
- "github.com/goamz/goamz/dynamodb"
- . "gopkg.in/check.v1"
-)
-
-type StreamSuite struct {
- TableDescriptionT dynamodb.TableDescriptionT
- DynamoDBTest
-}
-
-func (s *StreamSuite) SetUpSuite(c *C) {
- setUpAuth(c)
- s.DynamoDBTest.TableDescriptionT = s.TableDescriptionT
- s.server = &dynamodb.Server{dynamodb_auth, dynamodb_region}
- pk, err := s.TableDescriptionT.BuildPrimaryKey()
- if err != nil {
- c.Skip(err.Error())
- }
- s.table = s.server.NewTable(s.TableDescriptionT.TableName, pk)
-
- // Cleanup
- s.TearDownSuite(c)
- _, err = s.server.CreateTable(s.TableDescriptionT)
- if err != nil {
- c.Fatal(err)
- }
- s.WaitUntilStatus(c, "ACTIVE")
-}
-
-var stream_suite_keys_only = &StreamSuite{
- TableDescriptionT: dynamodb.TableDescriptionT{
- TableName: "StreamTable",
- AttributeDefinitions: []dynamodb.AttributeDefinitionT{
- dynamodb.AttributeDefinitionT{"TestHashKey", "S"},
- dynamodb.AttributeDefinitionT{"TestRangeKey", "N"},
- },
- KeySchema: []dynamodb.KeySchemaT{
- dynamodb.KeySchemaT{"TestHashKey", "HASH"},
- dynamodb.KeySchemaT{"TestRangeKey", "RANGE"},
- },
- ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
- ReadCapacityUnits: 1,
- WriteCapacityUnits: 1,
- },
- StreamSpecification: dynamodb.StreamSpecificationT{
- StreamEnabled: true,
- StreamViewType: "KEYS_ONLY",
- },
- },
-}
-
-var stream_suite_new_image = &StreamSuite{
- TableDescriptionT: dynamodb.TableDescriptionT{
- TableName: "StreamTable",
- AttributeDefinitions: []dynamodb.AttributeDefinitionT{
- dynamodb.AttributeDefinitionT{"TestHashKey", "S"},
- dynamodb.AttributeDefinitionT{"TestRangeKey", "N"},
- },
- KeySchema: []dynamodb.KeySchemaT{
- dynamodb.KeySchemaT{"TestHashKey", "HASH"},
- dynamodb.KeySchemaT{"TestRangeKey", "RANGE"},
- },
- ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
- ReadCapacityUnits: 1,
- WriteCapacityUnits: 1,
- },
- StreamSpecification: dynamodb.StreamSpecificationT{
- StreamEnabled: true,
- StreamViewType: "NEW_IMAGE",
- },
- },
-}
-
-var _ = Suite(stream_suite_keys_only)
-var _ = Suite(stream_suite_new_image)
-
-func (s *StreamSuite) TestStream(c *C) {
- checkStream(s.table, c)
-}
-
-func checkStream(table *dynamodb.Table, c *C) {
- // list the table's streams
- streams, err := table.ListStreams("")
- if err != nil {
- c.Fatal(err)
- }
- c.Check(len(streams), Not(Equals), 0)
- c.Check(streams[0].TableName, Equals, table.Name)
-
- // stick a couple of items in the table
- attrs := []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("TestAttr", "0"),
- }
- if ok, err := table.PutItem("0", "0", attrs); !ok {
- c.Fatal(err)
- }
- attrs = []dynamodb.Attribute{
- *dynamodb.NewStringAttribute("TestAttr", "1"),
- }
- if ok, err := table.PutItem("1", "1", attrs); !ok {
- c.Fatal(err)
- }
-
- // create a stream object
- stream := table.Server.NewStream(streams[0].StreamArn)
-
- // describe the steam
- desc, err := stream.DescribeStream("")
- if err != nil {
- c.Fatal(err)
- }
-
- tableDesc, err := table.DescribeTable()
- if err != nil {
- c.Fatal(err)
- }
-
- c.Check(desc.KeySchema[0], Equals, tableDesc.KeySchema[0])
- c.Check(desc.StreamArn, Equals, streams[0].StreamArn)
- c.Check(desc.StreamStatus, Equals, "ENABLED")
- c.Check(desc.StreamViewType, Equals, tableDesc.StreamSpecification.StreamViewType)
- c.Check(desc.TableName, Equals, table.Name)
- c.Check(len(desc.Shards), Equals, 1)
-
- // get a shard iterator
- shardIt, err := stream.GetShardIterator(desc.Shards[0].ShardId, "TRIM_HORIZON", "")
- if err != nil {
- c.Fatal(err)
- }
- c.Check(len(shardIt), Not(Equals), 0)
-
- // poll for records
- nextIt, records, err := stream.GetRecords(shardIt)
- if err != nil {
- c.Fatal(err)
- }
- c.Check(len(nextIt), Not(Equals), 0)
- c.Check(len(records), Equals, 2)
-
- for index, record := range records {
- c.Check(record.EventSource, Equals, "aws:dynamodb")
- c.Check(record.EventName, Equals, "INSERT")
- c.Check(len(record.EventID), Not(Equals), 0)
-
- // look at the actual record
- streamRec := record.StreamRecord
- c.Check(streamRec.StreamViewType, Equals, desc.StreamViewType)
- c.Check(len(streamRec.SequenceNumber), Not(Equals), 0)
- if streamRec.SizeBytes <= 0 {
- c.Errorf("Expected greater-than-zero size, got: %d", streamRec.SizeBytes)
- }
- // check the keys
- if streamRec.StreamViewType == "KEYS_ONLY" {
- checkKeys(streamRec.Keys, index, c)
- }
- // check the image
- if streamRec.StreamViewType == "NEW_IMAGE" {
- checkNewImage(streamRec.NewImage, index, c)
- }
- }
-}
-
-func checkKeys(keys map[string]*dynamodb.Attribute, expect int, c *C) {
- c.Check(len(keys), Equals, 2)
- value, err := strconv.Atoi(keys["TestHashKey"].Value)
- if err != nil {
- c.Fatal(err)
- }
- c.Check(value, Equals, expect)
- value, err = strconv.Atoi(keys["TestRangeKey"].Value)
- if err != nil {
- c.Fatal(err)
- }
- c.Check(value, Equals, expect)
-}
-
-func checkNewImage(image map[string]*dynamodb.Attribute, expect int, c *C) {
- c.Check(len(image), Equals, 3)
- value, err := strconv.Atoi(image["TestHashKey"].Value)
- if err != nil {
- c.Fatal(err)
- }
- c.Check(value, Equals, expect)
- value, err = strconv.Atoi(image["TestRangeKey"].Value)
- if err != nil {
- c.Fatal(err)
- }
- c.Check(value, Equals, expect)
- value, err = strconv.Atoi(image["TestAttr"].Value)
- if err != nil {
- c.Fatal(err)
- }
- c.Check(value, Equals, expect)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/table.go b/vendor/github.com/goamz/goamz/dynamodb/table.go
deleted file mode 100755
index 541433c13..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/table.go
+++ /dev/null
@@ -1,259 +0,0 @@
-package dynamodb
-
-import (
- "encoding/json"
- "errors"
- "fmt"
- simplejson "github.com/bitly/go-simplejson"
-)
-
-type Table struct {
- Server *Server
- Name string
- Key PrimaryKey
-}
-
-type AttributeDefinitionT struct {
- Name string `json:"AttributeName"`
- Type string `json:"AttributeType"`
-}
-
-type KeySchemaT struct {
- AttributeName string
- KeyType string
-}
-
-type ProjectionT struct {
- ProjectionType string
-}
-
-type GlobalSecondaryIndexT struct {
- IndexName string
- IndexSizeBytes int64
- ItemCount int64
- KeySchema []KeySchemaT
- Projection ProjectionT
- ProvisionedThroughput ProvisionedThroughputT
-}
-
-type LocalSecondaryIndexT struct {
- IndexName string
- IndexSizeBytes int64
- ItemCount int64
- KeySchema []KeySchemaT
- Projection ProjectionT
-}
-
-type ProvisionedThroughputT struct {
- NumberOfDecreasesToday int64
- ReadCapacityUnits int64
- WriteCapacityUnits int64
-}
-
-type StreamSpecificationT struct {
- StreamEnabled bool
- StreamViewType string
-}
-
-type TableDescriptionT struct {
- AttributeDefinitions []AttributeDefinitionT
- CreationDateTime float64
- ItemCount int64
- KeySchema []KeySchemaT
- GlobalSecondaryIndexes []GlobalSecondaryIndexT
- LocalSecondaryIndexes []LocalSecondaryIndexT
- ProvisionedThroughput ProvisionedThroughputT
- StreamSpecification StreamSpecificationT
- TableName string
- TableSizeBytes int64
- TableStatus string
- LatestStreamArn string
- LatestStreamLabel string
-}
-
-type describeTableResponse struct {
- Table TableDescriptionT
-}
-
-func findAttributeDefinitionByName(ads []AttributeDefinitionT, name string) *AttributeDefinitionT {
- for _, a := range ads {
- if a.Name == name {
- return &a
- }
- }
- return nil
-}
-
-func (a *AttributeDefinitionT) GetEmptyAttribute() *Attribute {
- switch a.Type {
- case "S":
- return NewStringAttribute(a.Name, "")
- case "N":
- return NewNumericAttribute(a.Name, "")
- case "B":
- return NewBinaryAttribute(a.Name, "")
- default:
- return nil
- }
-}
-
-func (t *TableDescriptionT) BuildPrimaryKey() (pk PrimaryKey, err error) {
- for _, k := range t.KeySchema {
- var attr *Attribute
- ad := findAttributeDefinitionByName(t.AttributeDefinitions, k.AttributeName)
- if ad == nil {
- return pk, errors.New("An inconsistency found in TableDescriptionT")
- }
- attr = ad.GetEmptyAttribute()
- if attr == nil {
- return pk, errors.New("An inconsistency found in TableDescriptionT")
- }
-
- switch k.KeyType {
- case "HASH":
- pk.KeyAttribute = attr
- case "RANGE":
- pk.RangeAttribute = attr
- }
- }
- return
-}
-
-func (s *Server) NewTable(name string, key PrimaryKey) *Table {
- return &Table{s, name, key}
-}
-
-func (s *Server) ListTables() ([]string, error) {
- var tables []string
-
- query := NewEmptyQuery()
-
- jsonResponse, err := s.queryServer(target("ListTables"), query)
-
- if err != nil {
- return nil, err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
-
- if err != nil {
- return nil, err
- }
-
- response, err := json.Get("TableNames").Array()
-
- if err != nil {
- message := fmt.Sprintf("Unexpected response %s", jsonResponse)
- return nil, errors.New(message)
- }
-
- for _, value := range response {
- if t, ok := (value).(string); ok {
- tables = append(tables, t)
- }
- }
-
- return tables, nil
-}
-
-func (s *Server) CreateTable(tableDescription TableDescriptionT) (string, error) {
- query := NewEmptyQuery()
- query.AddCreateRequestTable(tableDescription)
-
- jsonResponse, err := s.queryServer(target("CreateTable"), query)
-
- if err != nil {
- return "unknown", err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
-
- if err != nil {
- return "unknown", err
- }
-
- return json.Get("TableDescription").Get("TableStatus").MustString(), nil
-}
-
-func (s *Server) DeleteTable(tableDescription TableDescriptionT) (string, error) {
- query := NewEmptyQuery()
- query.AddDeleteRequestTable(tableDescription)
-
- jsonResponse, err := s.queryServer(target("DeleteTable"), query)
-
- if err != nil {
- return "unknown", err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
-
- if err != nil {
- return "unknown", err
- }
-
- return json.Get("TableDescription").Get("TableStatus").MustString(), nil
-}
-
-func (t *Table) DescribeTable() (*TableDescriptionT, error) {
- return t.Server.DescribeTable(t.Name)
-}
-
-func (s *Server) DescribeTable(name string) (*TableDescriptionT, error) {
- q := NewEmptyQuery()
- q.addTableByName(name)
-
- jsonResponse, err := s.queryServer(target("DescribeTable"), q)
- if err != nil {
- return nil, err
- }
-
- var r describeTableResponse
- err = json.Unmarshal(jsonResponse, &r)
- if err != nil {
- return nil, err
- }
-
- return &r.Table, nil
-}
-
-func (s *Server) UpdateTable(tableDescription TableDescriptionT) (string, error) {
- query := NewEmptyQuery()
- query.AddUpdateRequestTable(tableDescription)
-
- jsonResponse, err := s.queryServer(target("UpdateTable"), query)
-
- if err != nil {
- return "unknown", err
- }
-
- json, err := simplejson.NewJson(jsonResponse)
-
- if err != nil {
- return "unknown", err
- }
-
- return json.Get("TableDescription").Get("TableStatus").MustString(), nil
-}
-
-func (t *Table) ListStreams(startArn string) ([]StreamListItemT, error) {
- return t.Server.ListTableStreams(t.Name, startArn)
-}
-
-func (t *Table) LimitedListStreams(startArn string, limit int64) ([]StreamListItemT, error) {
- return t.Server.LimitedListTableStreams(t.Name, startArn, limit)
-}
-
-func keyParam(k *PrimaryKey, hashKey string, rangeKey string) string {
- value := fmt.Sprintf("{\"HashKeyElement\":{%s}", keyValue(k.KeyAttribute.Type, hashKey))
-
- if k.RangeAttribute != nil {
- value = fmt.Sprintf("%s,\"RangeKeyElement\":{%s}", value,
- keyValue(k.RangeAttribute.Type, rangeKey))
- }
-
- return fmt.Sprintf("\"Key\":%s}", value)
-}
-
-func keyValue(key string, value string) string {
- return fmt.Sprintf("\"%s\":\"%s\"", key, value)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/table_test.go b/vendor/github.com/goamz/goamz/dynamodb/table_test.go
deleted file mode 100755
index 8925bdc1b..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/table_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package dynamodb_test
-
-import (
- "github.com/goamz/goamz/dynamodb"
- . "gopkg.in/check.v1"
-)
-
-type TableSuite struct {
- TableDescriptionT dynamodb.TableDescriptionT
- DynamoDBTest
-}
-
-func (s *TableSuite) SetUpSuite(c *C) {
- setUpAuth(c)
- s.DynamoDBTest.TableDescriptionT = s.TableDescriptionT
- s.server = &dynamodb.Server{dynamodb_auth, dynamodb_region}
- pk, err := s.TableDescriptionT.BuildPrimaryKey()
- if err != nil {
- c.Skip(err.Error())
- }
- s.table = s.server.NewTable(s.TableDescriptionT.TableName, pk)
-
- // Cleanup
- s.TearDownSuite(c)
-}
-
-var table_suite = &TableSuite{
- TableDescriptionT: dynamodb.TableDescriptionT{
- TableName: "DynamoDBTestMyTable",
- AttributeDefinitions: []dynamodb.AttributeDefinitionT{
- dynamodb.AttributeDefinitionT{"TestHashKey", "S"},
- dynamodb.AttributeDefinitionT{"TestRangeKey", "N"},
- dynamodb.AttributeDefinitionT{"TestSecKey", "N"},
- },
- KeySchema: []dynamodb.KeySchemaT{
- dynamodb.KeySchemaT{"TestHashKey", "HASH"},
- dynamodb.KeySchemaT{"TestRangeKey", "RANGE"},
- },
- GlobalSecondaryIndexes: []dynamodb.GlobalSecondaryIndexT{
- dynamodb.GlobalSecondaryIndexT{
- IndexName: "gsiTest",
- KeySchema: []dynamodb.KeySchemaT{
- dynamodb.KeySchemaT{"TestHashKey", "HASH"},
- dynamodb.KeySchemaT{"TestSecKey", "RANGE"},
- },
- Projection: dynamodb.ProjectionT{"ALL"},
- ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
- ReadCapacityUnits: 1,
- WriteCapacityUnits: 1,
- },
- },
- },
- ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
- ReadCapacityUnits: 1,
- WriteCapacityUnits: 1,
- },
- },
-}
-
-var _ = Suite(table_suite)
-
-func (s *TableSuite) TestCreateListTable(c *C) {
- status, err := s.server.CreateTable(s.TableDescriptionT)
- if err != nil {
- c.Fatal(err)
- }
- if status != "ACTIVE" && status != "CREATING" {
- c.Error("Expect status to be ACTIVE or CREATING")
- }
-
- s.WaitUntilStatus(c, "ACTIVE")
-
- tables, err := s.server.ListTables()
- if err != nil {
- c.Fatal(err)
- }
- c.Check(len(tables), Not(Equals), 0)
- c.Check(findTableByName(tables, s.TableDescriptionT.TableName), Equals, true)
-}
diff --git a/vendor/github.com/goamz/goamz/dynamodb/update_item.go b/vendor/github.com/goamz/goamz/dynamodb/update_item.go
deleted file mode 100644
index 280eb4bed..000000000
--- a/vendor/github.com/goamz/goamz/dynamodb/update_item.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package dynamodb
-
-import simplejson "github.com/bitly/go-simplejson"
-
-/*
-Construct an update item query.
-
-The query can be composed via chaining and then executed via Execute()
-
-Usage:
- update := table.UpdateItem(key)
- .ReturnValues(dynamodb.UPDATED_NEW)
- .UpdateExpression("SET Counter = Counter + :incr")
- .UpdateCondition("Counter < :checkVal")
- .ExpressionAttributes(NewNumberAttribute(":incr", "1"), NewNumberAttribute(":checkVal", 42))
- result, err := update.Execute()
- if err == nil {
- log.Printf("Counter is now %v", result.Attributes["Counter"].Value)
- }
-
-*/
-func (t *Table) UpdateItem(key *Key) *UpdateItem {
- q := NewQuery(t)
- q.AddKey(t, key)
- return &UpdateItem{table: t, query: q}
-}
-
-type UpdateItem struct {
- table *Table
- query *Query
- hasReturnValues bool
-}
-
-// Specify how return values are to be provided.
-func (u *UpdateItem) ReturnValues(returnValues ReturnValues) *UpdateItem {
- u.hasReturnValues = (returnValues != NONE)
- u.query.AddReturnValues(returnValues)
- return u
-}
-
-/*
-Specify an update expression and optional attribute settings at the same time.
-
- update.UpdateExpression("SET Foo = Foo + :incr", dynamodb.NewNumberAttribute(":incr", "7"))
-
-is equivalent to
-
- update.UpdateExpression("SET Foo = Foo + :incr")
- .ExpressionAttributes(NewNumberAttribute(":incr", "7"))
-
-*/
-func (u *UpdateItem) UpdateExpression(expression string, attributes ...Attribute) *UpdateItem {
- u.query.AddUpdateExpression(expression)
- u.ExpressionAttributes(attributes...)
- return u
-}
-
-// Specify attribute substitutions to be used in expressions.
-func (u *UpdateItem) ExpressionAttributes(attributes ...Attribute) *UpdateItem {
- u.query.AddExpressionAttributes(attributes)
- return u
-}
-
-// Specify a check condition for conditional updates.
-func (u *UpdateItem) ConditionExpression(expression string) *UpdateItem {
- u.query.AddConditionExpression(expression)
- return u
-}
-
-// Execute this query.
-func (u *UpdateItem) Execute() (*UpdateResult, error) {
- jsonResponse, err := u.table.Server.queryServer(target("UpdateItem"), u.query)
-
- if err != nil {
- return nil, err
- }
-
- if u.hasReturnValues {
- resp, err := simplejson.NewJson(jsonResponse)
- if err != nil {
- return nil, err
- }
- attrib, err := resp.Get("Attributes").Map()
- if err != nil {
- return nil, err
- }
- return &UpdateResult{parseAttributes(attrib)}, nil
- }
- return nil, nil
-}
-
-type UpdateResult struct {
- Attributes map[string]*Attribute
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/ec2.go b/vendor/github.com/goamz/goamz/ec2/ec2.go
deleted file mode 100644
index e6ec612cf..000000000
--- a/vendor/github.com/goamz/goamz/ec2/ec2.go
+++ /dev/null
@@ -1,2267 +0,0 @@
-//
-// goamz - Go packages to interact with the Amazon Web Services.
-//
-// https://wiki.ubuntu.com/goamz
-//
-// Copyright (c) 2011 Canonical Ltd.
-//
-// Written by Gustavo Niemeyer <gustavo.niemeyer@canonical.com>
-//
-
-package ec2
-
-import (
- "crypto/rand"
- "encoding/hex"
- "encoding/xml"
- "fmt"
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "sort"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-const debug = false
-
-// The EC2 type encapsulates operations with a specific EC2 region.
-type EC2 struct {
- aws.Auth
- aws.Region
- httpClient *http.Client
- private byte // Reserve the right of using private data.
-}
-
-// NewWithClient creates a new EC2 with a custom http client
-func NewWithClient(auth aws.Auth, region aws.Region, client *http.Client) *EC2 {
- return &EC2{auth, region, client, 0}
-}
-
-// New creates a new EC2.
-func New(auth aws.Auth, region aws.Region) *EC2 {
- return NewWithClient(auth, region, aws.RetryingClient)
-}
-
-// ----------------------------------------------------------------------------
-// Filtering helper.
-
-// Filter builds filtering parameters to be used in an EC2 query which supports
-// filtering. For example:
-//
-// filter := NewFilter()
-// filter.Add("architecture", "i386")
-// filter.Add("launch-index", "0")
-// resp, err := ec2.Instances(nil, filter)
-//
-type Filter struct {
- m map[string][]string
-}
-
-// NewFilter creates a new Filter.
-func NewFilter() *Filter {
- return &Filter{make(map[string][]string)}
-}
-
-// Add appends a filtering parameter with the given name and value(s).
-func (f *Filter) Add(name string, value ...string) {
- f.m[name] = append(f.m[name], value...)
-}
-
-func (f *Filter) addParams(params map[string]string) {
- if f != nil {
- a := make([]string, len(f.m))
- i := 0
- for k := range f.m {
- a[i] = k
- i++
- }
- sort.StringSlice(a).Sort()
- for i, k := range a {
- prefix := "Filter." + strconv.Itoa(i+1)
- params[prefix+".Name"] = k
- for j, v := range f.m[k] {
- params[prefix+".Value."+strconv.Itoa(j+1)] = v
- }
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-// Error encapsulates an error returned by EC2.
-//
-// See http://goo.gl/VZGuC for more details.
-type Error struct {
- // HTTP status code (200, 403, ...)
- StatusCode int
- // EC2 error code ("UnsupportedOperation", ...)
- Code string
- // The human-oriented error message
- Message string
- RequestId string `xml:"RequestID"`
-}
-
-func (err *Error) Error() string {
- if err.Code == "" {
- return err.Message
- }
-
- return fmt.Sprintf("%s (%s)", err.Message, err.Code)
-}
-
-// For now a single error inst is being exposed. In the future it may be useful
-// to provide access to all of them, but rather than doing it as an array/slice,
-// use a *next pointer, so that it's backward compatible and it continues to be
-// easy to handle the first error, which is what most people will want.
-type xmlErrors struct {
- RequestId string `xml:"RequestID"`
- Errors []Error `xml:"Errors>Error"`
-}
-
-var timeNow = time.Now
-
-func (ec2 *EC2) query(params map[string]string, resp interface{}) error {
- params["Version"] = "2014-02-01"
- params["Timestamp"] = timeNow().In(time.UTC).Format(time.RFC3339)
- endpoint, err := url.Parse(ec2.Region.EC2Endpoint)
- if err != nil {
- return err
- }
- if endpoint.Path == "" {
- endpoint.Path = "/"
- }
- sign(ec2.Auth, "GET", endpoint.Path, params, endpoint.Host)
- endpoint.RawQuery = multimap(params).Encode()
- if debug {
- log.Printf("get { %v } -> {\n", endpoint.String())
- }
- r, err := ec2.httpClient.Get(endpoint.String())
- if err != nil {
- return err
- }
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("response:\n")
- log.Printf("%v\n}\n", string(dump))
- }
- if r.StatusCode != 200 {
- return buildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-func buildError(r *http.Response) error {
- errors := xmlErrors{}
- xml.NewDecoder(r.Body).Decode(&errors)
- var err Error
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func makeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-func addParamsList(params map[string]string, label string, ids []string) {
- for i, id := range ids {
- params[label+"."+strconv.Itoa(i+1)] = id
- }
-}
-
-func addBlockDeviceParams(prename string, params map[string]string, blockdevices []BlockDeviceMapping) {
- for i, k := range blockdevices {
- // Fixup index since Amazon counts these from 1
- prefix := prename + "BlockDeviceMapping." + strconv.Itoa(i+1) + "."
-
- if k.DeviceName != "" {
- params[prefix+"DeviceName"] = k.DeviceName
- }
- if k.VirtualName != "" {
- params[prefix+"VirtualName"] = k.VirtualName
- }
- if k.SnapshotId != "" {
- params[prefix+"Ebs.SnapshotId"] = k.SnapshotId
- }
- if k.VolumeType != "" {
- params[prefix+"Ebs.VolumeType"] = k.VolumeType
- }
- if k.IOPS != 0 {
- params[prefix+"Ebs.Iops"] = strconv.FormatInt(k.IOPS, 10)
- }
- if k.VolumeSize != 0 {
- params[prefix+"Ebs.VolumeSize"] = strconv.FormatInt(k.VolumeSize, 10)
- }
- if k.DeleteOnTermination {
- params[prefix+"Ebs.DeleteOnTermination"] = "true"
- }
- if k.NoDevice {
- params[prefix+"NoDevice"] = "true"
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// Instance management functions and types.
-
-// RunInstancesOptions encapsulates options for the respective request in EC2.
-//
-// See http://goo.gl/Mcm3b for more details.
-type RunInstancesOptions struct {
- ImageId string
- MinCount int
- MaxCount int
- KeyName string
- InstanceType string
- SecurityGroups []SecurityGroup
- KernelId string
- RamdiskId string
- UserData []byte
- AvailabilityZone string
- PlacementGroupName string
- Tenancy string
- Monitoring bool
- SubnetId string
- DisableAPITermination bool
- ShutdownBehavior string
- PrivateIPAddress string
- IamInstanceProfile IamInstanceProfile
- BlockDevices []BlockDeviceMapping
- EbsOptimized bool
- AssociatePublicIpAddress bool
-}
-
-// Response to a RunInstances request.
-//
-// See http://goo.gl/Mcm3b for more details.
-type RunInstancesResp struct {
- RequestId string `xml:"requestId"`
- ReservationId string `xml:"reservationId"`
- OwnerId string `xml:"ownerId"`
- SecurityGroups []SecurityGroup `xml:"groupSet>item"`
- Instances []Instance `xml:"instancesSet>item"`
-}
-
-// Instance encapsulates a running instance in EC2.
-//
-// See http://goo.gl/OCH8a for more details.
-type Instance struct {
-
- // General instance information
- InstanceId string `xml:"instanceId"` // The ID of the instance launched
- InstanceType string `xml:"instanceType"` // The instance type eg. m1.small | m1.medium | m1.large etc
- AvailabilityZone string `xml:"placement>availabilityZone"` // The Availability Zone the instance is located in
- Tags []Tag `xml:"tagSet>item"` // Any tags assigned to the resource
- State InstanceState `xml:"instanceState"` // The current state of the instance
- Reason string `xml:"reason"` // The reason for the most recent state transition. This might be an empty string
- StateReason InstanceStateReason `xml:"stateReason"` // The reason for the most recent state transition
- ImageId string `xml:"imageId"` // The ID of the AMI used to launch the instance
- KeyName string `xml:"keyName"` // The key pair name, if this instance was launched with an associated key pair
- Monitoring string `xml:"monitoring>state"` // Valid values: disabled | enabled | pending
- IamInstanceProfile IamInstanceProfile `xml:"iamInstanceProfile"` // The IAM instance profile associated with the instance
- LaunchTime string `xml:"launchTime"` // The time the instance was launched
- OwnerId string // This isn't currently returned in the response, and is taken from the parent reservation
-
- // More specific information
- Architecture string `xml:"architecture"` // Valid values: i386 | x86_64
- Hypervisor string `xml:"hypervisor"` // Valid values: ovm | xen
- KernelId string `xml:"kernelId"` // The kernel associated with this instance
- RamDiskId string `xml:"ramdiskId"` // The RAM disk associated with this instance
- Platform string `xml:"platform"` // The value is Windows for Windows AMIs; otherwise blank
- VirtualizationType string `xml:"virtualizationType"` // Valid values: paravirtual | hvm
- AMILaunchIndex int `xml:"amiLaunchIndex"` // The AMI launch index, which can be used to find this instance in the launch group
- PlacementGroupName string `xml:"placement>groupName"` // The name of the placement group the instance is in (for cluster compute instances)
- Tenancy string `xml:"placement>tenancy"` // (VPC only) Valid values: default | dedicated
- InstanceLifecycle string `xml:"instanceLifecycle"` // Spot instance? Valid values: "spot" or blank
- SpotInstanceRequestId string `xml:"spotInstanceRequestId"` // The ID of the Spot Instance request
- ClientToken string `xml:"clientToken"` // The idempotency token you provided when you launched the instance
- ProductCodes []ProductCode `xml:"productCodes>item"` // The product codes attached to this instance
-
- // Storage
- RootDeviceType string `xml:"rootDeviceType"` // Valid values: ebs | instance-store
- RootDeviceName string `xml:"rootDeviceName"` // The root device name (for example, /dev/sda1)
- BlockDevices []BlockDevice `xml:"blockDeviceMapping>item"` // Any block device mapping entries for the instance
- EbsOptimized bool `xml:"ebsOptimized"` // Indicates whether the instance is optimized for Amazon EBS I/O
-
- // Network
- DNSName string `xml:"dnsName"` // The public DNS name assigned to the instance. This element remains empty until the instance enters the running state
- PrivateDNSName string `xml:"privateDnsName"` // The private DNS name assigned to the instance. This DNS name can only be used inside the Amazon EC2 network. This element remains empty until the instance enters the running state
- IPAddress string `xml:"ipAddress"` // The public IP address assigned to the instance
- PrivateIPAddress string `xml:"privateIpAddress"` // The private IP address assigned to the instance
- SubnetId string `xml:"subnetId"` // The ID of the subnet in which the instance is running
- VpcId string `xml:"vpcId"` // The ID of the VPC in which the instance is running
- SecurityGroups []SecurityGroup `xml:"groupSet>item"` // A list of the security groups for the instance
-
- // Advanced Networking
- NetworkInterfaces []InstanceNetworkInterface `xml:"networkInterfaceSet>item"` // (VPC) One or more network interfaces for the instance
- SourceDestCheck bool `xml:"sourceDestCheck"` // Controls whether source/destination checking is enabled on the instance
- SriovNetSupport string `xml:"sriovNetSupport"` // Specifies whether enhanced networking is enabled. Valid values: simple
-}
-
-// isSpotInstance returns if the instance is a spot instance
-func (i Instance) IsSpotInstance() bool {
- if i.InstanceLifecycle == "spot" {
- return true
- }
- return false
-}
-
-type BlockDevice struct {
- DeviceName string `xml:"deviceName"`
- EBS EBS `xml:"ebs"`
-}
-
-type EBS struct {
- VolumeId string `xml:"volumeId"`
- Status string `xml:"status"`
- AttachTime string `xml:"attachTime"`
- DeleteOnTermination bool `xml:"deleteOnTermination"`
-}
-
-// ProductCode represents a product code
-// See http://goo.gl/hswmQm for more details.
-type ProductCode struct {
- ProductCode string `xml:"productCode"` // The product code
- Type string `xml:"type"` // Valid values: devpay | marketplace
-}
-
-// InstanceNetworkInterface represents a network interface attached to an instance
-// See http://goo.gl/9eW02N for more details.
-type InstanceNetworkInterface struct {
- Id string `xml:"networkInterfaceId"`
- Description string `xml:"description"`
- SubnetId string `xml:"subnetId"`
- VpcId string `xml:"vpcId"`
- OwnerId string `xml:"ownerId"` // The ID of the AWS account that created the network interface.
- Status string `xml:"status"` // Valid values: available | attaching | in-use | detaching
- MacAddress string `xml:"macAddress"`
- PrivateIPAddress string `xml:"privateIpAddress"`
- PrivateDNSName string `xml:"privateDnsName"`
- SourceDestCheck bool `xml:"sourceDestCheck"`
- SecurityGroups []SecurityGroup `xml:"groupSet>item"`
- Attachment InstanceNetworkInterfaceAttachment `xml:"attachment"`
- Association InstanceNetworkInterfaceAssociation `xml:"association"`
- PrivateIPAddresses []InstancePrivateIpAddress `xml:"privateIpAddressesSet>item"`
-}
-
-// InstanceNetworkInterfaceAttachment describes a network interface attachment to an instance
-// See http://goo.gl/0ql0Cg for more details
-type InstanceNetworkInterfaceAttachment struct {
- AttachmentID string `xml:"attachmentID"` // The ID of the network interface attachment.
- DeviceIndex int32 `xml:"deviceIndex"` // The index of the device on the instance for the network interface attachment.
- Status string `xml:"status"` // Valid values: attaching | attached | detaching | detached
- AttachTime string `xml:"attachTime"` // Time attached, as a Datetime
- DeleteOnTermination bool `xml:"deleteOnTermination"` // Indicates whether the network interface is deleted when the instance is terminated.
-}
-
-// Describes association information for an Elastic IP address.
-// See http://goo.gl/YCDdMe for more details
-type InstanceNetworkInterfaceAssociation struct {
- PublicIP string `xml:"publicIp"` // The address of the Elastic IP address bound to the network interface
- PublicDNSName string `xml:"publicDnsName"` // The public DNS name
- IPOwnerId string `xml:"ipOwnerId"` // The ID of the owner of the Elastic IP address
-}
-
-// InstancePrivateIpAddress describes a private IP address
-// See http://goo.gl/irN646 for more details
-type InstancePrivateIpAddress struct {
- PrivateIPAddress string `xml:"privateIpAddress"` // The private IP address of the network interface
- PrivateDNSName string `xml:"privateDnsName"` // The private DNS name
- Primary bool `xml:"primary"` // Indicates whether this IP address is the primary private IP address of the network interface
- Association InstanceNetworkInterfaceAssociation `xml:"association"` // The association information for an Elastic IP address for the network interface
-}
-
-// IamInstanceProfile
-// See http://goo.gl/PjyijL for more details
-type IamInstanceProfile struct {
- ARN string `xml:"arn"`
- Id string `xml:"id"`
- Name string `xml:"name"`
-}
-
-// RunInstances starts new instances in EC2.
-// If options.MinCount and options.MaxCount are both zero, a single instance
-// will be started; otherwise if options.MaxCount is zero, options.MinCount
-// will be used instead.
-//
-// See http://goo.gl/Mcm3b for more details.
-func (ec2 *EC2) RunInstances(options *RunInstancesOptions) (resp *RunInstancesResp, err error) {
- params := makeParams("RunInstances")
- params["ImageId"] = options.ImageId
- params["InstanceType"] = options.InstanceType
- var min, max int
- if options.MinCount == 0 && options.MaxCount == 0 {
- min = 1
- max = 1
- } else if options.MaxCount == 0 {
- min = options.MinCount
- max = min
- } else {
- min = options.MinCount
- max = options.MaxCount
- }
- params["MinCount"] = strconv.Itoa(min)
- params["MaxCount"] = strconv.Itoa(max)
- token, err := clientToken()
- if err != nil {
- return nil, err
- }
- params["ClientToken"] = token
-
- if options.KeyName != "" {
- params["KeyName"] = options.KeyName
- }
- if options.KernelId != "" {
- params["KernelId"] = options.KernelId
- }
- if options.RamdiskId != "" {
- params["RamdiskId"] = options.RamdiskId
- }
- if options.UserData != nil {
- userData := make([]byte, b64.EncodedLen(len(options.UserData)))
- b64.Encode(userData, options.UserData)
- params["UserData"] = string(userData)
- }
- if options.AvailabilityZone != "" {
- params["Placement.AvailabilityZone"] = options.AvailabilityZone
- }
- if options.PlacementGroupName != "" {
- params["Placement.GroupName"] = options.PlacementGroupName
- }
- if options.Tenancy != "" {
- params["Placement.Tenancy"] = options.Tenancy
- }
- if options.Monitoring {
- params["Monitoring.Enabled"] = "true"
- }
- if options.SubnetId != "" && options.AssociatePublicIpAddress {
- // If we have a non-default VPC / Subnet specified, we can flag
- // AssociatePublicIpAddress to get a Public IP assigned. By default these are not provided.
- // You cannot specify both SubnetId and the NetworkInterface.0.* parameters though, otherwise
- // you get: Network interfaces and an instance-level subnet ID may not be specified on the same request
- // You also need to attach Security Groups to the NetworkInterface instead of the instance,
- // to avoid: Network interfaces and an instance-level security groups may not be specified on
- // the same request
- params["NetworkInterface.0.DeviceIndex"] = "0"
- params["NetworkInterface.0.AssociatePublicIpAddress"] = "true"
- params["NetworkInterface.0.SubnetId"] = options.SubnetId
-
- i := 1
- for _, g := range options.SecurityGroups {
- // We only have SecurityGroupId's on NetworkInterface's, no SecurityGroup params.
- if g.Id != "" {
- params["NetworkInterface.0.SecurityGroupId."+strconv.Itoa(i)] = g.Id
- i++
- }
- }
- } else {
- if options.SubnetId != "" {
- params["SubnetId"] = options.SubnetId
- }
-
- i, j := 1, 1
- for _, g := range options.SecurityGroups {
- if g.Id != "" {
- params["SecurityGroupId."+strconv.Itoa(i)] = g.Id
- i++
- } else {
- params["SecurityGroup."+strconv.Itoa(j)] = g.Name
- j++
- }
- }
- }
- if options.IamInstanceProfile.ARN != "" {
- params["IamInstanceProfile.Arn"] = options.IamInstanceProfile.ARN
- }
- if options.IamInstanceProfile.Name != "" {
- params["IamInstanceProfile.Name"] = options.IamInstanceProfile.Name
- }
- if options.DisableAPITermination {
- params["DisableApiTermination"] = "true"
- }
- if options.ShutdownBehavior != "" {
- params["InstanceInitiatedShutdownBehavior"] = options.ShutdownBehavior
- }
- if options.PrivateIPAddress != "" {
- params["PrivateIpAddress"] = options.PrivateIPAddress
- }
- if options.EbsOptimized {
- params["EbsOptimized"] = "true"
- }
-
- addBlockDeviceParams("", params, options.BlockDevices)
-
- resp = &RunInstancesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-func clientToken() (string, error) {
- // Maximum EC2 client token size is 64 bytes.
- // Each byte expands to two when hex encoded.
- buf := make([]byte, 32)
- _, err := rand.Read(buf)
- if err != nil {
- return "", err
- }
- return hex.EncodeToString(buf), nil
-}
-
-// ----------------------------------------------------------------------------
-// Spot Instance management functions and types.
-
-// The RequestSpotInstances type encapsulates options for the respective request in EC2.
-//
-// See http://goo.gl/GRZgCD for more details.
-type RequestSpotInstances struct {
- SpotPrice string
- InstanceCount int
- Type string
- ImageId string
- KeyName string
- InstanceType string
- SecurityGroups []SecurityGroup
- IamInstanceProfile string
- KernelId string
- RamdiskId string
- UserData []byte
- AvailZone string
- PlacementGroupName string
- Monitoring bool
- SubnetId string
- AssociatePublicIpAddress bool
- PrivateIPAddress string
- BlockDevices []BlockDeviceMapping
-}
-
-type SpotInstanceSpec struct {
- ImageId string
- KeyName string
- InstanceType string
- SecurityGroups []SecurityGroup
- IamInstanceProfile string
- KernelId string
- RamdiskId string
- UserData []byte
- AvailZone string
- PlacementGroupName string
- Monitoring bool
- SubnetId string
- AssociatePublicIpAddress bool
- PrivateIPAddress string
- BlockDevices []BlockDeviceMapping
-}
-
-type SpotLaunchSpec struct {
- ImageId string `xml:"imageId"`
- KeyName string `xml:"keyName"`
- InstanceType string `xml:"instanceType"`
- SecurityGroups []SecurityGroup `xml:"groupSet>item"`
- IamInstanceProfile string `xml:"iamInstanceProfile"`
- KernelId string `xml:"kernelId"`
- RamdiskId string `xml:"ramdiskId"`
- PlacementGroupName string `xml:"placement>groupName"`
- Monitoring bool `xml:"monitoring>enabled"`
- SubnetId string `xml:"subnetId"`
- BlockDevices []BlockDeviceMapping `xml:"blockDeviceMapping>item"`
-}
-
-type SpotRequestResult struct {
- SpotRequestId string `xml:"spotInstanceRequestId"`
- SpotPrice string `xml:"spotPrice"`
- Type string `xml:"type"`
- AvailZone string `xml:"launchedAvailabilityZone"`
- InstanceId string `xml:"instanceId"`
- State string `xml:"state"`
- SpotLaunchSpec SpotLaunchSpec `xml:"launchSpecification"`
- CreateTime string `xml:"createTime"`
- Tags []Tag `xml:"tagSet>item"`
-}
-
-// Response to a RequestSpotInstances request.
-//
-// See http://goo.gl/GRZgCD for more details.
-type RequestSpotInstancesResp struct {
- RequestId string `xml:"requestId"`
- SpotRequestResults []SpotRequestResult `xml:"spotInstanceRequestSet>item"`
-}
-
-// RequestSpotInstances requests a new spot instances in EC2.
-func (ec2 *EC2) RequestSpotInstances(options *RequestSpotInstances) (resp *RequestSpotInstancesResp, err error) {
- params := makeParams("RequestSpotInstances")
- prefix := "LaunchSpecification" + "."
-
- params["SpotPrice"] = options.SpotPrice
- params[prefix+"ImageId"] = options.ImageId
- params[prefix+"InstanceType"] = options.InstanceType
-
- if options.InstanceCount != 0 {
- params["InstanceCount"] = strconv.Itoa(options.InstanceCount)
- }
- if options.KeyName != "" {
- params[prefix+"KeyName"] = options.KeyName
- }
- if options.KernelId != "" {
- params[prefix+"KernelId"] = options.KernelId
- }
- if options.RamdiskId != "" {
- params[prefix+"RamdiskId"] = options.RamdiskId
- }
- if options.UserData != nil {
- userData := make([]byte, b64.EncodedLen(len(options.UserData)))
- b64.Encode(userData, options.UserData)
- params[prefix+"UserData"] = string(userData)
- }
- if options.AvailZone != "" {
- params[prefix+"Placement.AvailabilityZone"] = options.AvailZone
- }
- if options.PlacementGroupName != "" {
- params[prefix+"Placement.GroupName"] = options.PlacementGroupName
- }
- if options.Monitoring {
- params[prefix+"Monitoring.Enabled"] = "true"
- }
- if options.SubnetId != "" && options.AssociatePublicIpAddress {
- // If we have a non-default VPC / Subnet specified, we can flag
- // AssociatePublicIpAddress to get a Public IP assigned. By default these are not provided.
- // You cannot specify both SubnetId and the NetworkInterface.0.* parameters though, otherwise
- // you get: Network interfaces and an instance-level subnet ID may not be specified on the same request
- // You also need to attach Security Groups to the NetworkInterface instead of the instance,
- // to avoid: Network interfaces and an instance-level security groups may not be specified on
- // the same request
- params[prefix+"NetworkInterface.0.DeviceIndex"] = "0"
- params[prefix+"NetworkInterface.0.AssociatePublicIpAddress"] = "true"
- params[prefix+"NetworkInterface.0.SubnetId"] = options.SubnetId
-
- i := 1
- for _, g := range options.SecurityGroups {
- // We only have SecurityGroupId's on NetworkInterface's, no SecurityGroup params.
- if g.Id != "" {
- params[prefix+"NetworkInterface.0.SecurityGroupId."+strconv.Itoa(i)] = g.Id
- i++
- }
- }
- } else {
- if options.SubnetId != "" {
- params[prefix+"SubnetId"] = options.SubnetId
- }
-
- i, j := 1, 1
- for _, g := range options.SecurityGroups {
- if g.Id != "" {
- params[prefix+"SecurityGroupId."+strconv.Itoa(i)] = g.Id
- i++
- } else {
- params[prefix+"SecurityGroup."+strconv.Itoa(j)] = g.Name
- j++
- }
- }
- }
- if options.IamInstanceProfile != "" {
- params[prefix+"IamInstanceProfile.Name"] = options.IamInstanceProfile
- }
- if options.PrivateIPAddress != "" {
- params[prefix+"PrivateIpAddress"] = options.PrivateIPAddress
- }
- addBlockDeviceParams(prefix, params, options.BlockDevices)
-
- resp = &RequestSpotInstancesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Response to a DescribeSpotInstanceRequests request.
-//
-// See http://goo.gl/KsKJJk for more details.
-type SpotRequestsResp struct {
- RequestId string `xml:"requestId"`
- SpotRequestResults []SpotRequestResult `xml:"spotInstanceRequestSet>item"`
-}
-
-// DescribeSpotInstanceRequests returns details about spot requests in EC2. Both parameters
-// are optional, and if provided will limit the spot requests returned to those
-// matching the given spot request ids or filtering rules.
-//
-// See http://goo.gl/KsKJJk for more details.
-func (ec2 *EC2) DescribeSpotRequests(spotrequestIds []string, filter *Filter) (resp *SpotRequestsResp, err error) {
- params := makeParams("DescribeSpotInstanceRequests")
- addParamsList(params, "SpotInstanceRequestId", spotrequestIds)
- filter.addParams(params)
- resp = &SpotRequestsResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Response to a CancelSpotInstanceRequests request.
-//
-// See http://goo.gl/3BKHj for more details.
-type CancelSpotRequestResult struct {
- SpotRequestId string `xml:"spotInstanceRequestId"`
- State string `xml:"state"`
-}
-type CancelSpotRequestsResp struct {
- RequestId string `xml:"requestId"`
- CancelSpotRequestResults []CancelSpotRequestResult `xml:"spotInstanceRequestSet>item"`
-}
-
-// CancelSpotRequests requests the cancellation of spot requests when the given ids.
-//
-// See http://goo.gl/3BKHj for more details.
-func (ec2 *EC2) CancelSpotRequests(spotrequestIds []string) (resp *CancelSpotRequestsResp, err error) {
- params := makeParams("CancelSpotInstanceRequests")
- addParamsList(params, "SpotInstanceRequestId", spotrequestIds)
- resp = &CancelSpotRequestsResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Response to a TerminateInstances request.
-//
-// See http://goo.gl/3BKHj for more details.
-type TerminateInstancesResp struct {
- RequestId string `xml:"requestId"`
- StateChanges []InstanceStateChange `xml:"instancesSet>item"`
-}
-
-// InstanceState encapsulates the state of an instance in EC2.
-//
-// See http://goo.gl/y3ZBq for more details.
-type InstanceState struct {
- Code int `xml:"code"` // Watch out, bits 15-8 have unpublished meaning.
- Name string `xml:"name"`
-}
-
-// InstanceStateChange informs of the previous and current states
-// for an instance when a state change is requested.
-type InstanceStateChange struct {
- InstanceId string `xml:"instanceId"`
- CurrentState InstanceState `xml:"currentState"`
- PreviousState InstanceState `xml:"previousState"`
-}
-
-// InstanceStateReason describes a state change for an instance in EC2
-//
-// See http://goo.gl/KZkbXi for more details
-type InstanceStateReason struct {
- Code string `xml:"code"`
- Message string `xml:"message"`
-}
-
-// TerminateInstances requests the termination of instances when the given ids.
-//
-// See http://goo.gl/3BKHj for more details.
-func (ec2 *EC2) TerminateInstances(instIds []string) (resp *TerminateInstancesResp, err error) {
- params := makeParams("TerminateInstances")
- addParamsList(params, "InstanceId", instIds)
- resp = &TerminateInstancesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Response to a DescribeInstances request.
-//
-// See http://goo.gl/mLbmw for more details.
-type DescribeInstancesResp struct {
- RequestId string `xml:"requestId"`
- Reservations []Reservation `xml:"reservationSet>item"`
-}
-
-// Reservation represents details about a reservation in EC2.
-//
-// See http://goo.gl/0ItPT for more details.
-type Reservation struct {
- ReservationId string `xml:"reservationId"`
- OwnerId string `xml:"ownerId"`
- RequesterId string `xml:"requesterId"`
- SecurityGroups []SecurityGroup `xml:"groupSet>item"`
- Instances []Instance `xml:"instancesSet>item"`
-}
-
-// Instances returns details about instances in EC2. Both parameters
-// are optional, and if provided will limit the instances returned to those
-// matching the given instance ids or filtering rules.
-//
-// See http://goo.gl/4No7c for more details.
-func (ec2 *EC2) DescribeInstances(instIds []string, filter *Filter) (resp *DescribeInstancesResp, err error) {
- params := makeParams("DescribeInstances")
- addParamsList(params, "InstanceId", instIds)
- filter.addParams(params)
- resp = &DescribeInstancesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- // Add additional parameters to instances which aren't available in the response
- for i, rsv := range resp.Reservations {
- ownerId := rsv.OwnerId
- for j, inst := range rsv.Instances {
- inst.OwnerId = ownerId
- resp.Reservations[i].Instances[j] = inst
- }
- }
-
- return
-}
-
-// DescribeInstanceStatusOptions encapsulates the query parameters for the corresponding action.
-//
-// See http:////goo.gl/2FBTdS for more details.
-type DescribeInstanceStatusOptions struct {
- InstanceIds []string // If non-empty, limit the query to this subset of instances. Maximum length of 100.
- IncludeAllInstances bool // If true, describe all instances, instead of just running instances (the default).
- MaxResults int // Maximum number of results to return. Minimum of 5. Maximum of 1000.
- NextToken string // The token for the next set of items to return. (You received this token from a prior call.)
-}
-
-// Response to a DescribeInstanceStatus request.
-//
-// See http://goo.gl/2FBTdS for more details.
-type DescribeInstanceStatusResp struct {
- RequestId string `xml:"requestId"`
- InstanceStatusSet []InstanceStatusItem `xml:"instanceStatusSet>item"`
- NextToken string `xml:"nextToken"`
-}
-
-// InstanceStatusItem describes the instance status, cause, details, and potential actions to take in response.
-//
-// See http://goo.gl/oImFZZ for more details.
-type InstanceStatusItem struct {
- InstanceId string `xml:"instanceId"`
- AvailabilityZone string `xml:"availabilityZone"`
- Events []InstanceStatusEvent `xml:"eventsSet>item"` // Extra information regarding events associated with the instance.
- InstanceState InstanceState `xml:"instanceState"` // The intended state of the instance. Calls to DescribeInstanceStatus require that an instance be in the running state.
- SystemStatus InstanceStatus `xml:"systemStatus"`
- InstanceStatus InstanceStatus `xml:"instanceStatus"`
-}
-
-// InstanceStatusEvent describes an instance event.
-//
-// See http://goo.gl/PXsDTn for more details.
-type InstanceStatusEvent struct {
- Code string `xml:"code"` // The associated code of the event.
- Description string `xml:"description"` // A description of the event.
- NotBefore string `xml:"notBefore"` // The earliest scheduled start time for the event.
- NotAfter string `xml:"notAfter"` // The latest scheduled end time for the event.
-}
-
-// InstanceStatus describes the status of an instance with details.
-//
-// See http://goo.gl/eFch4S for more details.
-type InstanceStatus struct {
- Status string `xml:"status"` // The instance status.
- Details InstanceStatusDetails `xml:"details"` // The system instance health or application instance health.
-}
-
-// InstanceStatusDetails describes the instance status with the cause and more detail.
-//
-// See http://goo.gl/3qoMC4 for more details.
-type InstanceStatusDetails struct {
- Name string `xml:"name"` // The type of instance status.
- Status string `xml:"status"` // The status.
- ImpairedSince string `xml:"impairedSince"` // The time when a status check failed. For an instance that was launched and impaired, this is the time when the instance was launched.
-}
-
-// DescribeInstanceStatus returns instance status information about instances in EC2.
-// instIds and filter are optional, and if provided will limit the instances returned to those
-// matching the given instance ids or filtering rules.
-// all determines whether to report all matching instances or only those in the running state
-//
-// See http://goo.gl/2FBTdS for more details.
-func (ec2 *EC2) DescribeInstanceStatus(options *DescribeInstanceStatusOptions, filter *Filter) (resp *DescribeInstanceStatusResp, err error) {
- params := makeParams("DescribeInstanceStatus")
- if len(options.InstanceIds) > 0 {
- addParamsList(params, "InstanceId", options.InstanceIds)
- }
- if options.IncludeAllInstances {
- params["IncludeAllInstances"] = "true"
- }
- if options.MaxResults != 0 {
- params["MaxResults"] = strconv.Itoa(options.MaxResults)
- }
- if options.NextToken != "" {
- params["NextToken"] = options.NextToken
- }
- filter.addParams(params)
- resp = &DescribeInstanceStatusResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ----------------------------------------------------------------------------
-// KeyPair management functions and types.
-
-type CreateKeyPairResp struct {
- RequestId string `xml:"requestId"`
- KeyName string `xml:"keyName"`
- KeyFingerprint string `xml:"keyFingerprint"`
- KeyMaterial string `xml:"keyMaterial"`
-}
-
-// CreateKeyPair creates a new key pair and returns the private key contents.
-//
-// See http://goo.gl/0S6hV
-func (ec2 *EC2) CreateKeyPair(keyName string) (resp *CreateKeyPairResp, err error) {
- params := makeParams("CreateKeyPair")
- params["KeyName"] = keyName
-
- resp = &CreateKeyPairResp{}
- err = ec2.query(params, resp)
- if err == nil {
- resp.KeyFingerprint = strings.TrimSpace(resp.KeyFingerprint)
- }
- return
-}
-
-// DeleteKeyPair deletes a key pair.
-//
-// See http://goo.gl/0bqok
-func (ec2 *EC2) DeleteKeyPair(name string) (resp *SimpleResp, err error) {
- params := makeParams("DeleteKeyPair")
- params["KeyName"] = name
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- return
-}
-
-type ImportKeyPairOptions struct {
- KeyName string
- PublicKeyMaterial string
-}
-
-type ImportKeyPairResp struct {
- RequestId string `xml:"requestId"`
- KeyName string `xml:"keyName"`
- KeyFingerprint string `xml:"keyFingerprint"`
-}
-
-// ImportKeyPair import a key pair.
-//
-// See http://goo.gl/xpTccS
-func (ec2 *EC2) ImportKeyPair(options *ImportKeyPairOptions) (resp *ImportKeyPairResp, err error) {
- params := makeParams("ImportKeyPair")
- params["KeyName"] = options.KeyName
- params["PublicKeyMaterial"] = options.PublicKeyMaterial
-
- resp = &ImportKeyPairResp{}
- err = ec2.query(params, resp)
- return
-}
-
-// ResourceTag represents key-value metadata used to classify and organize
-// EC2 instances.
-//
-// See http://goo.gl/bncl3 for more details
-type Tag struct {
- Key string `xml:"key"`
- Value string `xml:"value"`
-}
-
-// CreateTags adds or overwrites one or more tags for the specified taggable resources.
-// For a list of tagable resources, see: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html
-//
-// See http://goo.gl/Vmkqc for more details
-func (ec2 *EC2) CreateTags(resourceIds []string, tags []Tag) (resp *SimpleResp, err error) {
- params := makeParams("CreateTags")
- addParamsList(params, "ResourceId", resourceIds)
-
- for j, tag := range tags {
- params["Tag."+strconv.Itoa(j+1)+".Key"] = tag.Key
- params["Tag."+strconv.Itoa(j+1)+".Value"] = tag.Value
- }
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to a StartInstances request.
-//
-// See http://goo.gl/awKeF for more details.
-type StartInstanceResp struct {
- RequestId string `xml:"requestId"`
- StateChanges []InstanceStateChange `xml:"instancesSet>item"`
-}
-
-// Response to a StopInstances request.
-//
-// See http://goo.gl/436dJ for more details.
-type StopInstanceResp struct {
- RequestId string `xml:"requestId"`
- StateChanges []InstanceStateChange `xml:"instancesSet>item"`
-}
-
-// StartInstances starts an Amazon EBS-backed AMI that you've previously stopped.
-//
-// See http://goo.gl/awKeF for more details.
-func (ec2 *EC2) StartInstances(ids ...string) (resp *StartInstanceResp, err error) {
- params := makeParams("StartInstances")
- addParamsList(params, "InstanceId", ids)
- resp = &StartInstanceResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StopInstances requests stopping one or more Amazon EBS-backed instances.
-//
-// See http://goo.gl/436dJ for more details.
-func (ec2 *EC2) StopInstances(ids ...string) (resp *StopInstanceResp, err error) {
- params := makeParams("StopInstances")
- addParamsList(params, "InstanceId", ids)
- resp = &StopInstanceResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// RebootInstance requests a reboot of one or more instances. This operation is asynchronous;
-// it only queues a request to reboot the specified instance(s). The operation will succeed
-// if the instances are valid and belong to you.
-//
-// Requests to reboot terminated instances are ignored.
-//
-// See http://goo.gl/baoUf for more details.
-func (ec2 *EC2) RebootInstances(ids ...string) (resp *SimpleResp, err error) {
- params := makeParams("RebootInstances")
- addParamsList(params, "InstanceId", ids)
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// The ModifyInstanceAttribute request parameters.
-type ModifyInstance struct {
- InstanceType string
- BlockDevices []BlockDeviceMapping
- DisableAPITermination bool
- EbsOptimized bool
- SecurityGroups []SecurityGroup
- ShutdownBehavior string
- KernelId string
- RamdiskId string
- SourceDestCheck bool
- SriovNetSupport bool
- UserData []byte
-}
-
-// Response to a ModifyInstanceAttribute request.
-//
-// http://goo.gl/icuXh5 for more details.
-type ModifyInstanceResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"`
-}
-
-// ModifyImageAttribute modifies the specified attribute of the specified instance.
-// You can specify only one attribute at a time. To modify some attributes, the
-// instance must be stopped.
-//
-// See http://goo.gl/icuXh5 for more details.
-func (ec2 *EC2) ModifyInstance(instId string, options *ModifyInstance) (resp *ModifyInstanceResp, err error) {
- params := makeParams("ModifyInstanceAttribute")
- params["InstanceId"] = instId
- addBlockDeviceParams("", params, options.BlockDevices)
-
- if options.InstanceType != "" {
- params["InstanceType.Value"] = options.InstanceType
- }
-
- if options.DisableAPITermination {
- params["DisableApiTermination.Value"] = "true"
- }
-
- if options.EbsOptimized {
- params["EbsOptimized"] = "true"
- }
-
- if options.ShutdownBehavior != "" {
- params["InstanceInitiatedShutdownBehavior.Value"] = options.ShutdownBehavior
- }
-
- if options.KernelId != "" {
- params["Kernel.Value"] = options.KernelId
- }
-
- if options.RamdiskId != "" {
- params["Ramdisk.Value"] = options.RamdiskId
- }
-
- if options.SourceDestCheck {
- params["SourceDestCheck.Value"] = "true"
- }
-
- if options.SriovNetSupport {
- params["SriovNetSupport.Value"] = "simple"
- }
-
- if options.UserData != nil {
- userData := make([]byte, b64.EncodedLen(len(options.UserData)))
- b64.Encode(userData, options.UserData)
- params["UserData"] = string(userData)
- }
-
- i := 1
- for _, g := range options.SecurityGroups {
- if g.Id != "" {
- params["GroupId."+strconv.Itoa(i)] = g.Id
- i++
- }
- }
-
- resp = &ModifyInstanceResp{}
- err = ec2.query(params, resp)
- if err != nil {
- resp = nil
- }
- return
-}
-
-// Reserved Instances
-
-// Structures
-
-// DescribeReservedInstancesResponse structure returned from a DescribeReservedInstances request.
-//
-// See
-type DescribeReservedInstancesResponse struct {
- RequestId string `xml:"requestId"`
- ReservedInstances []ReservedInstancesResponseItem `xml:"reservedInstancesSet>item"`
-}
-
-//
-//
-// See
-type ReservedInstancesResponseItem struct {
- ReservedInstanceId string `xml:"reservedInstancesId"`
- InstanceType string `xml:"instanceType"`
- AvailabilityZone string `xml:"availabilityZone"`
- Start string `xml:"start"`
- Duration uint64 `xml:"duration"`
- End string `xml:"end"`
- FixedPrice float32 `xml:"fixedPrice"`
- UsagePrice float32 `xml:"usagePrice"`
- InstanceCount int `xml:"instanceCount"`
- ProductDescription string `xml:"productDescription"`
- State string `xml:"state"`
- Tags []Tag `xml:"tagSet->item"`
- InstanceTenancy string `xml:"instanceTenancy"`
- CurrencyCode string `xml:"currencyCode"`
- OfferingType string `xml:"offeringType"`
- RecurringCharges []RecurringCharge `xml:"recurringCharges>item"`
-}
-
-//
-//
-// See
-type RecurringCharge struct {
- Frequency string `xml:"frequency"`
- Amount float32 `xml:"amount"`
-}
-
-// functions
-// DescribeReservedInstances
-//
-// See
-func (ec2 *EC2) DescribeReservedInstances(instIds []string, filter *Filter) (resp *DescribeReservedInstancesResponse, err error) {
- params := makeParams("DescribeReservedInstances")
-
- for i, id := range instIds {
- params["ReservedInstancesId."+strconv.Itoa(i+1)] = id
- }
- filter.addParams(params)
-
- resp = &DescribeReservedInstancesResponse{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ----------------------------------------------------------------------------
-// Image and snapshot management functions and types.
-
-// The CreateImage request parameters.
-//
-// See http://goo.gl/cxU41 for more details.
-type CreateImage struct {
- InstanceId string
- Name string
- Description string
- NoReboot bool
- BlockDevices []BlockDeviceMapping
-}
-
-// Response to a CreateImage request.
-//
-// See http://goo.gl/cxU41 for more details.
-type CreateImageResp struct {
- RequestId string `xml:"requestId"`
- ImageId string `xml:"imageId"`
-}
-
-// Response to a DescribeImages request.
-//
-// See http://goo.gl/hLnyg for more details.
-type ImagesResp struct {
- RequestId string `xml:"requestId"`
- Images []Image `xml:"imagesSet>item"`
-}
-
-// Response to a DescribeImageAttribute request.
-//
-// See http://goo.gl/bHO3zT for more details.
-type ImageAttributeResp struct {
- RequestId string `xml:"requestId"`
- ImageId string `xml:"imageId"`
- Kernel string `xml:"kernel>value"`
- RamDisk string `xml:"ramdisk>value"`
- Description string `xml:"description>value"`
- Group string `xml:"launchPermission>item>group"`
- UserIds []string `xml:"launchPermission>item>userId"`
- ProductCodes []string `xml:"productCodes>item>productCode"`
- BlockDevices []BlockDeviceMapping `xml:"blockDeviceMapping>item"`
-}
-
-// The RegisterImage request parameters.
-type RegisterImage struct {
- ImageLocation string
- Name string
- Description string
- Architecture string
- KernelId string
- RamdiskId string
- RootDeviceName string
- VirtType string
- BlockDevices []BlockDeviceMapping
-}
-
-// Response to a RegisterImage request.
-type RegisterImageResp struct {
- RequestId string `xml:"requestId"`
- ImageId string `xml:"imageId"`
-}
-
-// Response to a DegisterImage request.
-//
-// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html
-type DeregisterImageResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"`
-}
-
-// BlockDeviceMapping represents the association of a block device with an image.
-//
-// See http://goo.gl/wnDBf for more details.
-type BlockDeviceMapping struct {
- DeviceName string `xml:"deviceName"`
- VirtualName string `xml:"virtualName"`
- SnapshotId string `xml:"ebs>snapshotId"`
- VolumeType string `xml:"ebs>volumeType"`
- VolumeSize int64 `xml:"ebs>volumeSize"`
- DeleteOnTermination bool `xml:"ebs>deleteOnTermination"`
- NoDevice bool `xml:"noDevice"`
-
- // The number of I/O operations per second (IOPS) that the volume supports.
- IOPS int64 `xml:"ebs>iops"`
-}
-
-// Image represents details about an image.
-//
-// See http://goo.gl/iSqJG for more details.
-type Image struct {
- Id string `xml:"imageId"`
- Name string `xml:"name"`
- Description string `xml:"description"`
- Type string `xml:"imageType"`
- State string `xml:"imageState"`
- Location string `xml:"imageLocation"`
- Public bool `xml:"isPublic"`
- Architecture string `xml:"architecture"`
- Platform string `xml:"platform"`
- ProductCodes []string `xml:"productCode>item>productCode"`
- KernelId string `xml:"kernelId"`
- RamdiskId string `xml:"ramdiskId"`
- StateReason string `xml:"stateReason"`
- OwnerId string `xml:"imageOwnerId"`
- OwnerAlias string `xml:"imageOwnerAlias"`
- RootDeviceType string `xml:"rootDeviceType"`
- RootDeviceName string `xml:"rootDeviceName"`
- VirtualizationType string `xml:"virtualizationType"`
- Hypervisor string `xml:"hypervisor"`
- BlockDevices []BlockDeviceMapping `xml:"blockDeviceMapping>item"`
- Tags []Tag `xml:"tagSet>item"`
-}
-
-// The ModifyImageAttribute request parameters.
-type ModifyImageAttribute struct {
- AddUsers []string
- RemoveUsers []string
- AddGroups []string
- RemoveGroups []string
- ProductCodes []string
- Description string
-}
-
-// The CopyImage request parameters.
-//
-// See http://goo.gl/hQwPCK for more details.
-type CopyImage struct {
- SourceRegion string
- SourceImageId string
- Name string
- Description string
- ClientToken string
-}
-
-// Response to a CopyImage request.
-//
-// See http://goo.gl/hQwPCK for more details.
-type CopyImageResp struct {
- RequestId string `xml:"requestId"`
- ImageId string `xml:"imageId"`
-}
-
-// Creates an Amazon EBS-backed AMI from an Amazon EBS-backed instance
-// that is either running or stopped.
-//
-// See http://goo.gl/cxU41 for more details.
-func (ec2 *EC2) CreateImage(options *CreateImage) (resp *CreateImageResp, err error) {
- params := makeParams("CreateImage")
- params["InstanceId"] = options.InstanceId
- params["Name"] = options.Name
- if options.Description != "" {
- params["Description"] = options.Description
- }
- if options.NoReboot {
- params["NoReboot"] = "true"
- }
- addBlockDeviceParams("", params, options.BlockDevices)
-
- resp = &CreateImageResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
-
-// Images returns details about available images.
-// The ids and filter parameters, if provided, will limit the images returned.
-// For example, to get all the private images associated with this account set
-// the boolean filter "is-public" to 0.
-// For list of filters: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html
-//
-// Note: calling this function with nil ids and filter parameters will result in
-// a very large number of images being returned.
-//
-// See http://goo.gl/SRBhW for more details.
-func (ec2 *EC2) Images(ids []string, filter *Filter) (resp *ImagesResp, err error) {
- params := makeParams("DescribeImages")
- for i, id := range ids {
- params["ImageId."+strconv.Itoa(i+1)] = id
- }
- filter.addParams(params)
-
- resp = &ImagesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ImagesByOwners returns details about available images.
-// The ids, owners, and filter parameters, if provided, will limit the images returned.
-// For example, to get all the private images associated with this account set
-// the boolean filter "is-public" to 0.
-// For list of filters: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html
-//
-// Note: calling this function with nil ids and filter parameters will result in
-// a very large number of images being returned.
-//
-// See http://goo.gl/SRBhW for more details.
-func (ec2 *EC2) ImagesByOwners(ids []string, owners []string, filter *Filter) (resp *ImagesResp, err error) {
- params := makeParams("DescribeImages")
- for i, id := range ids {
- params["ImageId."+strconv.Itoa(i+1)] = id
- }
- for i, owner := range owners {
- params[fmt.Sprintf("Owner.%d", i+1)] = owner
- }
-
- filter.addParams(params)
-
- resp = &ImagesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ImageAttribute describes an attribute of an AMI.
-// You can specify only one attribute at a time.
-// Valid attributes are:
-// description | kernel | ramdisk | launchPermission | productCodes | blockDeviceMapping
-//
-// See http://goo.gl/bHO3zT for more details.
-func (ec2 *EC2) ImageAttribute(imageId, attribute string) (resp *ImageAttributeResp, err error) {
- params := makeParams("DescribeImageAttribute")
- params["ImageId"] = imageId
- params["Attribute"] = attribute
-
- resp = &ImageAttributeResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ModifyImageAttribute sets attributes for an image.
-//
-// See http://goo.gl/YUjO4G for more details.
-func (ec2 *EC2) ModifyImageAttribute(imageId string, options *ModifyImageAttribute) (resp *SimpleResp, err error) {
- params := makeParams("ModifyImageAttribute")
- params["ImageId"] = imageId
- if options.Description != "" {
- params["Description.Value"] = options.Description
- }
-
- if options.AddUsers != nil {
- for i, user := range options.AddUsers {
- p := fmt.Sprintf("LaunchPermission.Add.%d.UserId", i+1)
- params[p] = user
- }
- }
-
- if options.RemoveUsers != nil {
- for i, user := range options.RemoveUsers {
- p := fmt.Sprintf("LaunchPermission.Remove.%d.UserId", i+1)
- params[p] = user
- }
- }
-
- if options.AddGroups != nil {
- for i, group := range options.AddGroups {
- p := fmt.Sprintf("LaunchPermission.Add.%d.Group", i+1)
- params[p] = group
- }
- }
-
- if options.RemoveGroups != nil {
- for i, group := range options.RemoveGroups {
- p := fmt.Sprintf("LaunchPermission.Remove.%d.Group", i+1)
- params[p] = group
- }
- }
-
- if options.ProductCodes != nil {
- addParamsList(params, "ProductCode", options.ProductCodes)
- }
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- resp = nil
- }
-
- return
-}
-
-// Registers a new AMI with EC2.
-//
-// See: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html
-func (ec2 *EC2) RegisterImage(options *RegisterImage) (resp *RegisterImageResp, err error) {
- params := makeParams("RegisterImage")
- params["Name"] = options.Name
- if options.ImageLocation != "" {
- params["ImageLocation"] = options.ImageLocation
- }
-
- if options.Description != "" {
- params["Description"] = options.Description
- }
-
- if options.Architecture != "" {
- params["Architecture"] = options.Architecture
- }
-
- if options.KernelId != "" {
- params["KernelId"] = options.KernelId
- }
-
- if options.RamdiskId != "" {
- params["RamdiskId"] = options.RamdiskId
- }
-
- if options.RootDeviceName != "" {
- params["RootDeviceName"] = options.RootDeviceName
- }
-
- if options.VirtType != "" {
- params["VirtualizationType"] = options.VirtType
- }
-
- addBlockDeviceParams("", params, options.BlockDevices)
-
- resp = &RegisterImageResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
-
-// Degisters an image. Note that this does not delete the backing stores of the AMI.
-//
-// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html
-func (ec2 *EC2) DeregisterImage(imageId string) (resp *DeregisterImageResp, err error) {
- params := makeParams("DeregisterImage")
- params["ImageId"] = imageId
-
- resp = &DeregisterImageResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
-
-// Copy and Image from one region to another.
-//
-// See http://goo.gl/hQwPCK for more details.
-func (ec2 *EC2) CopyImage(options *CopyImage) (resp *CopyImageResp, err error) {
- params := makeParams("CopyImage")
-
- if options.SourceRegion != "" {
- params["SourceRegion"] = options.SourceRegion
- }
-
- if options.SourceImageId != "" {
- params["SourceImageId"] = options.SourceImageId
- }
-
- if options.Name != "" {
- params["Name"] = options.Name
- }
-
- if options.Description != "" {
- params["Description"] = options.Description
- }
-
- if options.ClientToken != "" {
- params["ClientToken"] = options.ClientToken
- }
-
- resp = &CopyImageResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
-
-// Response to a CreateSnapshot request.
-//
-// See http://goo.gl/ttcda for more details.
-type CreateSnapshotResp struct {
- RequestId string `xml:"requestId"`
- Snapshot
-}
-
-// CreateSnapshot creates a volume snapshot and stores it in S3.
-//
-// See http://goo.gl/ttcda for more details.
-func (ec2 *EC2) CreateSnapshot(volumeId, description string) (resp *CreateSnapshotResp, err error) {
- params := makeParams("CreateSnapshot")
- params["VolumeId"] = volumeId
- params["Description"] = description
-
- resp = &CreateSnapshotResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// DeleteSnapshots deletes the volume snapshots with the given ids.
-//
-// Note: If you make periodic snapshots of a volume, the snapshots are
-// incremental so that only the blocks on the device that have changed
-// since your last snapshot are incrementally saved in the new snapshot.
-// Even though snapshots are saved incrementally, the snapshot deletion
-// process is designed so that you need to retain only the most recent
-// snapshot in order to restore the volume.
-//
-// See http://goo.gl/vwU1y for more details.
-func (ec2 *EC2) DeleteSnapshots(ids []string) (resp *SimpleResp, err error) {
- params := makeParams("DeleteSnapshot")
- for i, id := range ids {
- params["SnapshotId."+strconv.Itoa(i+1)] = id
- }
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
-
-// Response to a DescribeSnapshots request.
-//
-// See http://goo.gl/nClDT for more details.
-type SnapshotsResp struct {
- RequestId string `xml:"requestId"`
- Snapshots []Snapshot `xml:"snapshotSet>item"`
-}
-
-// Snapshot represents details about a volume snapshot.
-//
-// See http://goo.gl/nkovs for more details.
-type Snapshot struct {
- Id string `xml:"snapshotId"`
- VolumeId string `xml:"volumeId"`
- VolumeSize string `xml:"volumeSize"`
- Status string `xml:"status"`
- StartTime string `xml:"startTime"`
- Description string `xml:"description"`
- Progress string `xml:"progress"`
- OwnerId string `xml:"ownerId"`
- OwnerAlias string `xml:"ownerAlias"`
- Tags []Tag `xml:"tagSet>item"`
-}
-
-// Snapshots returns details about volume snapshots available to the user.
-// The ids and filter parameters, if provided, limit the snapshots returned.
-//
-// See http://goo.gl/ogJL4 for more details.
-func (ec2 *EC2) Snapshots(ids []string, filter *Filter) (resp *SnapshotsResp, err error) {
- params := makeParams("DescribeSnapshots")
- for i, id := range ids {
- params["SnapshotId."+strconv.Itoa(i+1)] = id
- }
- filter.addParams(params)
-
- resp = &SnapshotsResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ----------------------------------------------------------------------------
-// Volume management
-
-// The CreateVolume request parameters
-//
-// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html
-type CreateVolume struct {
- AvailZone string
- Size int64
- SnapshotId string
- VolumeType string
- IOPS int64
-}
-
-// Response to an AttachVolume request
-type AttachVolumeResp struct {
- RequestId string `xml:"requestId"`
- VolumeId string `xml:"volumeId"`
- InstanceId string `xml:"instanceId"`
- Device string `xml:"device"`
- Status string `xml:"status"`
- AttachTime string `xml:"attachTime"`
-}
-
-// Response to a CreateVolume request
-type CreateVolumeResp struct {
- RequestId string `xml:"requestId"`
- VolumeId string `xml:"volumeId"`
- Size int64 `xml:"size"`
- SnapshotId string `xml:"snapshotId"`
- AvailZone string `xml:"availabilityZone"`
- Status string `xml:"status"`
- CreateTime string `xml:"createTime"`
- VolumeType string `xml:"volumeType"`
- IOPS int64 `xml:"iops"`
-}
-
-// Volume is a single volume.
-type Volume struct {
- VolumeId string `xml:"volumeId"`
- Size string `xml:"size"`
- SnapshotId string `xml:"snapshotId"`
- AvailZone string `xml:"availabilityZone"`
- Status string `xml:"status"`
- Attachments []VolumeAttachment `xml:"attachmentSet>item"`
- VolumeType string `xml:"volumeType"`
- IOPS int64 `xml:"iops"`
- Tags []Tag `xml:"tagSet>item"`
-}
-
-type VolumeAttachment struct {
- VolumeId string `xml:"volumeId"`
- InstanceId string `xml:"instanceId"`
- Device string `xml:"device"`
- Status string `xml:"status"`
-}
-
-// Response to a DescribeVolumes request
-type VolumesResp struct {
- RequestId string `xml:"requestId"`
- Volumes []Volume `xml:"volumeSet>item"`
-}
-
-// Attach a volume.
-func (ec2 *EC2) AttachVolume(volumeId string, instanceId string, device string) (resp *AttachVolumeResp, err error) {
- params := makeParams("AttachVolume")
- params["VolumeId"] = volumeId
- params["InstanceId"] = instanceId
- params["Device"] = device
-
- resp = &AttachVolumeResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return resp, nil
-}
-
-// Create a new volume.
-func (ec2 *EC2) CreateVolume(options *CreateVolume) (resp *CreateVolumeResp, err error) {
- params := makeParams("CreateVolume")
- params["AvailabilityZone"] = options.AvailZone
- if options.Size > 0 {
- params["Size"] = strconv.FormatInt(options.Size, 10)
- }
-
- if options.SnapshotId != "" {
- params["SnapshotId"] = options.SnapshotId
- }
-
- if options.VolumeType != "" {
- params["VolumeType"] = options.VolumeType
- }
-
- if options.IOPS > 0 {
- params["Iops"] = strconv.FormatInt(options.IOPS, 10)
- }
-
- resp = &CreateVolumeResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Delete an EBS volume.
-func (ec2 *EC2) DeleteVolume(id string) (resp *SimpleResp, err error) {
- params := makeParams("DeleteVolume")
- params["VolumeId"] = id
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Detaches an EBS volume.
-func (ec2 *EC2) DetachVolume(id string) (resp *SimpleResp, err error) {
- params := makeParams("DetachVolume")
- params["VolumeId"] = id
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Finds or lists all volumes.
-func (ec2 *EC2) Volumes(volIds []string, filter *Filter) (resp *VolumesResp, err error) {
- params := makeParams("DescribeVolumes")
- addParamsList(params, "VolumeId", volIds)
- filter.addParams(params)
- resp = &VolumesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ----------------------------------------------------------------------------
-// Security group management functions and types.
-
-// SimpleResp represents a response to an EC2 request which on success will
-// return no other information besides a request id.
-type SimpleResp struct {
- XMLName xml.Name
- RequestId string `xml:"requestId"`
-}
-
-// CreateSecurityGroupResp represents a response to a CreateSecurityGroup request.
-type CreateSecurityGroupResp struct {
- SecurityGroup
- RequestId string `xml:"requestId"`
-}
-
-// CreateSecurityGroup run a CreateSecurityGroup request in EC2, with the provided
-// name and description.
-//
-// See http://goo.gl/Eo7Yl for more details.
-func (ec2 *EC2) CreateSecurityGroup(group SecurityGroup) (resp *CreateSecurityGroupResp, err error) {
- params := makeParams("CreateSecurityGroup")
- params["GroupName"] = group.Name
- params["GroupDescription"] = group.Description
- if group.VpcId != "" {
- params["VpcId"] = group.VpcId
- }
-
- resp = &CreateSecurityGroupResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- resp.Name = group.Name
- return resp, nil
-}
-
-// SecurityGroupsResp represents a response to a DescribeSecurityGroups
-// request in EC2.
-//
-// See http://goo.gl/k12Uy for more details.
-type SecurityGroupsResp struct {
- RequestId string `xml:"requestId"`
- Groups []SecurityGroupInfo `xml:"securityGroupInfo>item"`
-}
-
-// SecurityGroup encapsulates details for a security group in EC2.
-//
-// See http://goo.gl/CIdyP for more details.
-type SecurityGroupInfo struct {
- SecurityGroup
- OwnerId string `xml:"ownerId"`
- Description string `xml:"groupDescription"`
- IPPerms []IPPerm `xml:"ipPermissions>item"`
- IPPermsEgress []IPPerm `xml:"ipPermissionsEgress>item"`
-}
-
-// IPPerm represents an allowance within an EC2 security group.
-//
-// See http://goo.gl/4oTxv for more details.
-type IPPerm struct {
- Protocol string `xml:"ipProtocol"`
- FromPort int `xml:"fromPort"`
- ToPort int `xml:"toPort"`
- SourceIPs []string `xml:"ipRanges>item>cidrIp"`
- SourceGroups []UserSecurityGroup `xml:"groups>item"`
-}
-
-// UserSecurityGroup holds a security group and the owner
-// of that group.
-type UserSecurityGroup struct {
- Id string `xml:"groupId"`
- Name string `xml:"groupName"`
- OwnerId string `xml:"userId"`
-}
-
-// SecurityGroup represents an EC2 security group.
-// If SecurityGroup is used as a parameter, then one of Id or Name
-// may be empty. If both are set, then Id is used.
-type SecurityGroup struct {
- Id string `xml:"groupId"`
- Name string `xml:"groupName"`
- Description string `xml:"groupDescription"`
- VpcId string `xml:"vpcId"`
-}
-
-// SecurityGroupNames is a convenience function that
-// returns a slice of security groups with the given names.
-func SecurityGroupNames(names ...string) []SecurityGroup {
- g := make([]SecurityGroup, len(names))
- for i, name := range names {
- g[i] = SecurityGroup{Name: name}
- }
- return g
-}
-
-// SecurityGroupNames is a convenience function that
-// returns a slice of security groups with the given ids.
-func SecurityGroupIds(ids ...string) []SecurityGroup {
- g := make([]SecurityGroup, len(ids))
- for i, id := range ids {
- g[i] = SecurityGroup{Id: id}
- }
- return g
-}
-
-// SecurityGroups returns details about security groups in EC2. Both parameters
-// are optional, and if provided will limit the security groups returned to those
-// matching the given groups or filtering rules.
-//
-// See http://goo.gl/k12Uy for more details.
-func (ec2 *EC2) SecurityGroups(groups []SecurityGroup, filter *Filter) (resp *SecurityGroupsResp, err error) {
- params := makeParams("DescribeSecurityGroups")
- i, j := 1, 1
- for _, g := range groups {
- if g.Id != "" {
- params["GroupId."+strconv.Itoa(i)] = g.Id
- i++
- } else {
- params["GroupName."+strconv.Itoa(j)] = g.Name
- j++
- }
- }
- filter.addParams(params)
-
- resp = &SecurityGroupsResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteSecurityGroup removes the given security group in EC2.
-//
-// See http://goo.gl/QJJDO for more details.
-func (ec2 *EC2) DeleteSecurityGroup(group SecurityGroup) (resp *SimpleResp, err error) {
- params := makeParams("DeleteSecurityGroup")
- if group.Id != "" {
- params["GroupId"] = group.Id
- } else {
- params["GroupName"] = group.Name
- }
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// AuthorizeSecurityGroup creates an allowance for clients matching the provided
-// rules to access instances within the given security group.
-//
-// See http://goo.gl/u2sDJ for more details.
-func (ec2 *EC2) AuthorizeSecurityGroup(group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
- return ec2.authOrRevoke("AuthorizeSecurityGroupIngress", group, perms)
-}
-
-// RevokeSecurityGroup revokes permissions from a group.
-//
-// See http://goo.gl/ZgdxA for more details.
-func (ec2 *EC2) RevokeSecurityGroup(group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
- return ec2.authOrRevoke("RevokeSecurityGroupIngress", group, perms)
-}
-
-// AuthorizeSecurityGroupEgress creates an allowance for instances within the
-// given security group to access servers matching the provided rules.
-//
-// See http://goo.gl/R91LXY for more details.
-func (ec2 *EC2) AuthorizeSecurityGroupEgress(group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
- return ec2.authOrRevoke("AuthorizeSecurityGroupEgress", group, perms)
-}
-
-// RevokeSecurityGroupEgress revokes egress permissions from a group
-//
-// see http://goo.gl/Zv4wh8
-func (ec2 *EC2) RevokeSecurityGroupEgress(group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
- return ec2.authOrRevoke("RevokeSecurityGroupEgress", group, perms)
-}
-
-func (ec2 *EC2) authOrRevoke(op string, group SecurityGroup, perms []IPPerm) (resp *SimpleResp, err error) {
- params := makeParams(op)
- if group.Id != "" {
- params["GroupId"] = group.Id
- } else {
- params["GroupName"] = group.Name
- }
-
- for i, perm := range perms {
- prefix := "IpPermissions." + strconv.Itoa(i+1)
- params[prefix+".IpProtocol"] = perm.Protocol
- params[prefix+".FromPort"] = strconv.Itoa(perm.FromPort)
- params[prefix+".ToPort"] = strconv.Itoa(perm.ToPort)
- for j, ip := range perm.SourceIPs {
- params[prefix+".IpRanges."+strconv.Itoa(j+1)+".CidrIp"] = ip
- }
- for j, g := range perm.SourceGroups {
- subprefix := prefix + ".Groups." + strconv.Itoa(j+1)
- if g.OwnerId != "" {
- params[subprefix+".UserId"] = g.OwnerId
- }
- if g.Id != "" {
- params[subprefix+".GroupId"] = g.Id
- } else {
- params[subprefix+".GroupName"] = g.Name
- }
- }
- }
-
- resp = &SimpleResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ----------------------------------------------------------------------------
-// Elastic IP management functions and types.
-
-// Response to a DescribeAddresses request.
-//
-// See http://goo.gl/zW7J4p for more details.
-type DescribeAddressesResp struct {
- RequestId string `xml:"requestId"`
- Addresses []Address `xml:"addressesSet>item"`
-}
-
-// Address represents an Elastic IP Address
-// See http://goo.gl/uxCjp7 for more details
-type Address struct {
- PublicIp string `xml:"publicIp"`
- AllocationId string `xml:"allocationId"`
- Domain string `xml:"domain"`
- InstanceId string `xml:"instanceId"`
- AssociationId string `xml:"associationId"`
- NetworkInterfaceId string `xml:"networkInterfaceId"`
- NetworkInterfaceOwnerId string `xml:"networkInterfaceOwnerId"`
- PrivateIpAddress string `xml:"privateIpAddress"`
-}
-
-// DescribeAddresses returns details about one or more
-// Elastic IP Addresses. Returned addresses can be
-// filtered by Public IP, Allocation ID or multiple filters
-//
-// See http://goo.gl/zW7J4p for more details.
-func (ec2 *EC2) DescribeAddresses(publicIps []string, allocationIds []string, filter *Filter) (resp *DescribeAddressesResp, err error) {
- params := makeParams("DescribeAddresses")
- addParamsList(params, "PublicIp", publicIps)
- addParamsList(params, "AllocationId", allocationIds)
- filter.addParams(params)
- resp = &DescribeAddressesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// AllocateAddressOptions are request parameters for allocating an Elastic IP Address
-//
-// See http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html
-type AllocateAddressOptions struct {
- Domain string
-}
-
-// Response to an AllocateAddress request
-//
-// See http://goo.gl/aLPmbm for more details
-type AllocateAddressResp struct {
- RequestId string `xml:"requestId"`
- PublicIp string `xml:"publicIp"`
- Domain string `xml:"domain"`
- AllocationId string `xml:"allocationId"`
-}
-
-// Allocates a new Elastic IP address.
-// The domain parameter is optional and is used for provisioning an ip address
-// in EC2 or in VPC respectively
-//
-// See http://goo.gl/aLPmbm for more details
-func (ec2 *EC2) AllocateAddress(options *AllocateAddressOptions) (resp *AllocateAddressResp, err error) {
- params := makeParams("AllocateAddress")
- params["Domain"] = options.Domain
- resp = &AllocateAddressResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to a ReleaseAddress request
-//
-// See http://goo.gl/Ciw2Z8 for more details
-type ReleaseAddressResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"`
-}
-
-// Release existing elastic ip address from the account
-// PublicIp = Required for EC2
-// AllocationId = Required for VPC
-//
-// See http://goo.gl/Ciw2Z8 for more details
-func (ec2 *EC2) ReleaseAddress(publicIp, allocationId string) (resp *ReleaseAddressResp, err error) {
- params := makeParams("ReleaseAddress")
-
- if publicIp != "" {
- params["PublicIp"] = publicIp
-
- }
- if allocationId != "" {
- params["AllocationId"] = allocationId
- }
-
- resp = &ReleaseAddressResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Options set for AssociateAddress
-//
-// See http://goo.gl/hhj4z7 for more details
-type AssociateAddressOptions struct {
- PublicIp string
- InstanceId string
- AllocationId string
- NetworkInterfaceId string
- PrivateIpAddress string
- AllowReassociation bool
-}
-
-// Response to an AssociateAddress request
-//
-// See http://goo.gl/hhj4z7 for more details
-type AssociateAddressResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"`
- AssociationId string `xml:"associationId"`
-}
-
-// Associate an Elastic ip address to an instance id or a network interface
-//
-// See http://goo.gl/hhj4z7 for more details
-func (ec2 *EC2) AssociateAddress(options *AssociateAddressOptions) (resp *AssociateAddressResp, err error) {
- params := makeParams("AssociateAddress")
- params["InstanceId"] = options.InstanceId
- if options.PublicIp != "" {
- params["PublicIp"] = options.PublicIp
- }
- if options.AllocationId != "" {
- params["AllocationId"] = options.AllocationId
- }
- if options.NetworkInterfaceId != "" {
- params["NetworkInterfaceId"] = options.NetworkInterfaceId
- }
- if options.PrivateIpAddress != "" {
- params["PrivateIpAddress"] = options.PrivateIpAddress
- }
- if options.AllowReassociation {
- params["AllowReassociation"] = "true"
- }
-
- resp = &AssociateAddressResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to a Disassociate Address request
-//
-// See http://goo.gl/Dapkuzfor more details
-type DisassociateAddressResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"`
-}
-
-// Disassociate an elastic ip address from an instance
-// PublicIp - Required for EC2
-// AssociationId - Required for VPC
-// See http://goo.gl/Dapkuz for more details
-func (ec2 *EC2) DisassociateAddress(publicIp, associationId string) (resp *DisassociateAddressResp, err error) {
- params := makeParams("DisassociateAddress")
- if publicIp != "" {
- params["PublicIp"] = publicIp
- }
- if associationId != "" {
- params["AssociationId"] = associationId
- }
-
- resp = &DisassociateAddressResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/ec2_test.go b/vendor/github.com/goamz/goamz/ec2/ec2_test.go
deleted file mode 100644
index 3ca3a220d..000000000
--- a/vendor/github.com/goamz/goamz/ec2/ec2_test.go
+++ /dev/null
@@ -1,1280 +0,0 @@
-package ec2_test
-
-import (
- "testing"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/ec2"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- ec2 *ec2.EC2
-}
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.ec2 = ec2.NewWithClient(
- auth,
- aws.Region{EC2Endpoint: testServer.URL},
- testutil.DefaultClient,
- )
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestRunInstancesErrorDump(c *C) {
- testServer.Response(400, nil, ErrorDump)
-
- options := ec2.RunInstancesOptions{
- ImageId: "ami-a6f504cf", // Ubuntu Maverick, i386, instance store
- InstanceType: "t1.micro", // Doesn't work with micro, results in 400.
- }
-
- msg := `AMIs with an instance-store root device are not supported for the instance type 't1\.micro'\.`
-
- resp, err := s.ec2.RunInstances(&options)
-
- testServer.WaitRequest()
-
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, msg+` \(UnsupportedOperation\)`)
-
- ec2err, ok := err.(*ec2.Error)
- c.Assert(ok, Equals, true)
- c.Assert(ec2err.StatusCode, Equals, 400)
- c.Assert(ec2err.Code, Equals, "UnsupportedOperation")
- c.Assert(ec2err.Message, Matches, msg)
- c.Assert(ec2err.RequestId, Equals, "0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4")
-}
-
-func (s *S) TestRequestSpotInstancesErrorDump(c *C) {
- testServer.Response(400, nil, ErrorDump)
-
- options := ec2.RequestSpotInstances{
- SpotPrice: "0.01",
- ImageId: "ami-a6f504cf", // Ubuntu Maverick, i386, instance store
- InstanceType: "t1.micro", // Doesn't work with micro, results in 400.
- }
-
- msg := `AMIs with an instance-store root device are not supported for the instance type 't1\.micro'\.`
-
- resp, err := s.ec2.RequestSpotInstances(&options)
-
- testServer.WaitRequest()
-
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, msg+` \(UnsupportedOperation\)`)
-
- ec2err, ok := err.(*ec2.Error)
- c.Assert(ok, Equals, true)
- c.Assert(ec2err.StatusCode, Equals, 400)
- c.Assert(ec2err.Code, Equals, "UnsupportedOperation")
- c.Assert(ec2err.Message, Matches, msg)
- c.Assert(ec2err.RequestId, Equals, "0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4")
-}
-
-func (s *S) TestRunInstancesErrorWithoutXML(c *C) {
- testServer.Responses(5, 500, nil, "")
- options := ec2.RunInstancesOptions{ImageId: "image-id"}
-
- resp, err := s.ec2.RunInstances(&options)
-
- testServer.WaitRequest()
-
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, "500 Internal Server Error")
-
- ec2err, ok := err.(*ec2.Error)
- c.Assert(ok, Equals, true)
- c.Assert(ec2err.StatusCode, Equals, 500)
- c.Assert(ec2err.Code, Equals, "")
- c.Assert(ec2err.Message, Equals, "500 Internal Server Error")
- c.Assert(ec2err.RequestId, Equals, "")
-}
-
-func (s *S) TestRequestSpotInstancesErrorWithoutXML(c *C) {
- testServer.Responses(5, 500, nil, "")
- options := ec2.RequestSpotInstances{SpotPrice: "spot-price", ImageId: "image-id"}
-
- resp, err := s.ec2.RequestSpotInstances(&options)
-
- testServer.WaitRequest()
-
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, "500 Internal Server Error")
-
- ec2err, ok := err.(*ec2.Error)
- c.Assert(ok, Equals, true)
- c.Assert(ec2err.StatusCode, Equals, 500)
- c.Assert(ec2err.Code, Equals, "")
- c.Assert(ec2err.Message, Equals, "500 Internal Server Error")
- c.Assert(ec2err.RequestId, Equals, "")
-}
-
-func (s *S) TestRunInstancesExample(c *C) {
- testServer.Response(200, nil, RunInstancesExample)
-
- options := ec2.RunInstancesOptions{
- KeyName: "my-keys",
- ImageId: "image-id",
- InstanceType: "inst-type",
- SecurityGroups: []ec2.SecurityGroup{{Name: "g1"}, {Id: "g2"}, {Name: "g3"}, {Id: "g4"}},
- UserData: []byte("1234"),
- KernelId: "kernel-id",
- RamdiskId: "ramdisk-id",
- AvailabilityZone: "zone",
- PlacementGroupName: "group",
- Monitoring: true,
- SubnetId: "subnet-id",
- DisableAPITermination: true,
- ShutdownBehavior: "terminate",
- PrivateIPAddress: "10.0.0.25",
- BlockDevices: []ec2.BlockDeviceMapping{
- {DeviceName: "/dev/sdb", VirtualName: "ephemeral0"},
- {DeviceName: "/dev/sdc", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
- },
- }
- resp, err := s.ec2.RunInstances(&options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"RunInstances"})
- c.Assert(req.Form["ImageId"], DeepEquals, []string{"image-id"})
- c.Assert(req.Form["MinCount"], DeepEquals, []string{"1"})
- c.Assert(req.Form["MaxCount"], DeepEquals, []string{"1"})
- c.Assert(req.Form["KeyName"], DeepEquals, []string{"my-keys"})
- c.Assert(req.Form["InstanceType"], DeepEquals, []string{"inst-type"})
- c.Assert(req.Form["SecurityGroup.1"], DeepEquals, []string{"g1"})
- c.Assert(req.Form["SecurityGroup.2"], DeepEquals, []string{"g3"})
- c.Assert(req.Form["SecurityGroupId.1"], DeepEquals, []string{"g2"})
- c.Assert(req.Form["SecurityGroupId.2"], DeepEquals, []string{"g4"})
- c.Assert(req.Form["UserData"], DeepEquals, []string{"MTIzNA=="})
- c.Assert(req.Form["KernelId"], DeepEquals, []string{"kernel-id"})
- c.Assert(req.Form["RamdiskId"], DeepEquals, []string{"ramdisk-id"})
- c.Assert(req.Form["Placement.AvailabilityZone"], DeepEquals, []string{"zone"})
- c.Assert(req.Form["Placement.GroupName"], DeepEquals, []string{"group"})
- c.Assert(req.Form["Monitoring.Enabled"], DeepEquals, []string{"true"})
- c.Assert(req.Form["SubnetId"], DeepEquals, []string{"subnet-id"})
- c.Assert(req.Form["DisableApiTermination"], DeepEquals, []string{"true"})
- c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], DeepEquals, []string{"terminate"})
- c.Assert(req.Form["PrivateIpAddress"], DeepEquals, []string{"10.0.0.25"})
- c.Assert(req.Form["BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sdb"})
- c.Assert(req.Form["BlockDeviceMapping.1.VirtualName"], DeepEquals, []string{"ephemeral0"})
- c.Assert(req.Form["BlockDeviceMapping.2.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
- c.Assert(req.Form["BlockDeviceMapping.2.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.ReservationId, Equals, "r-47a5402e")
- c.Assert(resp.OwnerId, Equals, "999988887777")
- c.Assert(resp.SecurityGroups, DeepEquals, []ec2.SecurityGroup{{Name: "default", Id: "sg-67ad940e"}})
- c.Assert(resp.Instances, HasLen, 3)
-
- i0 := resp.Instances[0]
- c.Assert(i0.InstanceId, Equals, "i-2ba64342")
- c.Assert(i0.InstanceType, Equals, "m1.small")
- c.Assert(i0.ImageId, Equals, "ami-60a54009")
- c.Assert(i0.Monitoring, Equals, "enabled")
- c.Assert(i0.KeyName, Equals, "example-key-name")
- c.Assert(i0.AMILaunchIndex, Equals, 0)
- c.Assert(i0.VirtualizationType, Equals, "paravirtual")
- c.Assert(i0.Hypervisor, Equals, "xen")
-
- i1 := resp.Instances[1]
- c.Assert(i1.InstanceId, Equals, "i-2bc64242")
- c.Assert(i1.InstanceType, Equals, "m1.small")
- c.Assert(i1.ImageId, Equals, "ami-60a54009")
- c.Assert(i1.Monitoring, Equals, "enabled")
- c.Assert(i1.KeyName, Equals, "example-key-name")
- c.Assert(i1.AMILaunchIndex, Equals, 1)
- c.Assert(i1.VirtualizationType, Equals, "paravirtual")
- c.Assert(i1.Hypervisor, Equals, "xen")
-
- i2 := resp.Instances[2]
- c.Assert(i2.InstanceId, Equals, "i-2be64332")
- c.Assert(i2.InstanceType, Equals, "m1.small")
- c.Assert(i2.ImageId, Equals, "ami-60a54009")
- c.Assert(i2.Monitoring, Equals, "enabled")
- c.Assert(i2.KeyName, Equals, "example-key-name")
- c.Assert(i2.AMILaunchIndex, Equals, 2)
- c.Assert(i2.VirtualizationType, Equals, "paravirtual")
- c.Assert(i2.Hypervisor, Equals, "xen")
-}
-
-func (s *S) TestRequestSpotInstancesExample(c *C) {
- testServer.Response(200, nil, RequestSpotInstancesExample)
-
- options := ec2.RequestSpotInstances{
- SpotPrice: "0.5",
- KeyName: "my-keys",
- ImageId: "image-id",
- InstanceType: "inst-type",
- SecurityGroups: []ec2.SecurityGroup{{Name: "g1"}, {Id: "g2"}, {Name: "g3"}, {Id: "g4"}},
- UserData: []byte("1234"),
- KernelId: "kernel-id",
- RamdiskId: "ramdisk-id",
- AvailZone: "zone",
- PlacementGroupName: "group",
- Monitoring: true,
- SubnetId: "subnet-id",
- PrivateIPAddress: "10.0.0.25",
- BlockDevices: []ec2.BlockDeviceMapping{
- {DeviceName: "/dev/sdb", VirtualName: "ephemeral0"},
- {DeviceName: "/dev/sdc", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
- },
- }
- resp, err := s.ec2.RequestSpotInstances(&options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"RequestSpotInstances"})
- c.Assert(req.Form["SpotPrice"], DeepEquals, []string{"0.5"})
- c.Assert(req.Form["LaunchSpecification.ImageId"], DeepEquals, []string{"image-id"})
- c.Assert(req.Form["LaunchSpecification.KeyName"], DeepEquals, []string{"my-keys"})
- c.Assert(req.Form["LaunchSpecification.InstanceType"], DeepEquals, []string{"inst-type"})
- c.Assert(req.Form["LaunchSpecification.SecurityGroup.1"], DeepEquals, []string{"g1"})
- c.Assert(req.Form["LaunchSpecification.SecurityGroup.2"], DeepEquals, []string{"g3"})
- c.Assert(req.Form["LaunchSpecification.SecurityGroupId.1"], DeepEquals, []string{"g2"})
- c.Assert(req.Form["LaunchSpecification.SecurityGroupId.2"], DeepEquals, []string{"g4"})
- c.Assert(req.Form["LaunchSpecification.UserData"], DeepEquals, []string{"MTIzNA=="})
- c.Assert(req.Form["LaunchSpecification.KernelId"], DeepEquals, []string{"kernel-id"})
- c.Assert(req.Form["LaunchSpecification.RamdiskId"], DeepEquals, []string{"ramdisk-id"})
- c.Assert(req.Form["LaunchSpecification.Placement.AvailabilityZone"], DeepEquals, []string{"zone"})
- c.Assert(req.Form["LaunchSpecification.Placement.GroupName"], DeepEquals, []string{"group"})
- c.Assert(req.Form["LaunchSpecification.Monitoring.Enabled"], DeepEquals, []string{"true"})
- c.Assert(req.Form["LaunchSpecification.SubnetId"], DeepEquals, []string{"subnet-id"})
- c.Assert(req.Form["LaunchSpecification.PrivateIpAddress"], DeepEquals, []string{"10.0.0.25"})
- c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sdb"})
- c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.1.VirtualName"], DeepEquals, []string{"ephemeral0"})
- c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.2.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
- c.Assert(req.Form["LaunchSpecification.BlockDeviceMapping.2.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.SpotRequestResults[0].SpotRequestId, Equals, "sir-1a2b3c4d")
- c.Assert(resp.SpotRequestResults[0].SpotPrice, Equals, "0.5")
- c.Assert(resp.SpotRequestResults[0].State, Equals, "open")
- c.Assert(resp.SpotRequestResults[0].SpotLaunchSpec.ImageId, Equals, "ami-1a2b3c4d")
-}
-
-func (s *S) TestCancelSpotRequestsExample(c *C) {
- testServer.Response(200, nil, CancelSpotRequestsExample)
-
- resp, err := s.ec2.CancelSpotRequests([]string{"s-1", "s-2"})
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"CancelSpotInstanceRequests"})
- c.Assert(req.Form["SpotInstanceRequestId.1"], DeepEquals, []string{"s-1"})
- c.Assert(req.Form["SpotInstanceRequestId.2"], DeepEquals, []string{"s-2"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.CancelSpotRequestResults[0].SpotRequestId, Equals, "sir-1a2b3c4d")
- c.Assert(resp.CancelSpotRequestResults[0].State, Equals, "cancelled")
-}
-
-func (s *S) TestTerminateInstancesExample(c *C) {
- testServer.Response(200, nil, TerminateInstancesExample)
-
- resp, err := s.ec2.TerminateInstances([]string{"i-1", "i-2"})
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"TerminateInstances"})
- c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"})
- c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"})
- c.Assert(req.Form["UserData"], IsNil)
- c.Assert(req.Form["KernelId"], IsNil)
- c.Assert(req.Form["RamdiskId"], IsNil)
- c.Assert(req.Form["Placement.AvailabilityZone"], IsNil)
- c.Assert(req.Form["Placement.GroupName"], IsNil)
- c.Assert(req.Form["Monitoring.Enabled"], IsNil)
- c.Assert(req.Form["SubnetId"], IsNil)
- c.Assert(req.Form["DisableApiTermination"], IsNil)
- c.Assert(req.Form["InstanceInitiatedShutdownBehavior"], IsNil)
- c.Assert(req.Form["PrivateIpAddress"], IsNil)
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.StateChanges, HasLen, 1)
- c.Assert(resp.StateChanges[0].InstanceId, Equals, "i-3ea74257")
- c.Assert(resp.StateChanges[0].CurrentState.Code, Equals, 32)
- c.Assert(resp.StateChanges[0].CurrentState.Name, Equals, "shutting-down")
- c.Assert(resp.StateChanges[0].PreviousState.Code, Equals, 16)
- c.Assert(resp.StateChanges[0].PreviousState.Name, Equals, "running")
-}
-
-func (s *S) TestDescribeSpotRequestsExample(c *C) {
- testServer.Response(200, nil, DescribeSpotRequestsExample)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.DescribeSpotRequests([]string{"s-1", "s-2"}, filter)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSpotInstanceRequests"})
- c.Assert(req.Form["SpotInstanceRequestId.1"], DeepEquals, []string{"s-1"})
- c.Assert(req.Form["SpotInstanceRequestId.2"], DeepEquals, []string{"s-2"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "b1719f2a-5334-4479-b2f1-26926EXAMPLE")
- c.Assert(resp.SpotRequestResults[0].SpotRequestId, Equals, "sir-1a2b3c4d")
- c.Assert(resp.SpotRequestResults[0].State, Equals, "active")
- c.Assert(resp.SpotRequestResults[0].SpotPrice, Equals, "0.5")
- c.Assert(resp.SpotRequestResults[0].SpotLaunchSpec.ImageId, Equals, "ami-1a2b3c4d")
-}
-
-func (s *S) TestDescribeInstancesExample1(c *C) {
- testServer.Response(200, nil, DescribeInstancesExample1)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.DescribeInstances([]string{"i-1", "i-2"}, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstances"})
- c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"})
- c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "98e3c9a4-848c-4d6d-8e8a-b1bdEXAMPLE")
- c.Assert(resp.Reservations, HasLen, 2)
-
- r0 := resp.Reservations[0]
- c.Assert(r0.ReservationId, Equals, "r-b27e30d9")
- c.Assert(r0.OwnerId, Equals, "999988887777")
- c.Assert(r0.RequesterId, Equals, "854251627541")
- c.Assert(r0.SecurityGroups, DeepEquals, []ec2.SecurityGroup{{Name: "default", Id: "sg-67ad940e"}})
- c.Assert(r0.Instances, HasLen, 1)
-
- r0i := r0.Instances[0]
- c.Assert(r0i.InstanceId, Equals, "i-c5cd56af")
- c.Assert(r0i.PrivateDNSName, Equals, "domU-12-31-39-10-56-34.compute-1.internal")
- c.Assert(r0i.DNSName, Equals, "ec2-174-129-165-232.compute-1.amazonaws.com")
- c.Assert(r0i.AvailabilityZone, Equals, "us-east-1b")
- c.Assert(r0i.IPAddress, Equals, "174.129.165.232")
- c.Assert(r0i.PrivateIPAddress, Equals, "10.198.85.190")
-}
-
-func (s *S) TestDescribeInstancesExample2(c *C) {
- testServer.Response(200, nil, DescribeInstancesExample2)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.DescribeInstances([]string{"i-1", "i-2"}, filter)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstances"})
- c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-1"})
- c.Assert(req.Form["InstanceId.2"], DeepEquals, []string{"i-2"})
- c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
- c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
- c.Assert(req.Form["Filter.1.Value.2"], IsNil)
- c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
- c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
- c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Reservations, HasLen, 1)
-
- r0 := resp.Reservations[0]
- r0i := r0.Instances[0]
- c.Assert(r0i.State.Code, Equals, 16)
- c.Assert(r0i.State.Name, Equals, "running")
-
- r0t0 := r0i.Tags[0]
- r0t1 := r0i.Tags[1]
- c.Assert(r0t0.Key, Equals, "webserver")
- c.Assert(r0t0.Value, Equals, "")
- c.Assert(r0t1.Key, Equals, "stack")
- c.Assert(r0t1.Value, Equals, "Production")
-}
-
-func (s *S) TestDescribeInstanceStatusExample(c *C) {
- testServer.Response(200, nil, DescribeInstanceStatusExample)
-
- resp, err := s.ec2.DescribeInstanceStatus(&ec2.DescribeInstanceStatusOptions{}, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeInstanceStatus"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.InstanceStatusSet, HasLen, 1)
- c.Assert(resp.NextToken, Equals, "exampleToken")
-
- i0 := resp.InstanceStatusSet[0]
- c.Assert(i0.InstanceId, Equals, "i-c7cd56ad")
- c.Assert(i0.AvailabilityZone, Equals, "us-east-1b")
- c.Assert(i0.Events, HasLen, 1)
-
- e0 := i0.Events[0]
- c.Assert(e0.Code, Equals, "instance-reboot")
- c.Assert(e0.Description, Equals, "example description")
- c.Assert(e0.NotBefore, Equals, "2010-08-17T01:15:18.000Z")
- c.Assert(e0.NotAfter, Equals, "2010-08-17T01:15:18.000Z")
-
- c.Assert(i0.InstanceState.Code, Equals, 16)
- c.Assert(i0.InstanceState.Name, Equals, "running")
- c.Assert(i0.SystemStatus.Status, Equals, "ok")
- c.Assert(i0.SystemStatus.Details.Name, Equals, "reachability")
- c.Assert(i0.SystemStatus.Details.Status, Equals, "passed")
- c.Assert(i0.SystemStatus.Details.ImpairedSince, Equals, "2010-08-17T01:15:18.000Z")
- c.Assert(i0.InstanceStatus.Status, Equals, "ok")
- c.Assert(i0.InstanceStatus.Details.Name, Equals, "reachability")
- c.Assert(i0.InstanceStatus.Details.Status, Equals, "passed")
- c.Assert(i0.InstanceStatus.Details.ImpairedSince, Equals, "2010-08-17T01:15:18.000Z")
-}
-
-func (s *S) TestDescribeAddressesPublicIPExample(c *C) {
- testServer.Response(200, nil, DescribeAddressesExample)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.DescribeAddresses([]string{"192.0.2.1", "198.51.100.2", "203.0.113.41"}, []string{}, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeAddresses"})
- c.Assert(req.Form["PublicIp.1"], DeepEquals, []string{"192.0.2.1"})
- c.Assert(req.Form["PublicIp.2"], DeepEquals, []string{"198.51.100.2"})
- c.Assert(req.Form["PublicIp.3"], DeepEquals, []string{"203.0.113.41"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Addresses, HasLen, 3)
-
- r0 := resp.Addresses[0]
- c.Assert(r0.PublicIp, Equals, "192.0.2.1")
- c.Assert(r0.Domain, Equals, "standard")
- c.Assert(r0.InstanceId, Equals, "i-f15ebb98")
-
- r0i := resp.Addresses[1]
- c.Assert(r0i.PublicIp, Equals, "198.51.100.2")
- c.Assert(r0i.Domain, Equals, "standard")
- c.Assert(r0i.InstanceId, Equals, "")
-
- r0ii := resp.Addresses[2]
- c.Assert(r0ii.PublicIp, Equals, "203.0.113.41")
- c.Assert(r0ii.Domain, Equals, "vpc")
- c.Assert(r0ii.InstanceId, Equals, "i-64600030")
- c.Assert(r0ii.AssociationId, Equals, "eipassoc-f0229899")
- c.Assert(r0ii.AllocationId, Equals, "eipalloc-08229861")
- c.Assert(r0ii.NetworkInterfaceOwnerId, Equals, "053230519467")
- c.Assert(r0ii.NetworkInterfaceId, Equals, "eni-ef229886")
- c.Assert(r0ii.PrivateIpAddress, Equals, "10.0.0.228")
-}
-
-func (s *S) TestDescribeAddressesAllocationIDExample(c *C) {
- testServer.Response(200, nil, DescribeAddressesAllocationIdExample)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.DescribeAddresses([]string{}, []string{"eipalloc-08229861", "eipalloc-08364752"}, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeAddresses"})
- c.Assert(req.Form["AllocationId.1"], DeepEquals, []string{"eipalloc-08229861"})
- c.Assert(req.Form["AllocationId.2"], DeepEquals, []string{"eipalloc-08364752"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Addresses, HasLen, 2)
-
- r0 := resp.Addresses[0]
- c.Assert(r0.PublicIp, Equals, "203.0.113.41")
- c.Assert(r0.AllocationId, Equals, "eipalloc-08229861")
- c.Assert(r0.Domain, Equals, "vpc")
- c.Assert(r0.InstanceId, Equals, "i-64600030")
- c.Assert(r0.AssociationId, Equals, "eipassoc-f0229899")
- c.Assert(r0.NetworkInterfaceId, Equals, "eni-ef229886")
- c.Assert(r0.NetworkInterfaceOwnerId, Equals, "053230519467")
- c.Assert(r0.PrivateIpAddress, Equals, "10.0.0.228")
-
- r1 := resp.Addresses[1]
- c.Assert(r1.PublicIp, Equals, "146.54.2.230")
- c.Assert(r1.AllocationId, Equals, "eipalloc-08364752")
- c.Assert(r1.Domain, Equals, "vpc")
- c.Assert(r1.InstanceId, Equals, "i-64693456")
- c.Assert(r1.AssociationId, Equals, "eipassoc-f0348693")
- c.Assert(r1.NetworkInterfaceId, Equals, "eni-da764039")
- c.Assert(r1.NetworkInterfaceOwnerId, Equals, "053230519467")
- c.Assert(r1.PrivateIpAddress, Equals, "10.0.0.102")
-}
-
-func (s *S) TestCreateImageExample(c *C) {
- testServer.Response(200, nil, CreateImageExample)
-
- options := &ec2.CreateImage{
- InstanceId: "i-123456",
- Name: "foo",
- Description: "Test CreateImage",
- NoReboot: true,
- BlockDevices: []ec2.BlockDeviceMapping{
- {DeviceName: "/dev/sdb", VirtualName: "ephemeral0"},
- {DeviceName: "/dev/sdc", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
- },
- }
-
- resp, err := s.ec2.CreateImage(options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"CreateImage"})
- c.Assert(req.Form["InstanceId"], DeepEquals, []string{options.InstanceId})
- c.Assert(req.Form["Name"], DeepEquals, []string{options.Name})
- c.Assert(req.Form["Description"], DeepEquals, []string{options.Description})
- c.Assert(req.Form["NoReboot"], DeepEquals, []string{"true"})
- c.Assert(req.Form["BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sdb"})
- c.Assert(req.Form["BlockDeviceMapping.1.VirtualName"], DeepEquals, []string{"ephemeral0"})
- c.Assert(req.Form["BlockDeviceMapping.2.DeviceName"], DeepEquals, []string{"/dev/sdc"})
- c.Assert(req.Form["BlockDeviceMapping.2.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
- c.Assert(req.Form["BlockDeviceMapping.2.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.ImageId, Equals, "ami-4fa54026")
-}
-
-func (s *S) TestDescribeImagesExample(c *C) {
- testServer.Response(200, nil, DescribeImagesExample)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.Images([]string{"ami-1", "ami-2"}, filter)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeImages"})
- c.Assert(req.Form["ImageId.1"], DeepEquals, []string{"ami-1"})
- c.Assert(req.Form["ImageId.2"], DeepEquals, []string{"ami-2"})
- c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
- c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
- c.Assert(req.Form["Filter.1.Value.2"], IsNil)
- c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
- c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
- c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "4a4a27a2-2e7c-475d-b35b-ca822EXAMPLE")
- c.Assert(resp.Images, HasLen, 1)
-
- i0 := resp.Images[0]
- c.Assert(i0.Id, Equals, "ami-a2469acf")
- c.Assert(i0.Type, Equals, "machine")
- c.Assert(i0.Name, Equals, "example-marketplace-amzn-ami.1")
- c.Assert(i0.Description, Equals, "Amazon Linux AMI i386 EBS")
- c.Assert(i0.Location, Equals, "aws-marketplace/example-marketplace-amzn-ami.1")
- c.Assert(i0.State, Equals, "available")
- c.Assert(i0.Public, Equals, true)
- c.Assert(i0.OwnerId, Equals, "123456789999")
- c.Assert(i0.OwnerAlias, Equals, "aws-marketplace")
- c.Assert(i0.Architecture, Equals, "i386")
- c.Assert(i0.KernelId, Equals, "aki-805ea7e9")
- c.Assert(i0.RootDeviceType, Equals, "ebs")
- c.Assert(i0.RootDeviceName, Equals, "/dev/sda1")
- c.Assert(i0.VirtualizationType, Equals, "paravirtual")
- c.Assert(i0.Hypervisor, Equals, "xen")
-
- c.Assert(i0.Tags, HasLen, 1)
- c.Assert(i0.Tags[0].Key, Equals, "Purpose")
- c.Assert(i0.Tags[0].Value, Equals, "EXAMPLE")
-
- c.Assert(i0.BlockDevices, HasLen, 1)
- c.Assert(i0.BlockDevices[0].DeviceName, Equals, "/dev/sda1")
- c.Assert(i0.BlockDevices[0].SnapshotId, Equals, "snap-787e9403")
- c.Assert(i0.BlockDevices[0].VolumeSize, Equals, int64(8))
- c.Assert(i0.BlockDevices[0].DeleteOnTermination, Equals, true)
-
- testServer.Response(200, nil, DescribeImagesExample)
- resp2, err := s.ec2.ImagesByOwners([]string{"ami-1", "ami-2"}, []string{"123456789999", "id2"}, filter)
-
- req2 := testServer.WaitRequest()
- c.Assert(req2.Form["Action"], DeepEquals, []string{"DescribeImages"})
- c.Assert(req2.Form["ImageId.1"], DeepEquals, []string{"ami-1"})
- c.Assert(req2.Form["ImageId.2"], DeepEquals, []string{"ami-2"})
- c.Assert(req2.Form["Owner.1"], DeepEquals, []string{"123456789999"})
- c.Assert(req2.Form["Owner.2"], DeepEquals, []string{"id2"})
- c.Assert(req2.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
- c.Assert(req2.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
- c.Assert(req2.Form["Filter.1.Value.2"], IsNil)
- c.Assert(req2.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
- c.Assert(req2.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
- c.Assert(req2.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
-
- c.Assert(err, IsNil)
- c.Assert(resp2.RequestId, Equals, "4a4a27a2-2e7c-475d-b35b-ca822EXAMPLE")
- c.Assert(resp2.Images, HasLen, 1)
-
- i1 := resp2.Images[0]
- c.Assert(i1.Id, Equals, "ami-a2469acf")
- c.Assert(i1.Type, Equals, "machine")
- c.Assert(i1.Name, Equals, "example-marketplace-amzn-ami.1")
- c.Assert(i1.Description, Equals, "Amazon Linux AMI i386 EBS")
- c.Assert(i1.Location, Equals, "aws-marketplace/example-marketplace-amzn-ami.1")
- c.Assert(i1.State, Equals, "available")
- c.Assert(i1.Public, Equals, true)
- c.Assert(i1.OwnerId, Equals, "123456789999")
- c.Assert(i1.OwnerAlias, Equals, "aws-marketplace")
- c.Assert(i1.Architecture, Equals, "i386")
- c.Assert(i1.KernelId, Equals, "aki-805ea7e9")
- c.Assert(i1.RootDeviceType, Equals, "ebs")
- c.Assert(i1.RootDeviceName, Equals, "/dev/sda1")
- c.Assert(i1.VirtualizationType, Equals, "paravirtual")
- c.Assert(i1.Hypervisor, Equals, "xen")
-
- c.Assert(i1.BlockDevices, HasLen, 1)
- c.Assert(i1.BlockDevices[0].DeviceName, Equals, "/dev/sda1")
- c.Assert(i1.BlockDevices[0].SnapshotId, Equals, "snap-787e9403")
- c.Assert(i1.BlockDevices[0].VolumeSize, Equals, int64(8))
- c.Assert(i1.BlockDevices[0].DeleteOnTermination, Equals, true)
-}
-
-func (s *S) TestImageAttributeExample(c *C) {
- testServer.Response(200, nil, ImageAttributeExample)
-
- resp, err := s.ec2.ImageAttribute("ami-61a54008", "launchPermission")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeImageAttribute"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.ImageId, Equals, "ami-61a54008")
- c.Assert(resp.Group, Equals, "all")
- c.Assert(resp.UserIds[0], Equals, "495219933132")
-}
-
-func (s *S) TestCreateSnapshotExample(c *C) {
- testServer.Response(200, nil, CreateSnapshotExample)
-
- resp, err := s.ec2.CreateSnapshot("vol-4d826724", "Daily Backup")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"CreateSnapshot"})
- c.Assert(req.Form["VolumeId"], DeepEquals, []string{"vol-4d826724"})
- c.Assert(req.Form["Description"], DeepEquals, []string{"Daily Backup"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Snapshot.Id, Equals, "snap-78a54011")
- c.Assert(resp.Snapshot.VolumeId, Equals, "vol-4d826724")
- c.Assert(resp.Snapshot.Status, Equals, "pending")
- c.Assert(resp.Snapshot.StartTime, Equals, "2008-05-07T12:51:50.000Z")
- c.Assert(resp.Snapshot.Progress, Equals, "60%")
- c.Assert(resp.Snapshot.OwnerId, Equals, "111122223333")
- c.Assert(resp.Snapshot.VolumeSize, Equals, "10")
- c.Assert(resp.Snapshot.Description, Equals, "Daily Backup")
-}
-
-func (s *S) TestDeleteSnapshotsExample(c *C) {
- testServer.Response(200, nil, DeleteSnapshotExample)
-
- resp, err := s.ec2.DeleteSnapshots([]string{"snap-78a54011"})
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteSnapshot"})
- c.Assert(req.Form["SnapshotId.1"], DeepEquals, []string{"snap-78a54011"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestDescribeSnapshotsExample(c *C) {
- testServer.Response(200, nil, DescribeSnapshotsExample)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.Snapshots([]string{"snap-1", "snap-2"}, filter)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSnapshots"})
- c.Assert(req.Form["SnapshotId.1"], DeepEquals, []string{"snap-1"})
- c.Assert(req.Form["SnapshotId.2"], DeepEquals, []string{"snap-2"})
- c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
- c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
- c.Assert(req.Form["Filter.1.Value.2"], IsNil)
- c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
- c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
- c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Snapshots, HasLen, 1)
-
- s0 := resp.Snapshots[0]
- c.Assert(s0.Id, Equals, "snap-1a2b3c4d")
- c.Assert(s0.VolumeId, Equals, "vol-8875daef")
- c.Assert(s0.VolumeSize, Equals, "15")
- c.Assert(s0.Status, Equals, "pending")
- c.Assert(s0.StartTime, Equals, "2010-07-29T04:12:01.000Z")
- c.Assert(s0.Progress, Equals, "30%")
- c.Assert(s0.OwnerId, Equals, "111122223333")
- c.Assert(s0.Description, Equals, "Daily Backup")
-
- c.Assert(s0.Tags, HasLen, 1)
- c.Assert(s0.Tags[0].Key, Equals, "Purpose")
- c.Assert(s0.Tags[0].Value, Equals, "demo_db_14_backup")
-}
-
-func (s *S) TestModifyImageAttributeExample(c *C) {
- testServer.Response(200, nil, ModifyImageAttributeExample)
-
- options := ec2.ModifyImageAttribute{
- Description: "Test Description",
- }
-
- resp, err := s.ec2.ModifyImageAttribute("ami-4fa54026", &options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"ModifyImageAttribute"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestModifyImageAttributeExample_complex(c *C) {
- testServer.Response(200, nil, ModifyImageAttributeExample)
-
- options := ec2.ModifyImageAttribute{
- AddUsers: []string{"u1", "u2"},
- RemoveUsers: []string{"u3"},
- AddGroups: []string{"g1", "g3"},
- RemoveGroups: []string{"g2"},
- Description: "Test Description",
- }
-
- resp, err := s.ec2.ModifyImageAttribute("ami-4fa54026", &options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"ModifyImageAttribute"})
- c.Assert(req.Form["LaunchPermission.Add.1.UserId"], DeepEquals, []string{"u1"})
- c.Assert(req.Form["LaunchPermission.Add.2.UserId"], DeepEquals, []string{"u2"})
- c.Assert(req.Form["LaunchPermission.Remove.1.UserId"], DeepEquals, []string{"u3"})
- c.Assert(req.Form["LaunchPermission.Add.1.Group"], DeepEquals, []string{"g1"})
- c.Assert(req.Form["LaunchPermission.Add.2.Group"], DeepEquals, []string{"g3"})
- c.Assert(req.Form["LaunchPermission.Remove.1.Group"], DeepEquals, []string{"g2"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestCopyImageExample(c *C) {
- testServer.Response(200, nil, CopyImageExample)
-
- options := ec2.CopyImage{
- SourceRegion: "us-west-2",
- SourceImageId: "ami-1a2b3c4d",
- Description: "Test Description",
- }
-
- resp, err := s.ec2.CopyImage(&options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"CopyImage"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "60bc441d-fa2c-494d-b155-5d6a3EXAMPLE")
-}
-
-func (s *S) TestCreateKeyPairExample(c *C) {
- testServer.Response(200, nil, CreateKeyPairExample)
-
- resp, err := s.ec2.CreateKeyPair("foo")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"CreateKeyPair"})
- c.Assert(req.Form["KeyName"], DeepEquals, []string{"foo"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.KeyName, Equals, "foo")
- c.Assert(resp.KeyFingerprint, Equals, "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00")
-}
-
-func (s *S) TestDeleteKeyPairExample(c *C) {
- testServer.Response(200, nil, DeleteKeyPairExample)
-
- resp, err := s.ec2.DeleteKeyPair("foo")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteKeyPair"})
- c.Assert(req.Form["KeyName"], DeepEquals, []string{"foo"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestCreateSecurityGroupExample(c *C) {
- testServer.Response(200, nil, CreateSecurityGroupExample)
-
- resp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: "websrv", Description: "Web Servers"})
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"CreateSecurityGroup"})
- c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
- c.Assert(req.Form["GroupDescription"], DeepEquals, []string{"Web Servers"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Name, Equals, "websrv")
- c.Assert(resp.Id, Equals, "sg-67ad940e")
-}
-
-func (s *S) TestDescribeSecurityGroupsExample(c *C) {
- testServer.Response(200, nil, DescribeSecurityGroupsExample)
-
- resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{{Name: "WebServers"}, {Name: "RangedPortsBySource"}}, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroups"})
- c.Assert(req.Form["GroupName.1"], DeepEquals, []string{"WebServers"})
- c.Assert(req.Form["GroupName.2"], DeepEquals, []string{"RangedPortsBySource"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Groups, HasLen, 2)
-
- g0 := resp.Groups[0]
- c.Assert(g0.OwnerId, Equals, "999988887777")
- c.Assert(g0.Name, Equals, "WebServers")
- c.Assert(g0.Id, Equals, "sg-67ad940e")
- c.Assert(g0.Description, Equals, "Web Servers")
- c.Assert(g0.IPPerms, HasLen, 1)
- c.Assert(g0.IPPermsEgress, HasLen, 1)
-
- g0ipp := g0.IPPerms[0]
- c.Assert(g0ipp.Protocol, Equals, "tcp")
- c.Assert(g0ipp.FromPort, Equals, 80)
- c.Assert(g0ipp.ToPort, Equals, 80)
- c.Assert(g0ipp.SourceIPs, DeepEquals, []string{"0.0.0.0/0"})
-
- g0ippe := g0.IPPermsEgress[0]
- c.Assert(g0ippe.Protocol, Equals, "tcp")
- c.Assert(g0ippe.FromPort, Equals, 80)
- c.Assert(g0ippe.ToPort, Equals, 80)
- c.Assert(g0ippe.SourceIPs, DeepEquals, []string{"0.0.0.0/0"})
-
- g1 := resp.Groups[1]
- c.Assert(g1.OwnerId, Equals, "999988887777")
- c.Assert(g1.Name, Equals, "RangedPortsBySource")
- c.Assert(g1.Id, Equals, "sg-76abc467")
- c.Assert(g1.Description, Equals, "Group A")
- c.Assert(g1.IPPerms, HasLen, 1)
-
- g1ipp := g1.IPPerms[0]
- c.Assert(g1ipp.Protocol, Equals, "tcp")
- c.Assert(g1ipp.FromPort, Equals, 6000)
- c.Assert(g1ipp.ToPort, Equals, 7000)
- c.Assert(g1ipp.SourceIPs, IsNil)
-}
-
-func (s *S) TestDescribeSecurityGroupsExampleWithFilter(c *C) {
- testServer.Response(200, nil, DescribeSecurityGroupsExample)
-
- filter := ec2.NewFilter()
- filter.Add("ip-permission.protocol", "tcp")
- filter.Add("ip-permission.from-port", "22")
- filter.Add("ip-permission.to-port", "22")
- filter.Add("ip-permission.group-name", "app_server_group", "database_group")
-
- _, err := s.ec2.SecurityGroups(nil, filter)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroups"})
- c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"ip-permission.from-port"})
- c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"22"})
- c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"ip-permission.group-name"})
- c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"app_server_group"})
- c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"database_group"})
- c.Assert(req.Form["Filter.3.Name"], DeepEquals, []string{"ip-permission.protocol"})
- c.Assert(req.Form["Filter.3.Value.1"], DeepEquals, []string{"tcp"})
- c.Assert(req.Form["Filter.4.Name"], DeepEquals, []string{"ip-permission.to-port"})
- c.Assert(req.Form["Filter.4.Value.1"], DeepEquals, []string{"22"})
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestDescribeSecurityGroupsDumpWithGroup(c *C) {
- testServer.Response(200, nil, DescribeSecurityGroupsDump)
-
- resp, err := s.ec2.SecurityGroups(nil, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeSecurityGroups"})
- c.Assert(err, IsNil)
- c.Check(resp.Groups, HasLen, 1)
- c.Check(resp.Groups[0].IPPerms, HasLen, 2)
-
- ipp0 := resp.Groups[0].IPPerms[0]
- c.Assert(ipp0.SourceIPs, IsNil)
- c.Check(ipp0.Protocol, Equals, "icmp")
- c.Assert(ipp0.SourceGroups, HasLen, 1)
- c.Check(ipp0.SourceGroups[0].OwnerId, Equals, "12345")
- c.Check(ipp0.SourceGroups[0].Name, Equals, "default")
- c.Check(ipp0.SourceGroups[0].Id, Equals, "sg-67ad940e")
-
- ipp1 := resp.Groups[0].IPPerms[1]
- c.Check(ipp1.Protocol, Equals, "tcp")
- c.Assert(ipp0.SourceIPs, IsNil)
- c.Assert(ipp0.SourceGroups, HasLen, 1)
- c.Check(ipp1.SourceGroups[0].Id, Equals, "sg-76abc467")
- c.Check(ipp1.SourceGroups[0].OwnerId, Equals, "12345")
- c.Check(ipp1.SourceGroups[0].Name, Equals, "other")
-}
-
-func (s *S) TestDeleteSecurityGroupExample(c *C) {
- testServer.Response(200, nil, DeleteSecurityGroupExample)
-
- resp, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: "websrv"})
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteSecurityGroup"})
- c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
- c.Assert(req.Form["GroupId"], IsNil)
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestDeleteSecurityGroupExampleWithId(c *C) {
- testServer.Response(200, nil, DeleteSecurityGroupExample)
-
- // ignore return and error - we're only want to check the parameter handling.
- s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name: "ignored"})
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["GroupName"], IsNil)
- c.Assert(req.Form["GroupId"], DeepEquals, []string{"sg-67ad940e"})
-}
-
-func (s *S) TestAuthorizeSecurityGroupExample1(c *C) {
- testServer.Response(200, nil, AuthorizeSecurityGroupIngressExample)
-
- perms := []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 80,
- ToPort: 80,
- SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"},
- }}
- resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}, perms)
-
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeSecurityGroupIngress"})
- c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
- c.Assert(req.Form["IpPermissions.1.IpProtocol"], DeepEquals, []string{"tcp"})
- c.Assert(req.Form["IpPermissions.1.FromPort"], DeepEquals, []string{"80"})
- c.Assert(req.Form["IpPermissions.1.ToPort"], DeepEquals, []string{"80"})
- c.Assert(req.Form["IpPermissions.1.IpRanges.1.CidrIp"], DeepEquals, []string{"205.192.0.0/16"})
- c.Assert(req.Form["IpPermissions.1.IpRanges.2.CidrIp"], DeepEquals, []string{"205.159.0.0/16"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestAuthorizeSecurityGroupExample1WithId(c *C) {
- testServer.Response(200, nil, AuthorizeSecurityGroupIngressExample)
-
- perms := []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 80,
- ToPort: 80,
- SourceIPs: []string{"205.192.0.0/16", "205.159.0.0/16"},
- }}
- // ignore return and error - we're only want to check the parameter handling.
- s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Id: "sg-67ad940e", Name: "ignored"}, perms)
-
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["GroupName"], IsNil)
- c.Assert(req.Form["GroupId"], DeepEquals, []string{"sg-67ad940e"})
-}
-
-func (s *S) TestAuthorizeSecurityGroupExample2(c *C) {
- testServer.Response(200, nil, AuthorizeSecurityGroupIngressExample)
-
- perms := []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 80,
- ToPort: 81,
- SourceGroups: []ec2.UserSecurityGroup{
- {OwnerId: "999988887777", Name: "OtherAccountGroup"},
- {Id: "sg-67ad940e"},
- },
- }}
- resp, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}, perms)
-
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"AuthorizeSecurityGroupIngress"})
- c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
- c.Assert(req.Form["IpPermissions.1.IpProtocol"], DeepEquals, []string{"tcp"})
- c.Assert(req.Form["IpPermissions.1.FromPort"], DeepEquals, []string{"80"})
- c.Assert(req.Form["IpPermissions.1.ToPort"], DeepEquals, []string{"81"})
- c.Assert(req.Form["IpPermissions.1.Groups.1.UserId"], DeepEquals, []string{"999988887777"})
- c.Assert(req.Form["IpPermissions.1.Groups.1.GroupName"], DeepEquals, []string{"OtherAccountGroup"})
- c.Assert(req.Form["IpPermissions.1.Groups.2.UserId"], IsNil)
- c.Assert(req.Form["IpPermissions.1.Groups.2.GroupName"], IsNil)
- c.Assert(req.Form["IpPermissions.1.Groups.2.GroupId"], DeepEquals, []string{"sg-67ad940e"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestRevokeSecurityGroupExample(c *C) {
- // RevokeSecurityGroup is implemented by the same code as AuthorizeSecurityGroup
- // so there's no need to duplicate all the tests.
- testServer.Response(200, nil, RevokeSecurityGroupIngressExample)
-
- resp, err := s.ec2.RevokeSecurityGroup(ec2.SecurityGroup{Name: "websrv"}, nil)
-
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"RevokeSecurityGroupIngress"})
- c.Assert(req.Form["GroupName"], DeepEquals, []string{"websrv"})
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestCreateTags(c *C) {
- testServer.Response(200, nil, CreateTagsExample)
-
- resp, err := s.ec2.CreateTags([]string{"ami-1a2b3c4d", "i-7f4d3a2b"}, []ec2.Tag{{"webserver", ""}, {"stack", "Production"}})
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["ResourceId.1"], DeepEquals, []string{"ami-1a2b3c4d"})
- c.Assert(req.Form["ResourceId.2"], DeepEquals, []string{"i-7f4d3a2b"})
- c.Assert(req.Form["Tag.1.Key"], DeepEquals, []string{"webserver"})
- c.Assert(req.Form["Tag.1.Value"], DeepEquals, []string{""})
- c.Assert(req.Form["Tag.2.Key"], DeepEquals, []string{"stack"})
- c.Assert(req.Form["Tag.2.Value"], DeepEquals, []string{"Production"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestStartInstances(c *C) {
- testServer.Response(200, nil, StartInstancesExample)
-
- resp, err := s.ec2.StartInstances("i-10a64379")
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"StartInstances"})
- c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-
- s0 := resp.StateChanges[0]
- c.Assert(s0.InstanceId, Equals, "i-10a64379")
- c.Assert(s0.CurrentState.Code, Equals, 0)
- c.Assert(s0.CurrentState.Name, Equals, "pending")
- c.Assert(s0.PreviousState.Code, Equals, 80)
- c.Assert(s0.PreviousState.Name, Equals, "stopped")
-}
-
-func (s *S) TestStopInstances(c *C) {
- testServer.Response(200, nil, StopInstancesExample)
-
- resp, err := s.ec2.StopInstances("i-10a64379")
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"StopInstances"})
- c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-
- s0 := resp.StateChanges[0]
- c.Assert(s0.InstanceId, Equals, "i-10a64379")
- c.Assert(s0.CurrentState.Code, Equals, 64)
- c.Assert(s0.CurrentState.Name, Equals, "stopping")
- c.Assert(s0.PreviousState.Code, Equals, 16)
- c.Assert(s0.PreviousState.Name, Equals, "running")
-}
-
-func (s *S) TestRebootInstances(c *C) {
- testServer.Response(200, nil, RebootInstancesExample)
-
- resp, err := s.ec2.RebootInstances("i-10a64379")
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"RebootInstances"})
- c.Assert(req.Form["InstanceId.1"], DeepEquals, []string{"i-10a64379"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestSignatureWithEndpointPath(c *C) {
- ec2.FakeTime(true)
- defer ec2.FakeTime(false)
-
- testServer.Response(200, nil, RebootInstancesExample)
-
- // https://bugs.launchpad.net/goamz/+bug/1022749
- ec2 := ec2.NewWithClient(s.ec2.Auth, aws.Region{EC2Endpoint: testServer.URL + "/services/Cloud"}, testutil.DefaultClient)
-
- _, err := ec2.RebootInstances("i-10a64379")
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Signature"], DeepEquals, []string{"VVoC6Y6xfES+KvZo+789thP8+tye4F6fOKBiKmXk4S4="})
-}
-
-func (s *S) TestAllocateAddressExample(c *C) {
- testServer.Response(200, nil, AllocateAddressExample)
-
- options := &ec2.AllocateAddressOptions{
- Domain: "vpc",
- }
-
- resp, err := s.ec2.AllocateAddress(options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"AllocateAddress"})
- c.Assert(req.Form["Domain"], DeepEquals, []string{"vpc"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.PublicIp, Equals, "198.51.100.1")
- c.Assert(resp.Domain, Equals, "vpc")
- c.Assert(resp.AllocationId, Equals, "eipalloc-5723d13e")
-}
-
-func (s *S) TestReleaseAddressExample(c *C) {
- testServer.Response(200, nil, ReleaseAddressExample)
-
- resp, err := s.ec2.ReleaseAddress("192.0.2.1", "eipalloc-5723d13e")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"ReleaseAddress"})
- c.Assert(req.Form["PublicIp"], DeepEquals, []string{"192.0.2.1"})
- c.Assert(req.Form["AllocationId"], DeepEquals, []string{"eipalloc-5723d13e"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Return, Equals, true)
-}
-
-func (s *S) TestAssociateAddressExample(c *C) {
- testServer.Response(200, nil, AssociateAddressExample)
-
- options := &ec2.AssociateAddressOptions{
- PublicIp: "192.0.2.1",
- InstanceId: "i-4fd2431a",
- AllocationId: "eipalloc-5723d13e",
- AllowReassociation: true,
- }
-
- resp, err := s.ec2.AssociateAddress(options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"AssociateAddress"})
- c.Assert(req.Form["PublicIp"], DeepEquals, []string{"192.0.2.1"})
- c.Assert(req.Form["InstanceId"], DeepEquals, []string{"i-4fd2431a"})
- c.Assert(req.Form["AllocationId"], DeepEquals, []string{"eipalloc-5723d13e"})
- c.Assert(req.Form["AllowReassociation"], DeepEquals, []string{"true"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.AssociationId, Equals, "eipassoc-fc5ca095")
- c.Assert(resp.Return, Equals, true)
-}
-
-func (s *S) TestDisassociateAddressExample(c *C) {
- testServer.Response(200, nil, DisassociateAddressExample)
-
- resp, err := s.ec2.DisassociateAddress("192.0.2.1", "eipassoc-aa7486c3")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DisassociateAddress"})
- c.Assert(req.Form["PublicIp"], DeepEquals, []string{"192.0.2.1"})
- c.Assert(req.Form["AssociationId"], DeepEquals, []string{"eipassoc-aa7486c3"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Return, Equals, true)
-}
-
-func (s *S) TestModifyInstance(c *C) {
- testServer.Response(200, nil, ModifyInstanceExample)
-
- options := ec2.ModifyInstance{
- InstanceType: "m1.small",
- DisableAPITermination: true,
- EbsOptimized: true,
- SecurityGroups: []ec2.SecurityGroup{{Id: "g1"}, {Id: "g2"}},
- ShutdownBehavior: "terminate",
- KernelId: "kernel-id",
- RamdiskId: "ramdisk-id",
- SourceDestCheck: true,
- SriovNetSupport: true,
- UserData: []byte("1234"),
- BlockDevices: []ec2.BlockDeviceMapping{
- {DeviceName: "/dev/sda1", SnapshotId: "snap-a08912c9", DeleteOnTermination: true},
- },
- }
-
- resp, err := s.ec2.ModifyInstance("i-2ba64342", &options)
- req := testServer.WaitRequest()
-
- c.Assert(req.Form["Action"], DeepEquals, []string{"ModifyInstanceAttribute"})
- c.Assert(req.Form["InstanceId"], DeepEquals, []string{"i-2ba64342"})
- c.Assert(req.Form["InstanceType.Value"], DeepEquals, []string{"m1.small"})
- c.Assert(req.Form["BlockDeviceMapping.1.DeviceName"], DeepEquals, []string{"/dev/sda1"})
- c.Assert(req.Form["BlockDeviceMapping.1.Ebs.SnapshotId"], DeepEquals, []string{"snap-a08912c9"})
- c.Assert(req.Form["BlockDeviceMapping.1.Ebs.DeleteOnTermination"], DeepEquals, []string{"true"})
- c.Assert(req.Form["DisableApiTermination.Value"], DeepEquals, []string{"true"})
- c.Assert(req.Form["EbsOptimized"], DeepEquals, []string{"true"})
- c.Assert(req.Form["GroupId.1"], DeepEquals, []string{"g1"})
- c.Assert(req.Form["GroupId.2"], DeepEquals, []string{"g2"})
- c.Assert(req.Form["InstanceInitiatedShutdownBehavior.Value"], DeepEquals, []string{"terminate"})
- c.Assert(req.Form["Kernel.Value"], DeepEquals, []string{"kernel-id"})
- c.Assert(req.Form["Ramdisk.Value"], DeepEquals, []string{"ramdisk-id"})
- c.Assert(req.Form["SourceDestCheck.Value"], DeepEquals, []string{"true"})
- c.Assert(req.Form["SriovNetSupport.Value"], DeepEquals, []string{"simple"})
- c.Assert(req.Form["UserData"], DeepEquals, []string{"MTIzNA=="})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
-}
-
-func (s *S) TestDescribeReservedInstancesExample(c *C) {
- testServer.Response(200, nil, DescribeReservedInstancesExample)
-
- resp, err := s.ec2.DescribeReservedInstances([]string{"i-1", "i-2"}, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeReservedInstances"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.ReservedInstances, HasLen, 1)
-
- r0 := resp.ReservedInstances[0]
- c.Assert(r0.ReservedInstanceId, Equals, "e5a2ff3b-7d14-494f-90af-0b5d0EXAMPLE")
-
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/ec2i_test.go b/vendor/github.com/goamz/goamz/ec2/ec2i_test.go
deleted file mode 100644
index e8656f19f..000000000
--- a/vendor/github.com/goamz/goamz/ec2/ec2i_test.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package ec2_test
-
-import (
- "crypto/rand"
- "fmt"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/ec2"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-// AmazonServer represents an Amazon EC2 server.
-type AmazonServer struct {
- auth aws.Auth
-}
-
-func (s *AmazonServer) SetUp(c *C) {
- auth, err := aws.EnvAuth()
- if err != nil {
- c.Fatal(err.Error())
- }
- s.auth = auth
-}
-
-// Suite cost per run: 0.02 USD
-var _ = Suite(&AmazonClientSuite{})
-
-// AmazonClientSuite tests the client against a live EC2 server.
-type AmazonClientSuite struct {
- srv AmazonServer
- ClientTests
-}
-
-func (s *AmazonClientSuite) SetUpSuite(c *C) {
- if !testutil.Amazon {
- c.Skip("AmazonClientSuite tests not enabled")
- }
- s.srv.SetUp(c)
- s.ec2 = ec2.NewWithClient(s.srv.auth, aws.USEast, testutil.DefaultClient)
-}
-
-// ClientTests defines integration tests designed to test the client.
-// It is not used as a test suite in itself, but embedded within
-// another type.
-type ClientTests struct {
- ec2 *ec2.EC2
-}
-
-var imageId = "ami-ccf405a5" // Ubuntu Maverick, i386, EBS store
-
-// Cost: 0.00 USD
-func (s *ClientTests) TestRunInstancesError(c *C) {
- options := ec2.RunInstancesOptions{
- ImageId: "ami-a6f504cf", // Ubuntu Maverick, i386, instance store
- InstanceType: "t1.micro", // Doesn't work with micro, results in 400.
- }
-
- resp, err := s.ec2.RunInstances(&options)
-
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, "AMI.*root device.*not supported.*")
-
- ec2err, ok := err.(*ec2.Error)
- c.Assert(ok, Equals, true)
- c.Assert(ec2err.StatusCode, Equals, 400)
- c.Assert(ec2err.Code, Equals, "UnsupportedOperation")
- c.Assert(ec2err.Message, Matches, "AMI.*root device.*not supported.*")
- c.Assert(ec2err.RequestId, Matches, ".+")
-}
-
-// Cost: 0.02 USD
-func (s *ClientTests) TestRunAndTerminate(c *C) {
- options := ec2.RunInstancesOptions{
- ImageId: imageId,
- InstanceType: "t1.micro",
- }
- resp1, err := s.ec2.RunInstances(&options)
- c.Assert(err, IsNil)
- c.Check(resp1.ReservationId, Matches, "r-[0-9a-f]*")
- c.Check(resp1.OwnerId, Matches, "[0-9]+")
- c.Check(resp1.Instances, HasLen, 1)
- c.Check(resp1.Instances[0].InstanceType, Equals, "t1.micro")
-
- instId := resp1.Instances[0].InstanceId
-
- resp2, err := s.ec2.DescribeInstances([]string{instId}, nil)
- c.Assert(err, IsNil)
- if c.Check(resp2.Reservations, HasLen, 1) && c.Check(len(resp2.Reservations[0].Instances), Equals, 1) {
- inst := resp2.Reservations[0].Instances[0]
- c.Check(inst.InstanceId, Equals, instId)
- }
-
- resp3, err := s.ec2.TerminateInstances([]string{instId})
- c.Assert(err, IsNil)
- c.Check(resp3.StateChanges, HasLen, 1)
- c.Check(resp3.StateChanges[0].InstanceId, Equals, instId)
- c.Check(resp3.StateChanges[0].CurrentState.Name, Equals, "shutting-down")
- c.Check(resp3.StateChanges[0].CurrentState.Code, Equals, 32)
-}
-
-// Cost: 0.00 USD
-func (s *ClientTests) TestSecurityGroups(c *C) {
- name := "goamz-test"
- descr := "goamz security group for tests"
-
- // Clean it up, if a previous test left it around and avoid leaving it around.
- s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
- defer s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
-
- resp1, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
- c.Assert(err, IsNil)
- c.Assert(resp1.RequestId, Matches, ".+")
- c.Assert(resp1.Name, Equals, name)
- c.Assert(resp1.Id, Matches, ".+")
-
- resp1, err = s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
- ec2err, _ := err.(*ec2.Error)
- c.Assert(resp1, IsNil)
- c.Assert(ec2err, NotNil)
- c.Assert(ec2err.Code, Equals, "InvalidGroup.Duplicate")
-
- perms := []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 0,
- ToPort: 1024,
- SourceIPs: []string{"127.0.0.1/24"},
- }}
-
- resp2, err := s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms)
- c.Assert(err, IsNil)
- c.Assert(resp2.RequestId, Matches, ".+")
-
- resp3, err := s.ec2.SecurityGroups(ec2.SecurityGroupNames(name), nil)
- c.Assert(err, IsNil)
- c.Assert(resp3.RequestId, Matches, ".+")
- c.Assert(resp3.Groups, HasLen, 1)
-
- g0 := resp3.Groups[0]
- c.Assert(g0.Name, Equals, name)
- c.Assert(g0.Description, Equals, descr)
- c.Assert(g0.IPPerms, HasLen, 1)
- c.Assert(g0.IPPerms[0].Protocol, Equals, "tcp")
- c.Assert(g0.IPPerms[0].FromPort, Equals, 0)
- c.Assert(g0.IPPerms[0].ToPort, Equals, 1024)
- c.Assert(g0.IPPerms[0].SourceIPs, DeepEquals, []string{"127.0.0.1/24"})
-
- resp2, err = s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
- c.Assert(err, IsNil)
- c.Assert(resp2.RequestId, Matches, ".+")
-}
-
-var sessionId = func() string {
- buf := make([]byte, 8)
- // if we have no randomness, we'll just make do, so ignore the error.
- rand.Read(buf)
- return fmt.Sprintf("%x", buf)
-}()
-
-// sessionName reutrns a name that is probably
-// unique to this test session.
-func sessionName(prefix string) string {
- return prefix + "-" + sessionId
-}
-
-var allRegions = []aws.Region{
- aws.USEast,
- aws.USWest,
- aws.EUWest,
- aws.APSoutheast,
- aws.APNortheast,
-}
-
-// Communicate with all EC2 endpoints to see if they are alive.
-func (s *ClientTests) TestRegions(c *C) {
- name := sessionName("goamz-region-test")
- perms := []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 80,
- ToPort: 80,
- SourceIPs: []string{"127.0.0.1/32"},
- }}
- errs := make(chan error, len(allRegions))
- for _, region := range allRegions {
- go func(r aws.Region) {
- e := ec2.NewWithClient(s.ec2.Auth, r, testutil.DefaultClient)
- _, err := e.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms)
- errs <- err
- }(region)
- }
- for _ = range allRegions {
- err := <-errs
- if err != nil {
- ec2_err, ok := err.(*ec2.Error)
- if ok {
- c.Check(ec2_err.Code, Matches, "InvalidGroup.NotFound")
- } else {
- c.Errorf("Non-EC2 error: %s", err)
- }
- } else {
- c.Errorf("Test should have errored but it seems to have succeeded")
- }
- }
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/ec2t_test.go b/vendor/github.com/goamz/goamz/ec2/ec2t_test.go
deleted file mode 100644
index 37c2e7eb7..000000000
--- a/vendor/github.com/goamz/goamz/ec2/ec2t_test.go
+++ /dev/null
@@ -1,581 +0,0 @@
-package ec2_test
-
-import (
- "fmt"
- "regexp"
- "sort"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/ec2"
- "github.com/goamz/goamz/ec2/ec2test"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-// LocalServer represents a local ec2test fake server.
-type LocalServer struct {
- auth aws.Auth
- region aws.Region
- srv *ec2test.Server
-}
-
-func (s *LocalServer) SetUp(c *C) {
- srv, err := ec2test.NewServer()
- c.Assert(err, IsNil)
- c.Assert(srv, NotNil)
-
- s.srv = srv
- s.region = aws.Region{EC2Endpoint: srv.URL()}
-}
-
-// LocalServerSuite defines tests that will run
-// against the local ec2test server. It includes
-// selected tests from ClientTests;
-// when the ec2test functionality is sufficient, it should
-// include all of them, and ClientTests can be simply embedded.
-type LocalServerSuite struct {
- srv LocalServer
- ServerTests
- clientTests ClientTests
-}
-
-var _ = Suite(&LocalServerSuite{})
-
-func (s *LocalServerSuite) SetUpSuite(c *C) {
- s.srv.SetUp(c)
- s.ServerTests.ec2 = ec2.NewWithClient(s.srv.auth, s.srv.region, testutil.DefaultClient)
- s.clientTests.ec2 = ec2.NewWithClient(s.srv.auth, s.srv.region, testutil.DefaultClient)
-}
-
-func (s *LocalServerSuite) TestRunAndTerminate(c *C) {
- s.clientTests.TestRunAndTerminate(c)
-}
-
-func (s *LocalServerSuite) TestSecurityGroups(c *C) {
- s.clientTests.TestSecurityGroups(c)
-}
-
-// TestUserData is not defined on ServerTests because it
-// requires the ec2test server to function.
-func (s *LocalServerSuite) TestUserData(c *C) {
- data := make([]byte, 256)
- for i := range data {
- data[i] = byte(i)
- }
- inst, err := s.ec2.RunInstances(&ec2.RunInstancesOptions{
- ImageId: imageId,
- InstanceType: "t1.micro",
- UserData: data,
- })
- c.Assert(err, IsNil)
- c.Assert(inst, NotNil)
- c.Assert(inst.Instances[0].DNSName, Equals, inst.Instances[0].InstanceId+".example.com")
-
- id := inst.Instances[0].InstanceId
-
- defer s.ec2.TerminateInstances([]string{id})
-
- tinst := s.srv.srv.Instance(id)
- c.Assert(tinst, NotNil)
- c.Assert(tinst.UserData, DeepEquals, data)
-}
-
-// AmazonServerSuite runs the ec2test server tests against a live EC2 server.
-// It will only be activated if the -all flag is specified.
-type AmazonServerSuite struct {
- srv AmazonServer
- ServerTests
-}
-
-var _ = Suite(&AmazonServerSuite{})
-
-func (s *AmazonServerSuite) SetUpSuite(c *C) {
- if !testutil.Amazon {
- c.Skip("AmazonServerSuite tests not enabled")
- }
- s.srv.SetUp(c)
- s.ServerTests.ec2 = ec2.NewWithClient(s.srv.auth, aws.USEast, testutil.DefaultClient)
-}
-
-// ServerTests defines a set of tests designed to test
-// the ec2test local fake ec2 server.
-// It is not used as a test suite in itself, but embedded within
-// another type.
-type ServerTests struct {
- ec2 *ec2.EC2
-}
-
-func terminateInstances(c *C, e *ec2.EC2, insts []*ec2.Instance) {
- var ids []string
- for _, inst := range insts {
- if inst != nil {
- ids = append(ids, inst.InstanceId)
- }
- }
- _, err := e.TerminateInstances(ids)
- c.Check(err, IsNil, Commentf("%d INSTANCES LEFT RUNNING!!!", len(ids)))
-}
-
-func (s *ServerTests) makeTestGroup(c *C, name, descr string) ec2.SecurityGroup {
- // Clean it up if a previous test left it around.
- _, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
- if err != nil && err.(*ec2.Error).Code != "InvalidGroup.NotFound" {
- c.Fatalf("delete security group: %v", err)
- }
-
- resp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
- c.Assert(err, IsNil)
- c.Assert(resp.Name, Equals, name)
- return resp.SecurityGroup
-}
-
-func (s *ServerTests) TestIPPerms(c *C) {
- g0 := s.makeTestGroup(c, "goamz-test0", "ec2test group 0")
- defer s.ec2.DeleteSecurityGroup(g0)
-
- g1 := s.makeTestGroup(c, "goamz-test1", "ec2test group 1")
- defer s.ec2.DeleteSecurityGroup(g1)
-
- resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{g0, g1}, nil)
- c.Assert(err, IsNil)
- c.Assert(resp.Groups, HasLen, 2)
- c.Assert(resp.Groups[0].IPPerms, HasLen, 0)
- c.Assert(resp.Groups[1].IPPerms, HasLen, 0)
-
- ownerId := resp.Groups[0].OwnerId
-
- // test some invalid parameters
- // TODO more
- _, err = s.ec2.AuthorizeSecurityGroup(g0, []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 0,
- ToPort: 1024,
- SourceIPs: []string{"z127.0.0.1/24"},
- }})
- c.Assert(err, NotNil)
- c.Check(err.(*ec2.Error).Code, Equals, "InvalidPermission.Malformed")
-
- // Check that AuthorizeSecurityGroup adds the correct authorizations.
- _, err = s.ec2.AuthorizeSecurityGroup(g0, []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 2000,
- ToPort: 2001,
- SourceIPs: []string{"127.0.0.0/24"},
- SourceGroups: []ec2.UserSecurityGroup{{
- Name: g1.Name,
- }, {
- Id: g0.Id,
- }},
- }, {
- Protocol: "tcp",
- FromPort: 2000,
- ToPort: 2001,
- SourceIPs: []string{"200.1.1.34/32"},
- }})
- c.Assert(err, IsNil)
-
- resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil)
- c.Assert(err, IsNil)
- c.Assert(resp.Groups, HasLen, 1)
- c.Assert(resp.Groups[0].IPPerms, HasLen, 1)
-
- perm := resp.Groups[0].IPPerms[0]
- srcg := perm.SourceGroups
- c.Assert(srcg, HasLen, 2)
-
- // Normalize so we don't care about returned order.
- if srcg[0].Name == g1.Name {
- srcg[0], srcg[1] = srcg[1], srcg[0]
- }
- c.Check(srcg[0].Name, Equals, g0.Name)
- c.Check(srcg[0].Id, Equals, g0.Id)
- c.Check(srcg[0].OwnerId, Equals, ownerId)
- c.Check(srcg[1].Name, Equals, g1.Name)
- c.Check(srcg[1].Id, Equals, g1.Id)
- c.Check(srcg[1].OwnerId, Equals, ownerId)
-
- sort.Strings(perm.SourceIPs)
- c.Check(perm.SourceIPs, DeepEquals, []string{"127.0.0.0/24", "200.1.1.34/32"})
-
- // Check that we can't delete g1 (because g0 is using it)
- _, err = s.ec2.DeleteSecurityGroup(g1)
- c.Assert(err, NotNil)
- c.Check(err.(*ec2.Error).Code, Equals, "InvalidGroup.InUse")
-
- _, err = s.ec2.RevokeSecurityGroup(g0, []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 2000,
- ToPort: 2001,
- SourceGroups: []ec2.UserSecurityGroup{{Id: g1.Id}},
- }, {
- Protocol: "tcp",
- FromPort: 2000,
- ToPort: 2001,
- SourceIPs: []string{"200.1.1.34/32"},
- }})
- c.Assert(err, IsNil)
-
- resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil)
- c.Assert(err, IsNil)
- c.Assert(resp.Groups, HasLen, 1)
- c.Assert(resp.Groups[0].IPPerms, HasLen, 1)
-
- perm = resp.Groups[0].IPPerms[0]
- srcg = perm.SourceGroups
- c.Assert(srcg, HasLen, 1)
- c.Check(srcg[0].Name, Equals, g0.Name)
- c.Check(srcg[0].Id, Equals, g0.Id)
- c.Check(srcg[0].OwnerId, Equals, ownerId)
-
- c.Check(perm.SourceIPs, DeepEquals, []string{"127.0.0.0/24"})
-
- // We should be able to delete g1 now because we've removed its only use.
- _, err = s.ec2.DeleteSecurityGroup(g1)
- c.Assert(err, IsNil)
-
- _, err = s.ec2.DeleteSecurityGroup(g0)
- c.Assert(err, IsNil)
-
- f := ec2.NewFilter()
- f.Add("group-id", g0.Id, g1.Id)
- resp, err = s.ec2.SecurityGroups(nil, f)
- c.Assert(err, IsNil)
- c.Assert(resp.Groups, HasLen, 0)
-}
-
-func (s *ServerTests) TestDuplicateIPPerm(c *C) {
- name := "goamz-test"
- descr := "goamz security group for tests"
-
- // Clean it up, if a previous test left it around and avoid leaving it around.
- s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
- defer s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name})
-
- resp1, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: name, Description: descr})
- c.Assert(err, IsNil)
- c.Assert(resp1.Name, Equals, name)
-
- perms := []ec2.IPPerm{{
- Protocol: "tcp",
- FromPort: 200,
- ToPort: 1024,
- SourceIPs: []string{"127.0.0.1/24"},
- }, {
- Protocol: "tcp",
- FromPort: 0,
- ToPort: 100,
- SourceIPs: []string{"127.0.0.1/24"},
- }}
-
- _, err = s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms[0:1])
- c.Assert(err, IsNil)
-
- _, err = s.ec2.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms[0:2])
- c.Assert(err, ErrorMatches, `.*\(InvalidPermission.Duplicate\)`)
-}
-
-type filterSpec struct {
- name string
- values []string
-}
-
-func (s *ServerTests) TestInstanceFiltering(c *C) {
- groupResp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: sessionName("testgroup1"), Description: "testgroup one description"})
- c.Assert(err, IsNil)
- group1 := groupResp.SecurityGroup
- defer s.ec2.DeleteSecurityGroup(group1)
-
- groupResp, err = s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: sessionName("testgroup2"), Description: "testgroup two description"})
- c.Assert(err, IsNil)
- group2 := groupResp.SecurityGroup
- defer s.ec2.DeleteSecurityGroup(group2)
-
- insts := make([]*ec2.Instance, 3)
- inst, err := s.ec2.RunInstances(&ec2.RunInstancesOptions{
- MinCount: 2,
- ImageId: imageId,
- InstanceType: "t1.micro",
- SecurityGroups: []ec2.SecurityGroup{group1},
- })
- c.Assert(err, IsNil)
- insts[0] = &inst.Instances[0]
- insts[1] = &inst.Instances[1]
- defer terminateInstances(c, s.ec2, insts)
-
- imageId2 := "ami-e358958a" // Natty server, i386, EBS store
- inst, err = s.ec2.RunInstances(&ec2.RunInstancesOptions{
- ImageId: imageId2,
- InstanceType: "t1.micro",
- SecurityGroups: []ec2.SecurityGroup{group2},
- })
- c.Assert(err, IsNil)
- insts[2] = &inst.Instances[0]
-
- ids := func(indices ...int) (instIds []string) {
- for _, index := range indices {
- instIds = append(instIds, insts[index].InstanceId)
- }
- return
- }
-
- tests := []struct {
- about string
- instanceIds []string // instanceIds argument to Instances method.
- filters []filterSpec // filters argument to Instances method.
- resultIds []string // set of instance ids of expected results.
- allowExtra bool // resultIds may be incomplete.
- err string // expected error.
- }{
- {
- about: "check that Instances returns all instances",
- resultIds: ids(0, 1, 2),
- allowExtra: true,
- }, {
- about: "check that specifying two instance ids returns them",
- instanceIds: ids(0, 2),
- resultIds: ids(0, 2),
- }, {
- about: "check that specifying a non-existent instance id gives an error",
- instanceIds: append(ids(0), "i-deadbeef"),
- err: `.*\(InvalidInstanceID\.NotFound\)`,
- }, {
- about: "check that a filter allowed both instances returns both of them",
- filters: []filterSpec{
- {"instance-id", ids(0, 2)},
- },
- resultIds: ids(0, 2),
- }, {
- about: "check that a filter allowing only one instance returns it",
- filters: []filterSpec{
- {"instance-id", ids(1)},
- },
- resultIds: ids(1),
- }, {
- about: "check that a filter allowing no instances returns none",
- filters: []filterSpec{
- {"instance-id", []string{"i-deadbeef12345"}},
- },
- }, {
- about: "check that filtering on group id works",
- filters: []filterSpec{
- {"group-id", []string{group1.Id}},
- },
- resultIds: ids(0, 1),
- }, {
- about: "check that filtering on group name works",
- filters: []filterSpec{
- {"group-name", []string{group1.Name}},
- },
- resultIds: ids(0, 1),
- }, {
- about: "check that filtering on image id works",
- filters: []filterSpec{
- {"image-id", []string{imageId}},
- },
- resultIds: ids(0, 1),
- allowExtra: true,
- }, {
- about: "combination filters 1",
- filters: []filterSpec{
- {"image-id", []string{imageId, imageId2}},
- {"group-name", []string{group1.Name}},
- },
- resultIds: ids(0, 1),
- }, {
- about: "combination filters 2",
- filters: []filterSpec{
- {"image-id", []string{imageId2}},
- {"group-name", []string{group1.Name}},
- },
- },
- }
- for i, t := range tests {
- c.Logf("%d. %s", i, t.about)
- var f *ec2.Filter
- if t.filters != nil {
- f = ec2.NewFilter()
- for _, spec := range t.filters {
- f.Add(spec.name, spec.values...)
- }
- }
- resp, err := s.ec2.DescribeInstances(t.instanceIds, f)
- if t.err != "" {
- c.Check(err, ErrorMatches, t.err)
- continue
- }
- c.Assert(err, IsNil)
- insts := make(map[string]*ec2.Instance)
- for _, r := range resp.Reservations {
- for j := range r.Instances {
- inst := &r.Instances[j]
- c.Check(insts[inst.InstanceId], IsNil, Commentf("duplicate instance id: %q", inst.InstanceId))
- insts[inst.InstanceId] = inst
- }
- }
- if !t.allowExtra {
- c.Check(insts, HasLen, len(t.resultIds), Commentf("expected %d instances got %#v", len(t.resultIds), insts))
- }
- for j, id := range t.resultIds {
- c.Check(insts[id], NotNil, Commentf("instance id %d (%q) not found; got %#v", j, id, insts))
- }
- }
-}
-
-func idsOnly(gs []ec2.SecurityGroup) []ec2.SecurityGroup {
- for i := range gs {
- gs[i].Name = ""
- }
- return gs
-}
-
-func namesOnly(gs []ec2.SecurityGroup) []ec2.SecurityGroup {
- for i := range gs {
- gs[i].Id = ""
- }
- return gs
-}
-
-func (s *ServerTests) TestGroupFiltering(c *C) {
- g := make([]ec2.SecurityGroup, 4)
- for i := range g {
- resp, err := s.ec2.CreateSecurityGroup(ec2.SecurityGroup{Name: sessionName(fmt.Sprintf("testgroup%d", i)), Description: fmt.Sprintf("testdescription%d", i)})
- c.Assert(err, IsNil)
- g[i] = resp.SecurityGroup
- c.Logf("group %d: %v", i, g[i])
- defer s.ec2.DeleteSecurityGroup(g[i])
- }
-
- perms := [][]ec2.IPPerm{
- {{
- Protocol: "tcp",
- FromPort: 100,
- ToPort: 200,
- SourceIPs: []string{"1.2.3.4/32"},
- }},
- {{
- Protocol: "tcp",
- FromPort: 200,
- ToPort: 300,
- SourceGroups: []ec2.UserSecurityGroup{{Id: g[1].Id}},
- }},
- {{
- Protocol: "udp",
- FromPort: 200,
- ToPort: 400,
- SourceGroups: []ec2.UserSecurityGroup{{Id: g[1].Id}},
- }},
- }
- for i, ps := range perms {
- _, err := s.ec2.AuthorizeSecurityGroup(g[i], ps)
- c.Assert(err, IsNil)
- }
-
- groups := func(indices ...int) (gs []ec2.SecurityGroup) {
- for _, index := range indices {
- gs = append(gs, g[index])
- }
- return
- }
-
- type groupTest struct {
- about string
- groups []ec2.SecurityGroup // groupIds argument to SecurityGroups method.
- filters []filterSpec // filters argument to SecurityGroups method.
- results []ec2.SecurityGroup // set of expected result groups.
- allowExtra bool // specified results may be incomplete.
- err string // expected error.
- }
- filterCheck := func(name, val string, gs []ec2.SecurityGroup) groupTest {
- return groupTest{
- about: "filter check " + name,
- filters: []filterSpec{{name, []string{val}}},
- results: gs,
- allowExtra: true,
- }
- }
- tests := []groupTest{
- {
- about: "check that SecurityGroups returns all groups",
- results: groups(0, 1, 2, 3),
- allowExtra: true,
- }, {
- about: "check that specifying two group ids returns them",
- groups: idsOnly(groups(0, 2)),
- results: groups(0, 2),
- }, {
- about: "check that specifying names only works",
- groups: namesOnly(groups(0, 2)),
- results: groups(0, 2),
- }, {
- about: "check that specifying a non-existent group id gives an error",
- groups: append(groups(0), ec2.SecurityGroup{Id: "sg-eeeeeeeee"}),
- err: `.*\(InvalidGroup\.NotFound\)`,
- }, {
- about: "check that a filter allowed two groups returns both of them",
- filters: []filterSpec{
- {"group-id", []string{g[0].Id, g[2].Id}},
- },
- results: groups(0, 2),
- },
- {
- about: "check that the previous filter works when specifying a list of ids",
- groups: groups(1, 2),
- filters: []filterSpec{
- {"group-id", []string{g[0].Id, g[2].Id}},
- },
- results: groups(2),
- }, {
- about: "check that a filter allowing no groups returns none",
- filters: []filterSpec{
- {"group-id", []string{"sg-eeeeeeeee"}},
- },
- },
- filterCheck("description", "testdescription1", groups(1)),
- filterCheck("group-name", g[2].Name, groups(2)),
- filterCheck("ip-permission.cidr", "1.2.3.4/32", groups(0)),
- filterCheck("ip-permission.group-name", g[1].Name, groups(1, 2)),
- filterCheck("ip-permission.protocol", "udp", groups(2)),
- filterCheck("ip-permission.from-port", "200", groups(1, 2)),
- filterCheck("ip-permission.to-port", "200", groups(0)),
- // TODO owner-id
- }
- for i, t := range tests {
- c.Logf("%d. %s", i, t.about)
- var f *ec2.Filter
- if t.filters != nil {
- f = ec2.NewFilter()
- for _, spec := range t.filters {
- f.Add(spec.name, spec.values...)
- }
- }
- resp, err := s.ec2.SecurityGroups(t.groups, f)
- if t.err != "" {
- c.Check(err, ErrorMatches, t.err)
- continue
- }
- c.Assert(err, IsNil)
- groups := make(map[string]*ec2.SecurityGroup)
- for j := range resp.Groups {
- group := &resp.Groups[j].SecurityGroup
- c.Check(groups[group.Id], IsNil, Commentf("duplicate group id: %q", group.Id))
-
- groups[group.Id] = group
- }
- // If extra groups may be returned, eliminate all groups that
- // we did not create in this session apart from the default group.
- if t.allowExtra {
- namePat := regexp.MustCompile(sessionName("testgroup[0-9]"))
- for id, g := range groups {
- if !namePat.MatchString(g.Name) {
- delete(groups, id)
- }
- }
- }
- c.Check(groups, HasLen, len(t.results))
- for j, g := range t.results {
- rg := groups[g.Id]
- c.Assert(rg, NotNil, Commentf("group %d (%v) not found; got %#v", j, g, groups))
- c.Check(rg.Name, Equals, g.Name, Commentf("group %d (%v)", j, g))
- }
- }
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/ec2test/filter.go b/vendor/github.com/goamz/goamz/ec2/ec2test/filter.go
deleted file mode 100644
index 1a0c04619..000000000
--- a/vendor/github.com/goamz/goamz/ec2/ec2test/filter.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package ec2test
-
-import (
- "fmt"
- "net/url"
- "strings"
-)
-
-// filter holds an ec2 filter. A filter maps an attribute to a set of
-// possible values for that attribute. For an item to pass through the
-// filter, every attribute of the item mentioned in the filter must match
-// at least one of its given values.
-type filter map[string][]string
-
-// newFilter creates a new filter from the Filter fields in the url form.
-//
-// The filtering is specified through a map of name=>values, where the
-// name is a well-defined key identifying the data to be matched,
-// and the list of values holds the possible values the filtered
-// item can take for the key to be included in the
-// result set. For example:
-//
-// Filter.1.Name=instance-type
-// Filter.1.Value.1=m1.small
-// Filter.1.Value.2=m1.large
-//
-func newFilter(form url.Values) filter {
- // TODO return an error if the fields are not well formed?
- names := make(map[int]string)
- values := make(map[int][]string)
- maxId := 0
- for name, fvalues := range form {
- var rest string
- var id int
- if x, _ := fmt.Sscanf(name, "Filter.%d.%s", &id, &rest); x != 2 {
- continue
- }
- if id > maxId {
- maxId = id
- }
- if rest == "Name" {
- names[id] = fvalues[0]
- continue
- }
- if !strings.HasPrefix(rest, "Value.") {
- continue
- }
- values[id] = append(values[id], fvalues[0])
- }
-
- f := make(filter)
- for id, name := range names {
- f[name] = values[id]
- }
- return f
-}
-
-func notDigit(r rune) bool {
- return r < '0' || r > '9'
-}
-
-// filterable represents an object that can be passed through a filter.
-type filterable interface {
- // matchAttr returns true if given attribute of the
- // object matches value. It returns an error if the
- // attribute is not recognised or the value is malformed.
- matchAttr(attr, value string) (bool, error)
-}
-
-// ok returns true if x passes through the filter.
-func (f filter) ok(x filterable) (bool, error) {
-next:
- for a, vs := range f {
- for _, v := range vs {
- if ok, err := x.matchAttr(a, v); ok {
- continue next
- } else if err != nil {
- return false, fmt.Errorf("bad attribute or value %q=%q for type %T: %v", a, v, x, err)
- }
- }
- return false, nil
- }
- return true, nil
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/ec2test/server.go b/vendor/github.com/goamz/goamz/ec2/ec2test/server.go
deleted file mode 100644
index e25d4ea20..000000000
--- a/vendor/github.com/goamz/goamz/ec2/ec2test/server.go
+++ /dev/null
@@ -1,993 +0,0 @@
-// The ec2test package implements a fake EC2 provider with
-// the capability of inducing errors on any given operation,
-// and retrospectively determining what operations have been
-// carried out.
-package ec2test
-
-import (
- "encoding/base64"
- "encoding/xml"
- "fmt"
- "github.com/goamz/goamz/ec2"
- "io"
- "net"
- "net/http"
- "net/url"
- "regexp"
- "strconv"
- "strings"
- "sync"
-)
-
-var b64 = base64.StdEncoding
-
-// Action represents a request that changes the ec2 state.
-type Action struct {
- RequestId string
-
- // Request holds the requested action as a url.Values instance
- Request url.Values
-
- // If the action succeeded, Response holds the value that
- // was marshalled to build the XML response for the request.
- Response interface{}
-
- // If the action failed, Err holds an error giving details of the failure.
- Err *ec2.Error
-}
-
-// TODO possible other things:
-// - some virtual time stamp interface, so a client
-// can ask for all actions after a certain virtual time.
-
-// Server implements an EC2 simulator for use in testing.
-type Server struct {
- url string
- listener net.Listener
- mu sync.Mutex
- reqs []*Action
-
- instances map[string]*Instance // id -> instance
- reservations map[string]*reservation // id -> reservation
- groups map[string]*securityGroup // id -> group
- maxId counter
- reqId counter
- reservationId counter
- groupId counter
- initialInstanceState ec2.InstanceState
-}
-
-// reservation holds a simulated ec2 reservation.
-type reservation struct {
- id string
- instances map[string]*Instance
- groups []*securityGroup
-}
-
-// instance holds a simulated ec2 instance
-type Instance struct {
- // UserData holds the data that was passed to the RunInstances request
- // when the instance was started.
- UserData []byte
- id string
- imageId string
- reservation *reservation
- instType string
- state ec2.InstanceState
-}
-
-// permKey represents permission for a given security
-// group or IP address (but not both) to access a given range of
-// ports. Equality of permKeys is used in the implementation of
-// permission sets, relying on the uniqueness of securityGroup
-// instances.
-type permKey struct {
- protocol string
- fromPort int
- toPort int
- group *securityGroup
- ipAddr string
-}
-
-// securityGroup holds a simulated ec2 security group.
-// Instances of securityGroup should only be created through
-// Server.createSecurityGroup to ensure that groups can be
-// compared by pointer value.
-type securityGroup struct {
- id string
- name string
- description string
-
- perms map[permKey]bool
-}
-
-func (g *securityGroup) ec2SecurityGroup() ec2.SecurityGroup {
- return ec2.SecurityGroup{
- Name: g.name,
- Id: g.id,
- }
-}
-
-func (g *securityGroup) matchAttr(attr, value string) (ok bool, err error) {
- switch attr {
- case "description":
- return g.description == value, nil
- case "group-id":
- return g.id == value, nil
- case "group-name":
- return g.name == value, nil
- case "ip-permission.cidr":
- return g.hasPerm(func(k permKey) bool { return k.ipAddr == value }), nil
- case "ip-permission.group-name":
- return g.hasPerm(func(k permKey) bool {
- return k.group != nil && k.group.name == value
- }), nil
- case "ip-permission.from-port":
- port, err := strconv.Atoi(value)
- if err != nil {
- return false, err
- }
- return g.hasPerm(func(k permKey) bool { return k.fromPort == port }), nil
- case "ip-permission.to-port":
- port, err := strconv.Atoi(value)
- if err != nil {
- return false, err
- }
- return g.hasPerm(func(k permKey) bool { return k.toPort == port }), nil
- case "ip-permission.protocol":
- return g.hasPerm(func(k permKey) bool { return k.protocol == value }), nil
- case "owner-id":
- return value == ownerId, nil
- }
- return false, fmt.Errorf("unknown attribute %q", attr)
-}
-
-func (g *securityGroup) hasPerm(test func(k permKey) bool) bool {
- for k := range g.perms {
- if test(k) {
- return true
- }
- }
- return false
-}
-
-// ec2Perms returns the list of EC2 permissions granted
-// to g. It groups permissions by port range and protocol.
-func (g *securityGroup) ec2Perms() (perms []ec2.IPPerm) {
- // The grouping is held in result. We use permKey for convenience,
- // (ensuring that the group and ipAddr of each key is zero). For
- // each protocol/port range combination, we build up the permission
- // set in the associated value.
- result := make(map[permKey]*ec2.IPPerm)
- for k := range g.perms {
- groupKey := k
- groupKey.group = nil
- groupKey.ipAddr = ""
-
- ec2p := result[groupKey]
- if ec2p == nil {
- ec2p = &ec2.IPPerm{
- Protocol: k.protocol,
- FromPort: k.fromPort,
- ToPort: k.toPort,
- }
- result[groupKey] = ec2p
- }
- if k.group != nil {
- ec2p.SourceGroups = append(ec2p.SourceGroups,
- ec2.UserSecurityGroup{
- Id: k.group.id,
- Name: k.group.name,
- OwnerId: ownerId,
- })
- } else {
- ec2p.SourceIPs = append(ec2p.SourceIPs, k.ipAddr)
- }
- }
- for _, ec2p := range result {
- perms = append(perms, *ec2p)
- }
- return
-}
-
-var actions = map[string]func(*Server, http.ResponseWriter, *http.Request, string) interface{}{
- "RunInstances": (*Server).runInstances,
- "TerminateInstances": (*Server).terminateInstances,
- "DescribeInstances": (*Server).describeInstances,
- "CreateSecurityGroup": (*Server).createSecurityGroup,
- "DescribeSecurityGroups": (*Server).describeSecurityGroups,
- "DeleteSecurityGroup": (*Server).deleteSecurityGroup,
- "AuthorizeSecurityGroupIngress": (*Server).authorizeSecurityGroupIngress,
- "RevokeSecurityGroupIngress": (*Server).revokeSecurityGroupIngress,
-}
-
-const ownerId = "9876"
-
-// newAction allocates a new action and adds it to the
-// recorded list of server actions.
-func (srv *Server) newAction() *Action {
- srv.mu.Lock()
- defer srv.mu.Unlock()
-
- a := new(Action)
- srv.reqs = append(srv.reqs, a)
- return a
-}
-
-// NewServer returns a new server.
-func NewServer() (*Server, error) {
- srv := &Server{
- instances: make(map[string]*Instance),
- groups: make(map[string]*securityGroup),
- reservations: make(map[string]*reservation),
- initialInstanceState: Pending,
- }
-
- // Add default security group.
- g := &securityGroup{
- name: "default",
- description: "default group",
- id: fmt.Sprintf("sg-%d", srv.groupId.next()),
- }
- g.perms = map[permKey]bool{
- permKey{
- protocol: "icmp",
- fromPort: -1,
- toPort: -1,
- group: g,
- }: true,
- permKey{
- protocol: "tcp",
- fromPort: 0,
- toPort: 65535,
- group: g,
- }: true,
- permKey{
- protocol: "udp",
- fromPort: 0,
- toPort: 65535,
- group: g,
- }: true,
- }
- srv.groups[g.id] = g
-
- l, err := net.Listen("tcp", "localhost:0")
- if err != nil {
- return nil, fmt.Errorf("cannot listen on localhost: %v", err)
- }
- srv.listener = l
-
- srv.url = "http://" + l.Addr().String()
-
- // we use HandlerFunc rather than *Server directly so that we
- // can avoid exporting HandlerFunc from *Server.
- go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
- srv.serveHTTP(w, req)
- }))
- return srv, nil
-}
-
-// Quit closes down the server.
-func (srv *Server) Quit() {
- srv.listener.Close()
-}
-
-// SetInitialInstanceState sets the state that any new instances will be started in.
-func (srv *Server) SetInitialInstanceState(state ec2.InstanceState) {
- srv.mu.Lock()
- srv.initialInstanceState = state
- srv.mu.Unlock()
-}
-
-// URL returns the URL of the server.
-func (srv *Server) URL() string {
- return srv.url
-}
-
-// serveHTTP serves the EC2 protocol.
-func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
- req.ParseForm()
-
- a := srv.newAction()
- a.RequestId = fmt.Sprintf("req%d", srv.reqId.next())
- a.Request = req.Form
-
- // Methods on Server that deal with parsing user data
- // may fail. To save on error handling code, we allow these
- // methods to call fatalf, which will panic with an *ec2.Error
- // which will be caught here and returned
- // to the client as a properly formed EC2 error.
- defer func() {
- switch err := recover().(type) {
- case *ec2.Error:
- a.Err = err
- err.RequestId = a.RequestId
- writeError(w, err)
- case nil:
- default:
- panic(err)
- }
- }()
-
- f := actions[req.Form.Get("Action")]
- if f == nil {
- fatalf(400, "InvalidParameterValue", "Unrecognized Action")
- }
-
- response := f(srv, w, req, a.RequestId)
- a.Response = response
-
- w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
- xmlMarshal(w, response)
-}
-
-// Instance returns the instance for the given instance id.
-// It returns nil if there is no such instance.
-func (srv *Server) Instance(id string) *Instance {
- srv.mu.Lock()
- defer srv.mu.Unlock()
- return srv.instances[id]
-}
-
-// writeError writes an appropriate error response.
-// TODO how should we deal with errors when the
-// error itself is potentially generated by backend-agnostic
-// code?
-func writeError(w http.ResponseWriter, err *ec2.Error) {
- // Error encapsulates an error returned by EC2.
- // TODO merge with ec2.Error when xml supports ignoring a field.
- type ec2error struct {
- Code string // EC2 error code ("UnsupportedOperation", ...)
- Message string // The human-oriented error message
- RequestId string
- }
-
- type Response struct {
- RequestId string
- Errors []ec2error `xml:"Errors>Error"`
- }
-
- w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
- w.WriteHeader(err.StatusCode)
- xmlMarshal(w, Response{
- RequestId: err.RequestId,
- Errors: []ec2error{{
- Code: err.Code,
- Message: err.Message,
- }},
- })
-}
-
-// xmlMarshal is the same as xml.Marshal except that
-// it panics on error. The marshalling should not fail,
-// but we want to know if it does.
-func xmlMarshal(w io.Writer, x interface{}) {
- if err := xml.NewEncoder(w).Encode(x); err != nil {
- panic(fmt.Errorf("error marshalling %#v: %v", x, err))
- }
-}
-
-// formToGroups parses a set of SecurityGroup form values
-// as found in a RunInstances request, and returns the resulting
-// slice of security groups.
-// It calls fatalf if a group is not found.
-func (srv *Server) formToGroups(form url.Values) []*securityGroup {
- var groups []*securityGroup
- for name, values := range form {
- switch {
- case strings.HasPrefix(name, "SecurityGroupId."):
- if g := srv.groups[values[0]]; g != nil {
- groups = append(groups, g)
- } else {
- fatalf(400, "InvalidGroup.NotFound", "unknown group id %q", values[0])
- }
- case strings.HasPrefix(name, "SecurityGroup."):
- var found *securityGroup
- for _, g := range srv.groups {
- if g.name == values[0] {
- found = g
- }
- }
- if found == nil {
- fatalf(400, "InvalidGroup.NotFound", "unknown group name %q", values[0])
- }
- groups = append(groups, found)
- }
- }
- return groups
-}
-
-// runInstances implements the EC2 RunInstances entry point.
-func (srv *Server) runInstances(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- min := atoi(req.Form.Get("MinCount"))
- max := atoi(req.Form.Get("MaxCount"))
- if min < 0 || max < 1 {
- fatalf(400, "InvalidParameterValue", "bad values for MinCount or MaxCount")
- }
- if min > max {
- fatalf(400, "InvalidParameterCombination", "MinCount is greater than MaxCount")
- }
- var userData []byte
- if data := req.Form.Get("UserData"); data != "" {
- var err error
- userData, err = b64.DecodeString(data)
- if err != nil {
- fatalf(400, "InvalidParameterValue", "bad UserData value: %v", err)
- }
- }
-
- // TODO attributes still to consider:
- // ImageId: accept anything, we can verify later
- // KeyName ?
- // InstanceType ?
- // KernelId ?
- // RamdiskId ?
- // AvailabilityZone ?
- // GroupName tag
- // Monitoring ignore?
- // SubnetId ?
- // DisableAPITermination bool
- // ShutdownBehavior string
- // PrivateIPAddress string
-
- srv.mu.Lock()
- defer srv.mu.Unlock()
-
- // make sure that form fields are correct before creating the reservation.
- instType := req.Form.Get("InstanceType")
- imageId := req.Form.Get("ImageId")
-
- r := srv.newReservation(srv.formToGroups(req.Form))
-
- var resp ec2.RunInstancesResp
- resp.RequestId = reqId
- resp.ReservationId = r.id
- resp.OwnerId = ownerId
-
- for i := 0; i < max; i++ {
- inst := srv.newInstance(r, instType, imageId, srv.initialInstanceState)
- inst.UserData = userData
- resp.Instances = append(resp.Instances, inst.ec2instance())
- }
- return &resp
-}
-
-func (srv *Server) group(group ec2.SecurityGroup) *securityGroup {
- if group.Id != "" {
- return srv.groups[group.Id]
- }
- for _, g := range srv.groups {
- if g.name == group.Name {
- return g
- }
- }
- return nil
-}
-
-// NewInstances creates n new instances in srv with the given instance type,
-// image ID, initial state and security groups. If any group does not already
-// exist, it will be created. NewInstances returns the ids of the new instances.
-func (srv *Server) NewInstances(n int, instType string, imageId string, state ec2.InstanceState, groups []ec2.SecurityGroup) []string {
- srv.mu.Lock()
- defer srv.mu.Unlock()
-
- rgroups := make([]*securityGroup, len(groups))
- for i, group := range groups {
- g := srv.group(group)
- if g == nil {
- fatalf(400, "InvalidGroup.NotFound", "no such group %v", g)
- }
- rgroups[i] = g
- }
- r := srv.newReservation(rgroups)
-
- ids := make([]string, n)
- for i := 0; i < n; i++ {
- inst := srv.newInstance(r, instType, imageId, state)
- ids[i] = inst.id
- }
- return ids
-}
-
-func (srv *Server) newInstance(r *reservation, instType string, imageId string, state ec2.InstanceState) *Instance {
- inst := &Instance{
- id: fmt.Sprintf("i-%d", srv.maxId.next()),
- instType: instType,
- imageId: imageId,
- state: state,
- reservation: r,
- }
- srv.instances[inst.id] = inst
- r.instances[inst.id] = inst
- return inst
-}
-
-func (srv *Server) newReservation(groups []*securityGroup) *reservation {
- r := &reservation{
- id: fmt.Sprintf("r-%d", srv.reservationId.next()),
- instances: make(map[string]*Instance),
- groups: groups,
- }
-
- srv.reservations[r.id] = r
- return r
-}
-
-func (srv *Server) terminateInstances(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- srv.mu.Lock()
- defer srv.mu.Unlock()
- var resp ec2.TerminateInstancesResp
- resp.RequestId = reqId
- var insts []*Instance
- for attr, vals := range req.Form {
- if strings.HasPrefix(attr, "InstanceId.") {
- id := vals[0]
- inst := srv.instances[id]
- if inst == nil {
- fatalf(400, "InvalidInstanceID.NotFound", "no such instance id %q", id)
- }
- insts = append(insts, inst)
- }
- }
- for _, inst := range insts {
- resp.StateChanges = append(resp.StateChanges, inst.terminate())
- }
- return &resp
-}
-
-func (inst *Instance) terminate() (d ec2.InstanceStateChange) {
- d.PreviousState = inst.state
- inst.state = ShuttingDown
- d.CurrentState = inst.state
- d.InstanceId = inst.id
- return d
-}
-
-func (inst *Instance) ec2instance() ec2.Instance {
- return ec2.Instance{
- InstanceId: inst.id,
- InstanceType: inst.instType,
- ImageId: inst.imageId,
- DNSName: fmt.Sprintf("%s.example.com", inst.id),
- // TODO the rest
- }
-}
-
-func (inst *Instance) matchAttr(attr, value string) (ok bool, err error) {
- switch attr {
- case "architecture":
- return value == "i386", nil
- case "instance-id":
- return inst.id == value, nil
- case "group-id":
- for _, g := range inst.reservation.groups {
- if g.id == value {
- return true, nil
- }
- }
- return false, nil
- case "group-name":
- for _, g := range inst.reservation.groups {
- if g.name == value {
- return true, nil
- }
- }
- return false, nil
- case "image-id":
- return value == inst.imageId, nil
- case "instance-state-code":
- code, err := strconv.Atoi(value)
- if err != nil {
- return false, err
- }
- return code&0xff == inst.state.Code, nil
- case "instance-state-name":
- return value == inst.state.Name, nil
- }
- return false, fmt.Errorf("unknown attribute %q", attr)
-}
-
-var (
- Pending = ec2.InstanceState{0, "pending"}
- Running = ec2.InstanceState{16, "running"}
- ShuttingDown = ec2.InstanceState{32, "shutting-down"}
- Terminated = ec2.InstanceState{16, "terminated"}
- Stopped = ec2.InstanceState{16, "stopped"}
-)
-
-func (srv *Server) createSecurityGroup(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- name := req.Form.Get("GroupName")
- if name == "" {
- fatalf(400, "InvalidParameterValue", "empty security group name")
- }
- srv.mu.Lock()
- defer srv.mu.Unlock()
- if srv.group(ec2.SecurityGroup{Name: name}) != nil {
- fatalf(400, "InvalidGroup.Duplicate", "group %q already exists", name)
- }
- g := &securityGroup{
- name: name,
- description: req.Form.Get("GroupDescription"),
- id: fmt.Sprintf("sg-%d", srv.groupId.next()),
- perms: make(map[permKey]bool),
- }
- srv.groups[g.id] = g
- // we define a local type for this because ec2.CreateSecurityGroupResp
- // contains SecurityGroup, but the response to this request
- // should not contain the security group name.
- type CreateSecurityGroupResponse struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"`
- GroupId string `xml:"groupId"`
- }
- r := &CreateSecurityGroupResponse{
- RequestId: reqId,
- Return: true,
- GroupId: g.id,
- }
- return r
-}
-
-func (srv *Server) notImplemented(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- fatalf(500, "InternalError", "not implemented")
- panic("not reached")
-}
-
-func (srv *Server) describeInstances(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- srv.mu.Lock()
- defer srv.mu.Unlock()
- insts := make(map[*Instance]bool)
- for name, vals := range req.Form {
- if !strings.HasPrefix(name, "InstanceId.") {
- continue
- }
- inst := srv.instances[vals[0]]
- if inst == nil {
- fatalf(400, "InvalidInstanceID.NotFound", "instance %q not found", vals[0])
- }
- insts[inst] = true
- }
-
- f := newFilter(req.Form)
-
- var resp ec2.DescribeInstancesResp
- resp.RequestId = reqId
- for _, r := range srv.reservations {
- var instances []ec2.Instance
- for _, inst := range r.instances {
- if len(insts) > 0 && !insts[inst] {
- continue
- }
- ok, err := f.ok(inst)
- if ok {
- instances = append(instances, inst.ec2instance())
- } else if err != nil {
- fatalf(400, "InvalidParameterValue", "describe instances: %v", err)
- }
- }
- if len(instances) > 0 {
- var groups []ec2.SecurityGroup
- for _, g := range r.groups {
- groups = append(groups, g.ec2SecurityGroup())
- }
- resp.Reservations = append(resp.Reservations, ec2.Reservation{
- ReservationId: r.id,
- OwnerId: ownerId,
- Instances: instances,
- SecurityGroups: groups,
- })
- }
- }
- return &resp
-}
-
-func (srv *Server) describeSecurityGroups(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- // BUG similar bug to describeInstances, but for GroupName and GroupId
- srv.mu.Lock()
- defer srv.mu.Unlock()
-
- var groups []*securityGroup
- for name, vals := range req.Form {
- var g ec2.SecurityGroup
- switch {
- case strings.HasPrefix(name, "GroupName."):
- g.Name = vals[0]
- case strings.HasPrefix(name, "GroupId."):
- g.Id = vals[0]
- default:
- continue
- }
- sg := srv.group(g)
- if sg == nil {
- fatalf(400, "InvalidGroup.NotFound", "no such group %v", g)
- }
- groups = append(groups, sg)
- }
- if len(groups) == 0 {
- for _, g := range srv.groups {
- groups = append(groups, g)
- }
- }
-
- f := newFilter(req.Form)
- var resp ec2.SecurityGroupsResp
- resp.RequestId = reqId
- for _, group := range groups {
- ok, err := f.ok(group)
- if ok {
- resp.Groups = append(resp.Groups, ec2.SecurityGroupInfo{
- OwnerId: ownerId,
- SecurityGroup: group.ec2SecurityGroup(),
- Description: group.description,
- IPPerms: group.ec2Perms(),
- })
- } else if err != nil {
- fatalf(400, "InvalidParameterValue", "describe security groups: %v", err)
- }
- }
- return &resp
-}
-
-func (srv *Server) authorizeSecurityGroupIngress(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- srv.mu.Lock()
- defer srv.mu.Unlock()
- g := srv.group(ec2.SecurityGroup{
- Name: req.Form.Get("GroupName"),
- Id: req.Form.Get("GroupId"),
- })
- if g == nil {
- fatalf(400, "InvalidGroup.NotFound", "group not found")
- }
- perms := srv.parsePerms(req)
-
- for _, p := range perms {
- if g.perms[p] {
- fatalf(400, "InvalidPermission.Duplicate", "Permission has already been authorized on the specified group")
- }
- }
- for _, p := range perms {
- g.perms[p] = true
- }
- return &ec2.SimpleResp{
- XMLName: xml.Name{"", "AuthorizeSecurityGroupIngressResponse"},
- RequestId: reqId,
- }
-}
-
-func (srv *Server) revokeSecurityGroupIngress(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- srv.mu.Lock()
- defer srv.mu.Unlock()
- g := srv.group(ec2.SecurityGroup{
- Name: req.Form.Get("GroupName"),
- Id: req.Form.Get("GroupId"),
- })
- if g == nil {
- fatalf(400, "InvalidGroup.NotFound", "group not found")
- }
- perms := srv.parsePerms(req)
-
- // Note EC2 does not give an error if asked to revoke an authorization
- // that does not exist.
- for _, p := range perms {
- delete(g.perms, p)
- }
- return &ec2.SimpleResp{
- XMLName: xml.Name{"", "RevokeSecurityGroupIngressResponse"},
- RequestId: reqId,
- }
-}
-
-var secGroupPat = regexp.MustCompile(`^sg-[a-z0-9]+$`)
-var ipPat = regexp.MustCompile(`^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$`)
-var ownerIdPat = regexp.MustCompile(`^[0-9]+$`)
-
-// parsePerms returns a slice of permKey values extracted
-// from the permission fields in req.
-func (srv *Server) parsePerms(req *http.Request) []permKey {
- // perms maps an index found in the form to its associated
- // IPPerm. For instance, the form value with key
- // "IpPermissions.3.FromPort" will be stored in perms[3].FromPort
- perms := make(map[int]ec2.IPPerm)
-
- type subgroupKey struct {
- id1, id2 int
- }
- // Each IPPerm can have many source security groups. The form key
- // for a source security group contains two indices: the index
- // of the IPPerm and the sub-index of the security group. The
- // sourceGroups map maps from a subgroupKey containing these
- // two indices to the associated security group. For instance,
- // the form value with key "IPPermissions.3.Groups.2.GroupName"
- // will be stored in sourceGroups[subgroupKey{3, 2}].Name.
- sourceGroups := make(map[subgroupKey]ec2.UserSecurityGroup)
-
- // For each value in the form we store its associated information in the
- // above maps. The maps are necessary because the form keys may
- // arrive in any order, and the indices are not
- // necessarily sequential or even small.
- for name, vals := range req.Form {
- val := vals[0]
- var id1 int
- var rest string
- if x, _ := fmt.Sscanf(name, "IpPermissions.%d.%s", &id1, &rest); x != 2 {
- continue
- }
- ec2p := perms[id1]
- switch {
- case rest == "FromPort":
- ec2p.FromPort = atoi(val)
- case rest == "ToPort":
- ec2p.ToPort = atoi(val)
- case rest == "IpProtocol":
- switch val {
- case "tcp", "udp", "icmp":
- ec2p.Protocol = val
- default:
- // check it's a well formed number
- atoi(val)
- ec2p.Protocol = val
- }
- case strings.HasPrefix(rest, "Groups."):
- k := subgroupKey{id1: id1}
- if x, _ := fmt.Sscanf(rest[len("Groups."):], "%d.%s", &k.id2, &rest); x != 2 {
- continue
- }
- g := sourceGroups[k]
- switch rest {
- case "UserId":
- // BUG if the user id is blank, this does not conform to the
- // way that EC2 handles it - a specified but blank owner id
- // can cause RevokeSecurityGroupIngress to fail with
- // "group not found" even if the security group id has been
- // correctly specified.
- // By failing here, we ensure that we fail early in this case.
- if !ownerIdPat.MatchString(val) {
- fatalf(400, "InvalidUserID.Malformed", "Invalid user ID: %q", val)
- }
- g.OwnerId = val
- case "GroupName":
- g.Name = val
- case "GroupId":
- if !secGroupPat.MatchString(val) {
- fatalf(400, "InvalidGroupId.Malformed", "Invalid group ID: %q", val)
- }
- g.Id = val
- default:
- fatalf(400, "UnknownParameter", "unknown parameter %q", name)
- }
- sourceGroups[k] = g
- case strings.HasPrefix(rest, "IpRanges."):
- var id2 int
- if x, _ := fmt.Sscanf(rest[len("IpRanges."):], "%d.%s", &id2, &rest); x != 2 {
- continue
- }
- switch rest {
- case "CidrIp":
- if !ipPat.MatchString(val) {
- fatalf(400, "InvalidPermission.Malformed", "Invalid IP range: %q", val)
- }
- ec2p.SourceIPs = append(ec2p.SourceIPs, val)
- default:
- fatalf(400, "UnknownParameter", "unknown parameter %q", name)
- }
- default:
- fatalf(400, "UnknownParameter", "unknown parameter %q", name)
- }
- perms[id1] = ec2p
- }
- // Associate each set of source groups with its IPPerm.
- for k, g := range sourceGroups {
- p := perms[k.id1]
- p.SourceGroups = append(p.SourceGroups, g)
- perms[k.id1] = p
- }
-
- // Now that we have built up the IPPerms we need, we check for
- // parameter errors and build up a permKey for each permission,
- // looking up security groups from srv as we do so.
- var result []permKey
- for _, p := range perms {
- if p.FromPort > p.ToPort {
- fatalf(400, "InvalidParameterValue", "invalid port range")
- }
- k := permKey{
- protocol: p.Protocol,
- fromPort: p.FromPort,
- toPort: p.ToPort,
- }
- for _, g := range p.SourceGroups {
- if g.OwnerId != "" && g.OwnerId != ownerId {
- fatalf(400, "InvalidGroup.NotFound", "group %q not found", g.Name)
- }
- var ec2g ec2.SecurityGroup
- switch {
- case g.Id != "":
- ec2g.Id = g.Id
- case g.Name != "":
- ec2g.Name = g.Name
- }
- k.group = srv.group(ec2g)
- if k.group == nil {
- fatalf(400, "InvalidGroup.NotFound", "group %v not found", g)
- }
- result = append(result, k)
- }
- k.group = nil
- for _, ip := range p.SourceIPs {
- k.ipAddr = ip
- result = append(result, k)
- }
- }
- return result
-}
-
-func (srv *Server) deleteSecurityGroup(w http.ResponseWriter, req *http.Request, reqId string) interface{} {
- srv.mu.Lock()
- defer srv.mu.Unlock()
- g := srv.group(ec2.SecurityGroup{
- Name: req.Form.Get("GroupName"),
- Id: req.Form.Get("GroupId"),
- })
- if g == nil {
- fatalf(400, "InvalidGroup.NotFound", "group not found")
- }
- for _, r := range srv.reservations {
- for _, h := range r.groups {
- if h == g && r.hasRunningMachine() {
- fatalf(500, "InvalidGroup.InUse", "group is currently in use by a running instance")
- }
- }
- }
- for _, sg := range srv.groups {
- // If a group refers to itself, it's ok to delete it.
- if sg == g {
- continue
- }
- for k := range sg.perms {
- if k.group == g {
- fatalf(500, "InvalidGroup.InUse", "group is currently in use by group %q", sg.id)
- }
- }
- }
-
- delete(srv.groups, g.id)
- return &ec2.SimpleResp{
- XMLName: xml.Name{"", "DeleteSecurityGroupResponse"},
- RequestId: reqId,
- }
-}
-
-func (r *reservation) hasRunningMachine() bool {
- for _, inst := range r.instances {
- if inst.state.Code != ShuttingDown.Code && inst.state.Code != Terminated.Code {
- return true
- }
- }
- return false
-}
-
-type counter int
-
-func (c *counter) next() (i int) {
- i = int(*c)
- (*c)++
- return
-}
-
-// atoi is like strconv.Atoi but is fatal if the
-// string is not well formed.
-func atoi(s string) int {
- i, err := strconv.Atoi(s)
- if err != nil {
- fatalf(400, "InvalidParameterValue", "bad number: %v", err)
- }
- return i
-}
-
-func fatalf(statusCode int, code string, f string, a ...interface{}) {
- panic(&ec2.Error{
- StatusCode: statusCode,
- Code: code,
- Message: fmt.Sprintf(f, a...),
- })
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/export_test.go b/vendor/github.com/goamz/goamz/ec2/export_test.go
deleted file mode 100644
index 78da91a07..000000000
--- a/vendor/github.com/goamz/goamz/ec2/export_test.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package ec2
-
-import (
- "github.com/goamz/goamz/aws"
- "time"
-)
-
-func Sign(auth aws.Auth, method, path string, params map[string]string, host string) {
- sign(auth, method, path, params, host)
-}
-
-func fixedTime() time.Time {
- return time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC)
-}
-
-func FakeTime(fakeIt bool) {
- if fakeIt {
- timeNow = fixedTime
- } else {
- timeNow = time.Now
- }
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/responses_test.go b/vendor/github.com/goamz/goamz/ec2/responses_test.go
deleted file mode 100644
index 84186c1be..000000000
--- a/vendor/github.com/goamz/goamz/ec2/responses_test.go
+++ /dev/null
@@ -1,1084 +0,0 @@
-package ec2_test
-
-var ErrorDump = `
-<?xml version="1.0" encoding="UTF-8"?>
-<Response><Errors><Error><Code>UnsupportedOperation</Code>
-<Message>AMIs with an instance-store root device are not supported for the instance type 't1.micro'.</Message>
-</Error></Errors><RequestID>0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4</RequestID></Response>
-`
-
-// http://goo.gl/Mcm3b
-var RunInstancesExample = `
-<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <reservationId>r-47a5402e</reservationId>
- <ownerId>999988887777</ownerId>
- <groupSet>
- <item>
- <groupId>sg-67ad940e</groupId>
- <groupName>default</groupName>
- </item>
- </groupSet>
- <instancesSet>
- <item>
- <instanceId>i-2ba64342</instanceId>
- <imageId>ami-60a54009</imageId>
- <instanceState>
- <code>0</code>
- <name>pending</name>
- </instanceState>
- <privateDnsName></privateDnsName>
- <dnsName></dnsName>
- <keyName>example-key-name</keyName>
- <amiLaunchIndex>0</amiLaunchIndex>
- <instanceType>m1.small</instanceType>
- <launchTime>2007-08-07T11:51:50.000Z</launchTime>
- <placement>
- <availabilityZone>us-east-1b</availabilityZone>
- </placement>
- <monitoring>
- <state>enabled</state>
- </monitoring>
- <virtualizationType>paravirtual</virtualizationType>
- <clientToken/>
- <tagSet/>
- <hypervisor>xen</hypervisor>
- </item>
- <item>
- <instanceId>i-2bc64242</instanceId>
- <imageId>ami-60a54009</imageId>
- <instanceState>
- <code>0</code>
- <name>pending</name>
- </instanceState>
- <privateDnsName></privateDnsName>
- <dnsName></dnsName>
- <keyName>example-key-name</keyName>
- <amiLaunchIndex>1</amiLaunchIndex>
- <instanceType>m1.small</instanceType>
- <launchTime>2007-08-07T11:51:50.000Z</launchTime>
- <placement>
- <availabilityZone>us-east-1b</availabilityZone>
- </placement>
- <monitoring>
- <state>enabled</state>
- </monitoring>
- <virtualizationType>paravirtual</virtualizationType>
- <clientToken/>
- <tagSet/>
- <hypervisor>xen</hypervisor>
- </item>
- <item>
- <instanceId>i-2be64332</instanceId>
- <imageId>ami-60a54009</imageId>
- <instanceState>
- <code>0</code>
- <name>pending</name>
- </instanceState>
- <privateDnsName></privateDnsName>
- <dnsName></dnsName>
- <keyName>example-key-name</keyName>
- <amiLaunchIndex>2</amiLaunchIndex>
- <instanceType>m1.small</instanceType>
- <launchTime>2007-08-07T11:51:50.000Z</launchTime>
- <placement>
- <availabilityZone>us-east-1b</availabilityZone>
- </placement>
- <monitoring>
- <state>enabled</state>
- </monitoring>
- <virtualizationType>paravirtual</virtualizationType>
- <clientToken/>
- <tagSet/>
- <hypervisor>xen</hypervisor>
- </item>
- </instancesSet>
-</RunInstancesResponse>
-`
-
-// http://goo.gl/GRZgCD
-var RequestSpotInstancesExample = `
-<RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <spotInstanceRequestSet>
- <item>
- <spotInstanceRequestId>sir-1a2b3c4d</spotInstanceRequestId>
- <spotPrice>0.5</spotPrice>
- <type>one-time</type>
- <state>open</state>
- <status>
- <code>pending-evaluation</code>
- <updateTime>YYYY-MM-DDTHH:MM:SS.000Z</updateTime>
- <message>Your Spot request has been submitted for review, and is pending evaluation.</message>
- </status>
- <availabilityZoneGroup>MyAzGroup</availabilityZoneGroup>
- <launchSpecification>
- <imageId>ami-1a2b3c4d</imageId>
- <keyName>gsg-keypair</keyName>
- <groupSet>
- <item>
- <groupId>sg-1a2b3c4d</groupId>
- <groupName>websrv</groupName>
- </item>
- </groupSet>
- <instanceType>m1.small</instanceType>
- <blockDeviceMapping/>
- <monitoring>
- <enabled>false</enabled>
- </monitoring>
- <ebsOptimized>false</ebsOptimized>
- </launchSpecification>
- <createTime>YYYY-MM-DDTHH:MM:SS.000Z</createTime>
- <productDescription>Linux/UNIX</productDescription>
- </item>
- </spotInstanceRequestSet>
-</RequestSpotInstancesResponse>
-`
-
-// http://goo.gl/KsKJJk
-var DescribeSpotRequestsExample = `
-<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>b1719f2a-5334-4479-b2f1-26926EXAMPLE</requestId>
- <spotInstanceRequestSet>
- <item>
- <spotInstanceRequestId>sir-1a2b3c4d</spotInstanceRequestId>
- <spotPrice>0.5</spotPrice>
- <type>one-time</type>
- <state>active</state>
- <status>
- <code>fulfilled</code>
- <updateTime>YYYY-MM-DDTHH:MM:SS.000Z</updateTime>
- <message>Your Spot request is fulfilled.</message>
- </status>
- <launchSpecification>
- <imageId>ami-1a2b3c4d</imageId>
- <keyName>gsg-keypair</keyName>
- <groupSet>
- <item>
- <groupId>sg-1a2b3c4d</groupId>
- <groupName>websrv</groupName>
- </item>
- </groupSet>
- <instanceType>m1.small</instanceType>
- <monitoring>
- <enabled>false</enabled>
- </monitoring>
- <ebsOptimized>false</ebsOptimized>
- </launchSpecification>
- <instanceId>i-1a2b3c4d</instanceId>
- <createTime>YYYY-MM-DDTHH:MM:SS.000Z</createTime>
- <productDescription>Linux/UNIX</productDescription>
- <launchedAvailabilityZone>us-east-1a</launchedAvailabilityZone>
- </item>
- </spotInstanceRequestSet>
-</DescribeSpotInstanceRequestsResponse>
-`
-
-// http://goo.gl/DcfFgJ
-var CancelSpotRequestsExample = `
-<CancelSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <spotInstanceRequestSet>
- <item>
- <spotInstanceRequestId>sir-1a2b3c4d</spotInstanceRequestId>
- <state>cancelled</state>
- </item>
- </spotInstanceRequestSet>
-</CancelSpotInstanceRequestsResponse>
-`
-
-// http://goo.gl/3BKHj
-var TerminateInstancesExample = `
-<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <instancesSet>
- <item>
- <instanceId>i-3ea74257</instanceId>
- <currentState>
- <code>32</code>
- <name>shutting-down</name>
- </currentState>
- <previousState>
- <code>16</code>
- <name>running</name>
- </previousState>
- </item>
- </instancesSet>
-</TerminateInstancesResponse>
-`
-
-// http://goo.gl/mLbmw
-var DescribeInstancesExample1 = `
-<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>98e3c9a4-848c-4d6d-8e8a-b1bdEXAMPLE</requestId>
- <reservationSet>
- <item>
- <reservationId>r-b27e30d9</reservationId>
- <ownerId>999988887777</ownerId>
- <groupSet>
- <item>
- <groupId>sg-67ad940e</groupId>
- <groupName>default</groupName>
- </item>
- </groupSet>
- <instancesSet>
- <item>
- <instanceId>i-c5cd56af</instanceId>
- <imageId>ami-1a2b3c4d</imageId>
- <instanceState>
- <code>16</code>
- <name>running</name>
- </instanceState>
- <privateDnsName>domU-12-31-39-10-56-34.compute-1.internal</privateDnsName>
- <dnsName>ec2-174-129-165-232.compute-1.amazonaws.com</dnsName>
- <reason/>
- <keyName>GSG_Keypair</keyName>
- <amiLaunchIndex>0</amiLaunchIndex>
- <productCodes/>
- <instanceType>m1.small</instanceType>
- <launchTime>2010-08-17T01:15:18.000Z</launchTime>
- <placement>
- <availabilityZone>us-east-1b</availabilityZone>
- <groupName/>
- </placement>
- <kernelId>aki-94c527fd</kernelId>
- <ramdiskId>ari-96c527ff</ramdiskId>
- <monitoring>
- <state>disabled</state>
- </monitoring>
- <privateIpAddress>10.198.85.190</privateIpAddress>
- <ipAddress>174.129.165.232</ipAddress>
- <architecture>i386</architecture>
- <rootDeviceType>ebs</rootDeviceType>
- <rootDeviceName>/dev/sda1</rootDeviceName>
- <blockDeviceMapping>
- <item>
- <deviceName>/dev/sda1</deviceName>
- <ebs>
- <volumeId>vol-a082c1c9</volumeId>
- <status>attached</status>
- <attachTime>2010-08-17T01:15:21.000Z</attachTime>
- <deleteOnTermination>false</deleteOnTermination>
- </ebs>
- </item>
- </blockDeviceMapping>
- <instanceLifecycle>spot</instanceLifecycle>
- <spotInstanceRequestId>sir-7a688402</spotInstanceRequestId>
- <virtualizationType>paravirtual</virtualizationType>
- <clientToken/>
- <tagSet/>
- <hypervisor>xen</hypervisor>
- </item>
- </instancesSet>
- <requesterId>854251627541</requesterId>
- </item>
- <item>
- <reservationId>r-b67e30dd</reservationId>
- <ownerId>999988887777</ownerId>
- <groupSet>
- <item>
- <groupId>sg-67ad940e</groupId>
- <groupName>default</groupName>
- </item>
- </groupSet>
- <instancesSet>
- <item>
- <instanceId>i-d9cd56b3</instanceId>
- <imageId>ami-1a2b3c4d</imageId>
- <instanceState>
- <code>16</code>
- <name>running</name>
- </instanceState>
- <privateDnsName>domU-12-31-39-10-54-E5.compute-1.internal</privateDnsName>
- <dnsName>ec2-184-73-58-78.compute-1.amazonaws.com</dnsName>
- <reason/>
- <keyName>GSG_Keypair</keyName>
- <amiLaunchIndex>0</amiLaunchIndex>
- <productCodes/>
- <instanceType>m1.large</instanceType>
- <launchTime>2010-08-17T01:15:19.000Z</launchTime>
- <placement>
- <availabilityZone>us-east-1b</availabilityZone>
- <groupName/>
- </placement>
- <kernelId>aki-94c527fd</kernelId>
- <ramdiskId>ari-96c527ff</ramdiskId>
- <monitoring>
- <state>disabled</state>
- </monitoring>
- <privateIpAddress>10.198.87.19</privateIpAddress>
- <ipAddress>184.73.58.78</ipAddress>
- <architecture>i386</architecture>
- <rootDeviceType>ebs</rootDeviceType>
- <rootDeviceName>/dev/sda1</rootDeviceName>
- <blockDeviceMapping>
- <item>
- <deviceName>/dev/sda1</deviceName>
- <ebs>
- <volumeId>vol-a282c1cb</volumeId>
- <status>attached</status>
- <attachTime>2010-08-17T01:15:23.000Z</attachTime>
- <deleteOnTermination>false</deleteOnTermination>
- </ebs>
- </item>
- </blockDeviceMapping>
- <instanceLifecycle>spot</instanceLifecycle>
- <spotInstanceRequestId>sir-55a3aa02</spotInstanceRequestId>
- <virtualizationType>paravirtual</virtualizationType>
- <clientToken/>
- <tagSet/>
- <hypervisor>xen</hypervisor>
- </item>
- </instancesSet>
- <requesterId>854251627541</requesterId>
- </item>
- </reservationSet>
-</DescribeInstancesResponse>
-`
-
-// http://goo.gl/mLbmw
-var DescribeInstancesExample2 = `
-<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <reservationSet>
- <item>
- <reservationId>r-bc7e30d7</reservationId>
- <ownerId>999988887777</ownerId>
- <groupSet>
- <item>
- <groupId>sg-67ad940e</groupId>
- <groupName>default</groupName>
- </item>
- </groupSet>
- <instancesSet>
- <item>
- <instanceId>i-c7cd56ad</instanceId>
- <imageId>ami-b232d0db</imageId>
- <instanceState>
- <code>16</code>
- <name>running</name>
- </instanceState>
- <privateDnsName>domU-12-31-39-01-76-06.compute-1.internal</privateDnsName>
- <dnsName>ec2-72-44-52-124.compute-1.amazonaws.com</dnsName>
- <keyName>GSG_Keypair</keyName>
- <amiLaunchIndex>0</amiLaunchIndex>
- <productCodes/>
- <instanceType>m1.small</instanceType>
- <launchTime>2010-08-17T01:15:16.000Z</launchTime>
- <placement>
- <availabilityZone>us-east-1b</availabilityZone>
- </placement>
- <kernelId>aki-94c527fd</kernelId>
- <ramdiskId>ari-96c527ff</ramdiskId>
- <monitoring>
- <state>disabled</state>
- </monitoring>
- <privateIpAddress>10.255.121.240</privateIpAddress>
- <ipAddress>72.44.52.124</ipAddress>
- <architecture>i386</architecture>
- <rootDeviceType>ebs</rootDeviceType>
- <rootDeviceName>/dev/sda1</rootDeviceName>
- <blockDeviceMapping>
- <item>
- <deviceName>/dev/sda1</deviceName>
- <ebs>
- <volumeId>vol-a482c1cd</volumeId>
- <status>attached</status>
- <attachTime>2010-08-17T01:15:26.000Z</attachTime>
- <deleteOnTermination>true</deleteOnTermination>
- </ebs>
- </item>
- </blockDeviceMapping>
- <virtualizationType>paravirtual</virtualizationType>
- <clientToken/>
- <tagSet>
- <item>
- <key>webserver</key>
- <value></value>
- </item>
- <item>
- <key>stack</key>
- <value>Production</value>
- </item>
- </tagSet>
- <hypervisor>xen</hypervisor>
- </item>
- </instancesSet>
- </item>
- </reservationSet>
-</DescribeInstancesResponse>
-`
-
-// http://goo.gl/2FBTdS
-var DescribeInstanceStatusExample = `
-<DescribeInstanceStatusResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <instanceStatusSet>
- <item>
- <instanceId>i-c7cd56ad</instanceId>
- <availabilityZone>us-east-1b</availabilityZone>
- <eventsSet>
- <item>
- <code>instance-reboot</code>
- <description>example description</description>
- <notBefore>2010-08-17T01:15:18.000Z</notBefore>
- <notAfter>2010-08-17T01:15:18.000Z</notAfter>
- </item>
- </eventsSet>
- <instanceState>
- <code>16</code>
- <name>running</name>
- </instanceState>
- <systemStatus>
- <status>ok</status>
- <details>
- <name>reachability</name>
- <status>passed</status>
- <impairedSince>2010-08-17T01:15:18.000Z</impairedSince>
- </details>
- </systemStatus>
- <instanceStatus>
- <status>ok</status>
- <details>
- <name>reachability</name>
- <status>passed</status>
- <impairedSince>2010-08-17T01:15:18.000Z</impairedSince>
- </details>
- </instanceStatus>
- </item>
- </instanceStatusSet>
- <nextToken>exampleToken</nextToken>
-</DescribeInstanceStatusResponse>
-`
-
-// http://goo.gl/icuXh5
-var ModifyInstanceExample = `
-<ModifyImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-06-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</ModifyImageAttributeResponse>
-`
-
-// http://goo.gl/9rprDN
-var AllocateAddressExample = `
-<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <publicIp>198.51.100.1</publicIp>
- <domain>vpc</domain>
- <allocationId>eipalloc-5723d13e</allocationId>
-</AllocateAddressResponse>
-`
-
-// http://goo.gl/3Q0oCc
-var ReleaseAddressExample = `
-<ReleaseAddressResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</ReleaseAddressResponse>
-`
-
-// http://goo.gl/uOSQE
-var AssociateAddressExample = `
-<AssociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
- <associationId>eipassoc-fc5ca095</associationId>
-</AssociateAddressResponse>
-`
-
-// http://goo.gl/LrOa0
-var DisassociateAddressExample = `
-<DisassociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</DisassociateAddressResponse>
-`
-
-//http://goo.gl/zW7J4p
-var DescribeAddressesExample = `
-<DescribeAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <addressesSet>
- <item>
- <publicIp>192.0.2.1</publicIp>
- <domain>standard</domain>
- <instanceId>i-f15ebb98</instanceId>
- </item>
- <item>
- <publicIp>198.51.100.2</publicIp>
- <domain>standard</domain>
- <instanceId/>
- </item>
- <item>
- <publicIp>203.0.113.41</publicIp>
- <allocationId>eipalloc-08229861</allocationId>
- <domain>vpc</domain>
- <instanceId>i-64600030</instanceId>
- <associationId>eipassoc-f0229899</associationId>
- <networkInterfaceId>eni-ef229886</networkInterfaceId>
- <networkInterfaceOwnerId>053230519467</networkInterfaceOwnerId>
- <privateIpAddress>10.0.0.228</privateIpAddress>
- </item>
- </addressesSet>
-</DescribeAddressesResponse>
-`
-
-var DescribeAddressesAllocationIdExample = `
-<DescribeAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <addressesSet>
- <item>
- <publicIp>203.0.113.41</publicIp>
- <allocationId>eipalloc-08229861</allocationId>
- <domain>vpc</domain>
- <instanceId>i-64600030</instanceId>
- <associationId>eipassoc-f0229899</associationId>
- <networkInterfaceId>eni-ef229886</networkInterfaceId>
- <networkInterfaceOwnerId>053230519467</networkInterfaceOwnerId>
- <privateIpAddress>10.0.0.228</privateIpAddress>
- </item>
- <item>
- <publicIp>146.54.2.230</publicIp>
- <allocationId>eipalloc-08364752</allocationId>
- <domain>vpc</domain>
- <instanceId>i-64693456</instanceId>
- <associationId>eipassoc-f0348693</associationId>
- <networkInterfaceId>eni-da764039</networkInterfaceId>
- <networkInterfaceOwnerId>053230519467</networkInterfaceOwnerId>
- <privateIpAddress>10.0.0.102</privateIpAddress>
- </item>
- </addressesSet>
-</DescribeAddressesResponse>
-`
-
-// http://goo.gl/cxU41
-var CreateImageExample = `
-<CreateImageResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <imageId>ami-4fa54026</imageId>
-</CreateImageResponse>
-`
-
-// http://goo.gl/V0U25
-var DescribeImagesExample = `
-<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2012-08-15/">
- <requestId>4a4a27a2-2e7c-475d-b35b-ca822EXAMPLE</requestId>
- <imagesSet>
- <item>
- <imageId>ami-a2469acf</imageId>
- <imageLocation>aws-marketplace/example-marketplace-amzn-ami.1</imageLocation>
- <imageState>available</imageState>
- <imageOwnerId>123456789999</imageOwnerId>
- <isPublic>true</isPublic>
- <productCodes>
- <item>
- <productCode>a1b2c3d4e5f6g7h8i9j10k11</productCode>
- <type>marketplace</type>
- </item>
- </productCodes>
- <architecture>i386</architecture>
- <imageType>machine</imageType>
- <kernelId>aki-805ea7e9</kernelId>
- <imageOwnerAlias>aws-marketplace</imageOwnerAlias>
- <name>example-marketplace-amzn-ami.1</name>
- <description>Amazon Linux AMI i386 EBS</description>
- <rootDeviceType>ebs</rootDeviceType>
- <rootDeviceName>/dev/sda1</rootDeviceName>
- <blockDeviceMapping>
- <item>
- <deviceName>/dev/sda1</deviceName>
- <ebs>
- <snapshotId>snap-787e9403</snapshotId>
- <volumeSize>8</volumeSize>
- <deleteOnTermination>true</deleteOnTermination>
- </ebs>
- </item>
- </blockDeviceMapping>
- <virtualizationType>paravirtual</virtualizationType>
- <tagSet>
- <item>
- <key>Purpose</key>
- <value>EXAMPLE</value>
- </item>
- </tagSet>
- <hypervisor>xen</hypervisor>
- </item>
- </imagesSet>
-</DescribeImagesResponse>
-`
-
-// http://goo.gl/bHO3z
-var ImageAttributeExample = `
-<DescribeImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-07-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <imageId>ami-61a54008</imageId>
- <launchPermission>
- <item>
- <group>all</group>
- </item>
- <item>
- <userId>495219933132</userId>
- </item>
- </launchPermission>
-</DescribeImageAttributeResponse>
-`
-
-// http://goo.gl/ttcda
-var CreateSnapshotExample = `
-<CreateSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2012-10-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <snapshotId>snap-78a54011</snapshotId>
- <volumeId>vol-4d826724</volumeId>
- <status>pending</status>
- <startTime>2008-05-07T12:51:50.000Z</startTime>
- <progress>60%</progress>
- <ownerId>111122223333</ownerId>
- <volumeSize>10</volumeSize>
- <description>Daily Backup</description>
-</CreateSnapshotResponse>
-`
-
-// http://goo.gl/vwU1y
-var DeleteSnapshotExample = `
-<DeleteSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2012-10-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</DeleteSnapshotResponse>
-`
-
-// http://goo.gl/nkovs
-var DescribeSnapshotsExample = `
-<DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2012-10-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <snapshotSet>
- <item>
- <snapshotId>snap-1a2b3c4d</snapshotId>
- <volumeId>vol-8875daef</volumeId>
- <status>pending</status>
- <startTime>2010-07-29T04:12:01.000Z</startTime>
- <progress>30%</progress>
- <ownerId>111122223333</ownerId>
- <volumeSize>15</volumeSize>
- <description>Daily Backup</description>
- <tagSet>
- <item>
- <key>Purpose</key>
- <value>demo_db_14_backup</value>
- </item>
- </tagSet>
- </item>
- </snapshotSet>
-</DescribeSnapshotsResponse>
-`
-
-// http://goo.gl/YUjO4G
-var ModifyImageAttributeExample = `
-<ModifyImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-06-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</ModifyImageAttributeResponse>
-`
-
-// http://goo.gl/hQwPCK
-var CopyImageExample = `
-<CopyImageResponse xmlns="http://ec2.amazonaws.com/doc/2013-06-15/">
- <requestId>60bc441d-fa2c-494d-b155-5d6a3EXAMPLE</requestId>
- <imageId>ami-4d3c2b1a</imageId>
-</CopyImageResponse>
-`
-
-var CreateKeyPairExample = `
-<CreateKeyPairResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <keyName>foo</keyName>
- <keyFingerprint>
- 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
- </keyFingerprint>
- <keyMaterial>---- BEGIN RSA PRIVATE KEY ----
-MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC
-VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6
-b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd
-BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN
-MTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD
-VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z
-b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt
-YXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ
-21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T
-rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE
-Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4
-nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb
-FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb
-NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE=
------END RSA PRIVATE KEY-----
-</keyMaterial>
-</CreateKeyPairResponse>
-`
-
-var DeleteKeyPairExample = `
-<DeleteKeyPairResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</DeleteKeyPairResponse>
-`
-
-// http://goo.gl/Eo7Yl
-var CreateSecurityGroupExample = `
-<CreateSecurityGroupResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
- <groupId>sg-67ad940e</groupId>
-</CreateSecurityGroupResponse>
-`
-
-// http://goo.gl/k12Uy
-var DescribeSecurityGroupsExample = `
-<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <securityGroupInfo>
- <item>
- <ownerId>999988887777</ownerId>
- <groupName>WebServers</groupName>
- <groupId>sg-67ad940e</groupId>
- <groupDescription>Web Servers</groupDescription>
- <ipPermissions>
- <item>
- <ipProtocol>tcp</ipProtocol>
- <fromPort>80</fromPort>
- <toPort>80</toPort>
- <groups/>
- <ipRanges>
- <item>
- <cidrIp>0.0.0.0/0</cidrIp>
- </item>
- </ipRanges>
- </item>
- </ipPermissions>
- <ipPermissionsEgress>
- <item>
- <ipProtocol>tcp</ipProtocol>
- <fromPort>80</fromPort>
- <toPort>80</toPort>
- <groups/>
- <ipRanges>
- <item>
- <cidrIp>0.0.0.0/0</cidrIp>
- </item>
- </ipRanges>
- </item>
- </ipPermissionsEgress>
- </item>
- <item>
- <ownerId>999988887777</ownerId>
- <groupName>RangedPortsBySource</groupName>
- <groupId>sg-76abc467</groupId>
- <groupDescription>Group A</groupDescription>
- <ipPermissions>
- <item>
- <ipProtocol>tcp</ipProtocol>
- <fromPort>6000</fromPort>
- <toPort>7000</toPort>
- <groups/>
- <ipRanges/>
- </item>
- </ipPermissions>
- </item>
- </securityGroupInfo>
-</DescribeSecurityGroupsResponse>
-`
-
-// A dump which includes groups within ip permissions.
-var DescribeSecurityGroupsDump = `
-<?xml version="1.0" encoding="UTF-8"?>
-<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>87b92b57-cc6e-48b2-943f-f6f0e5c9f46c</requestId>
- <securityGroupInfo>
- <item>
- <ownerId>12345</ownerId>
- <groupName>default</groupName>
- <groupDescription>default group</groupDescription>
- <ipPermissions>
- <item>
- <ipProtocol>icmp</ipProtocol>
- <fromPort>-1</fromPort>
- <toPort>-1</toPort>
- <groups>
- <item>
- <userId>12345</userId>
- <groupName>default</groupName>
- <groupId>sg-67ad940e</groupId>
- </item>
- </groups>
- <ipRanges/>
- </item>
- <item>
- <ipProtocol>tcp</ipProtocol>
- <fromPort>0</fromPort>
- <toPort>65535</toPort>
- <groups>
- <item>
- <userId>12345</userId>
- <groupName>other</groupName>
- <groupId>sg-76abc467</groupId>
- </item>
- </groups>
- <ipRanges/>
- </item>
- </ipPermissions>
- </item>
- </securityGroupInfo>
-</DescribeSecurityGroupsResponse>
-`
-
-// http://goo.gl/QJJDO
-var DeleteSecurityGroupExample = `
-<DeleteSecurityGroupResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</DeleteSecurityGroupResponse>
-`
-
-// http://goo.gl/u2sDJ
-var AuthorizeSecurityGroupIngressExample = `
-<AuthorizeSecurityGroupIngressResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</AuthorizeSecurityGroupIngressResponse>
-`
-
-// http://goo.gl/Mz7xr
-var RevokeSecurityGroupIngressExample = `
-<RevokeSecurityGroupIngressResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</RevokeSecurityGroupIngressResponse>
-`
-
-// http://goo.gl/Vmkqc
-var CreateTagsExample = `
-<CreateTagsResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</CreateTagsResponse>
-`
-
-// http://goo.gl/awKeF
-var StartInstancesExample = `
-<StartInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <instancesSet>
- <item>
- <instanceId>i-10a64379</instanceId>
- <currentState>
- <code>0</code>
- <name>pending</name>
- </currentState>
- <previousState>
- <code>80</code>
- <name>stopped</name>
- </previousState>
- </item>
- </instancesSet>
-</StartInstancesResponse>
-`
-
-// http://goo.gl/436dJ
-var StopInstancesExample = `
-<StopInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <instancesSet>
- <item>
- <instanceId>i-10a64379</instanceId>
- <currentState>
- <code>64</code>
- <name>stopping</name>
- </currentState>
- <previousState>
- <code>16</code>
- <name>running</name>
- </previousState>
- </item>
- </instancesSet>
-</StopInstancesResponse>
-`
-
-// http://goo.gl/baoUf
-var RebootInstancesExample = `
-<RebootInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</RebootInstancesResponse>
-`
-
-var DescribeRouteTablesExample = `
-<DescribeRouteTablesResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>6f570b0b-9c18-4b07-bdec-73740dcf861aEXAMPLE</requestId>
- <routeTableSet>
- <item>
- <routeTableId>rtb-13ad487a</routeTableId>
- <vpcId>vpc-11ad4878</vpcId>
- <routeSet>
- <item>
- <destinationCidrBlock>10.0.0.0/22</destinationCidrBlock>
- <gatewayId>local</gatewayId>
- <state>active</state>
- <origin>CreateRouteTable</origin>
- </item>
- </routeSet>
- <associationSet>
- <item>
- <routeTableAssociationId>rtbassoc-12ad487b</routeTableAssociationId>
- <routeTableId>rtb-13ad487a</routeTableId>
- <main>true</main>
- </item>
- </associationSet>
- <tagSet/>
- </item>
- <item>
- <routeTableId>rtb-f9ad4890</routeTableId>
- <vpcId>vpc-11ad4878</vpcId>
- <routeSet>
- <item>
- <destinationCidrBlock>10.0.0.0/22</destinationCidrBlock>
- <gatewayId>local</gatewayId>
- <state>active</state>
- <origin>CreateRouteTable</origin>
- </item>
- <item>
- <destinationCidrBlock>0.0.0.0/0</destinationCidrBlock>
- <gatewayId>igw-eaad4883</gatewayId>
- <state>active</state>
- </item>
- </routeSet>
- <associationSet>
- <item>
- <routeTableAssociationId>rtbassoc-faad4893</routeTableAssociationId>
- <routeTableId>rtb-f9ad4890</routeTableId>
- <subnetId>subnet-15ad487c</subnetId>
- </item>
- </associationSet>
- <tagSet/>
- </item>
- </routeTableSet>
-</DescribeRouteTablesResponse>
-`
-
-var CreateRouteTableExample = `
-<CreateRouteTableResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59abcd43-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <routeTable>
- <routeTableId>rtb-f9ad4890</routeTableId>
- <vpcId>vpc-11ad4878</vpcId>
- <routeSet>
- <item>
- <destinationCidrBlock>10.0.0.0/22</destinationCidrBlock>
- <gatewayId>local</gatewayId>
- <state>active</state>
- </item>
- </routeSet>
- <associationSet/>
- <tagSet/>
- </routeTable>
-</CreateRouteTableResponse>
-`
-
-var DeleteRouteTableExample = `
-<DeleteRouteTableResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>49dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</DeleteRouteTableResponse>
-`
-
-var AssociateRouteTableExample = `
-<AssociateRouteTableResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <associationId>rtbassoc-f8ad4891</associationId>
-</AssociateRouteTableResponse>
-`
-
-var DisassociateRouteTableExample = `
-<DisassociateRouteTableResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</DisassociateRouteTableResponse>
-`
-
-var ReplaceRouteTableAssociationExample = `
-<ReplaceRouteTableAssociationResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59dbff89-35bd-4eac-88ed-be587EXAMPLE</requestId>
- <newAssociationId>rtbassoc-faad2958</newAssociationId>
-</ReplaceRouteTableAssociationResponse>
-`
-var DescribeReservedInstancesExample = `
-<DescribeReservedInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2014-06-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <reservedInstancesSet>
- <item>
- <reservedInstancesId>e5a2ff3b-7d14-494f-90af-0b5d0EXAMPLE</reservedInstancesId>
- <instanceType>m1.xlarge</instanceType>
- <availabilityZone>us-east-1b</availabilityZone>
- <duration>31536000</duration>
- <fixedPrice>61.0</fixedPrice>
- <usagePrice>0.034</usagePrice>
- <instanceCount>3</instanceCount>
- <productDescription>Linux/UNIX</productDescription>
- <state>active</state>
- <instanceTenancy>default</instanceTenancy>
- <currencyCode>USD</currencyCode>
- <offeringType>Light Utilization</offeringType>
- <recurringCharges/>
- </item>
- </reservedInstancesSet>
-</DescribeReservedInstancesResponse>
-`
-
-var DescribeVpcsExample = `
-<DescribeVpcsResponse xmlns="http://ec2.amazonaws.com/doc/2015-04-15/">
- <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
- <vpcSet>
- <item>
- <vpcId>vpc-1a2b3c4d</vpcId>
- <state>available</state>
- <cidrBlock>10.0.0.0/23</cidrBlock>
- <dhcpOptionsId>dopt-7a8b9c2d</dhcpOptionsId>
- <instanceTenancy>default</instanceTenancy>
- <isDefault>false</isDefault>
- <tagSet/>
- </item>
- </vpcSet>
-</DescribeVpcsResponse>
-`
-
-var CreateVpcExample = `
-<CreateVpcResponse xmlns="http://ec2.amazonaws.com/doc/2015-04-15/">
- <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
- <vpc>
- <vpcId>vpc-1a2b3c4d</vpcId>
- <state>pending</state>
- <cidrBlock>10.0.0.0/16</cidrBlock>
- <dhcpOptionsId>dopt-1a2b3c4d2</dhcpOptionsId>
- <instanceTenancy>default</instanceTenancy>
- <tagSet/>
- </vpc>
-</CreateVpcResponse>
-`
-
-var DeleteVpcExample = `
-<DeleteVpcResponse xmlns="http://ec2.amazonaws.com/doc/2015-04-15/">
- <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
- <return>true</return>
-</DeleteVpcResponse>
-`
-
-var CreateRouteExample = `
-<CreateRouteResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>b4998629-3000-437f-b382-cc96fEXAMPLE</requestId>
- <return>true</return>
-</CreateRouteResponse>
-`
-
-var DeleteRouteExample = `
-<DeleteRouteResponse xmlns="http://ec2.amazonaws.com/doc/2015-04-15/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
- <return>true</return>
-</DeleteRouteResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/ec2/sign.go b/vendor/github.com/goamz/goamz/ec2/sign.go
deleted file mode 100644
index 1c30f13bb..000000000
--- a/vendor/github.com/goamz/goamz/ec2/sign.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package ec2
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "github.com/goamz/goamz/aws"
- "sort"
- "strings"
-)
-
-// ----------------------------------------------------------------------------
-// EC2 signing (http://goo.gl/fQmAN)
-
-var b64 = base64.StdEncoding
-
-func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
- params["AWSAccessKeyId"] = auth.AccessKey
- params["SignatureVersion"] = "2"
- params["SignatureMethod"] = "HmacSHA256"
- if auth.Token() != "" {
- params["SecurityToken"] = auth.Token()
- }
-
- // AWS specifies that the parameters in a signed request must
- // be provided in the natural order of the keys. This is distinct
- // from the natural order of the encoded value of key=value.
- // Percent and equals affect the sorting order.
- var keys, sarray []string
- for k, _ := range params {
- keys = append(keys, k)
- }
- sort.Strings(keys)
- for _, k := range keys {
- sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(params[k]))
- }
- joined := strings.Join(sarray, "&")
- payload := method + "\n" + host + "\n" + path + "\n" + joined
- hash := hmac.New(sha256.New, []byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- params["Signature"] = string(signature)
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/sign_test.go b/vendor/github.com/goamz/goamz/ec2/sign_test.go
deleted file mode 100644
index bc6996cce..000000000
--- a/vendor/github.com/goamz/goamz/ec2/sign_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package ec2_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/ec2"
- . "gopkg.in/check.v1"
-)
-
-// EC2 ReST authentication docs: http://goo.gl/fQmAN
-
-var testAuth = aws.Auth{AccessKey: "user", SecretKey: "secret"}
-
-func (s *S) TestBasicSignature(c *C) {
- params := map[string]string{}
- ec2.Sign(testAuth, "GET", "/path", params, "localhost")
- c.Assert(params["SignatureVersion"], Equals, "2")
- c.Assert(params["SignatureMethod"], Equals, "HmacSHA256")
- expected := "6lSe5QyXum0jMVc7cOUz32/52ZnL7N5RyKRk/09yiK4="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestParamSignature(c *C) {
- params := map[string]string{
- "param1": "value1",
- "param2": "value2",
- "param3": "value3",
- }
- ec2.Sign(testAuth, "GET", "/path", params, "localhost")
- expected := "XWOR4+0lmK8bD8CGDGZ4kfuSPbb2JibLJiCl/OPu1oU="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestManyParams(c *C) {
- params := map[string]string{
- "param1": "value10",
- "param2": "value2",
- "param3": "value3",
- "param4": "value4",
- "param5": "value5",
- "param6": "value6",
- "param7": "value7",
- "param8": "value8",
- "param9": "value9",
- "param10": "value1",
- }
- ec2.Sign(testAuth, "GET", "/path", params, "localhost")
- expected := "di0sjxIvezUgQ1SIL6i+C/H8lL+U0CQ9frLIak8jkVg="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestEscaping(c *C) {
- params := map[string]string{"Nonce": "+ +"}
- ec2.Sign(testAuth, "GET", "/path", params, "localhost")
- c.Assert(params["Nonce"], Equals, "+ +")
- expected := "bqffDELReIqwjg/W0DnsnVUmfLK4wXVLO4/LuG+1VFA="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestSignatureExample1(c *C) {
- params := map[string]string{
- "Timestamp": "2009-02-01T12:53:20+00:00",
- "Version": "2007-11-07",
- "Action": "ListDomains",
- }
- ec2.Sign(aws.Auth{AccessKey: "access", SecretKey: "secret"}, "GET", "/", params, "sdb.amazonaws.com")
- expected := "okj96/5ucWBSc1uR2zXVfm6mDHtgfNv657rRtt/aunQ="
- c.Assert(params["Signature"], Equals, expected)
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/vpc.go b/vendor/github.com/goamz/goamz/ec2/vpc.go
deleted file mode 100644
index 3a2ff7c6e..000000000
--- a/vendor/github.com/goamz/goamz/ec2/vpc.go
+++ /dev/null
@@ -1,399 +0,0 @@
-package ec2
-
-// RouteTable describes a route table which contains a set of rules, called routes
-// that are used to determine where network traffic is directed.
-//
-// See http://goo.gl/bI9hkg for more details.
-type RouteTable struct {
- Id string `xml:"routeTableId"`
- VpcId string `xml:"vpcId"`
- Routes []Route `xml:"routeSet>item"`
- Associations []RouteTableAssociation `xml:"associationSet>item"`
- PropagatingVgws []PropagatingVgw `xml:"propagatingVgwSet>item"`
- Tags []Tag `xml:"tagSet>item"`
-}
-
-// Route describes a route in a route table.
-//
-// See http://goo.gl/hE5Kxe for more details.
-type Route struct {
- DestinationCidrBlock string `xml:"destinationCidrBlock"` // The CIDR block used for the destination match.
- GatewayId string `xml:"gatewayId"` // The ID of a gateway attached to your VPC.
- InstanceId string `xml:"instanceId"` // The ID of a NAT instance in your VPC.
- InstanceOwnerId string `xml:"instanceOwnerId"` // The AWS account ID of the owner of the instance.
- NetworkInterfaceId string `xml:"networkInterfaceId"` // The ID of the network interface.
- State string `xml:"state"` // The state of the route. Valid values: active | blackhole
- Origin string `xml:"origin"` // Describes how the route was created. Valid values: Valid values: CreateRouteTable | CreateRoute | EnableVgwRoutePropagation
- VpcPeeringConnectionId string `xml:"vpcPeeringConnectionId"` // The ID of the VPC peering connection.
-}
-
-// RouteTableAssociation describes an association between a route table and a subnet.
-//
-// See http://goo.gl/BZB8o8 for more details.
-type RouteTableAssociation struct {
- Id string `xml:"routeTableAssociationId"` // The ID of the association between a route table and a subnet.
- RouteTableId string `xml:"routeTableId"` // The ID of the route table.
- SubnetId string `xml:"subnetId"` // The ID of the subnet.
- Main bool `xml:"main"` // Indicates whether this is the main route table.
-}
-
-// PropagatingVgw describes a virtual private gateway propagating route.
-//
-// See http://goo.gl/myGQtG for more details.
-type PropagatingVgw struct {
- GatewayId string `xml:"gatewayID"`
-}
-
-// CreateRouteTableResp represents a response from a CreateRouteTable request
-//
-// See http://goo.gl/LD0TqP for more details.
-type CreateRouteTableResp struct {
- RequestId string `xml:"requestId"`
- RouteTable RouteTable `xml:"routeTable"`
-}
-
-// CreateRouteTable creates a route table for the specified VPC.
-// After you create a route table, you can add routes and associate the table with a subnet.
-//
-// See http://goo.gl/V9h6gE for more details..
-func (ec2 *EC2) CreateRouteTable(vpcId string) (resp *CreateRouteTableResp, err error) {
- params := makeParams("CreateRouteTable")
- params["VpcId"] = vpcId
- resp = &CreateRouteTableResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// DescribeRouteTablesResp represents a response from a DescribeRouteTables call
-//
-// See http://goo.gl/T3tVsg for more details.
-type DescribeRouteTablesResp struct {
- RequestId string `xml:"requestId"`
- RouteTables []RouteTable `xml:"routeTableSet>item"`
-}
-
-// DescribeRouteTables describes one or more of your route tables
-//
-// See http://goo.gl/S0RVos for more details.
-func (ec2 *EC2) DescribeRouteTables(routeTableIds []string, filter *Filter) (resp *DescribeRouteTablesResp, err error) {
- params := makeParams("DescribeRouteTables")
- addParamsList(params, "RouteTableId", routeTableIds)
- filter.addParams(params)
- resp = &DescribeRouteTablesResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// AssociateRouteTableResp represents a response from an AssociateRouteTable call
-//
-// See http://goo.gl/T4KlYk for more details.
-type AssociateRouteTableResp struct {
- RequestId string `xml:"requestId"`
- AssociationId string `xml:"associationId"`
-}
-
-// AssociateRouteTable associates a subnet with a route table.
-//
-// The subnet and route table must be in the same VPC. This association causes
-// traffic originating from the subnet to be routed according to the routes
-// in the route table. The action returns an association ID, which you need in
-// order to disassociate the route table from the subnet later.
-// A route table can be associated with multiple subnets.
-//
-// See http://goo.gl/bfnONU for more details.
-func (ec2 *EC2) AssociateRouteTable(routeTableId, subnetId string) (resp *AssociateRouteTableResp, err error) {
- params := makeParams("AssociateRouteTable")
- params["RouteTableId"] = routeTableId
- params["SubnetId"] = subnetId
- resp = &AssociateRouteTableResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// DisassociateRouteTableResp represents the response from a DisassociateRouteTable request
-//
-// See http://goo.gl/1v4reT for more details.
-type DisassociateRouteTableResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"` // True if the request succeeds
-}
-
-// DisassociateRouteTable disassociates a subnet from a route table.
-//
-// See http://goo.gl/A4NJum for more details.
-func (ec2 *EC2) DisassociateRouteTable(associationId string) (resp *DisassociateRouteTableResp, err error) {
- params := makeParams("DisassociateRouteTable")
- params["AssociationId"] = associationId
- resp = &DisassociateRouteTableResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ReplaceRouteTableAssociationResp represents a response from a ReplaceRouteTableAssociation call
-//
-// See http://goo.gl/VhILGe for more details.
-type ReplaceRouteTableAssociationResp struct {
- RequestId string `xml:"requestId"`
- NewAssociationId string `xml:"newAssociationId"`
-}
-
-// ReplaceRouteTableAssociation changes the route table associated with a given subnet in a VPC.
-//
-// See http://goo.gl/kiit8j for more details.
-func (ec2 *EC2) ReplaceRouteTableAssociation(associationId, routeTableId string) (resp *ReplaceRouteTableAssociationResp, err error) {
- params := makeParams("ReplaceRouteTableAssociation")
- params["AssociationId"] = associationId
- params["RouteTableId"] = routeTableId
- resp = &ReplaceRouteTableAssociationResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// DeleteRouteTableResp represents a response from a DeleteRouteTable request
-//
-// See http://goo.gl/b8usig for more details.
-type DeleteRouteTableResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"` // True if the request succeeds
-}
-
-// DeleteRouteTable deletes the specified route table.
-// You must disassociate the route table from any subnets before you can delete it.
-// You can't delete the main route table.
-//
-// See http://goo.gl/crHxT2 for more details.
-func (ec2 *EC2) DeleteRouteTable(routeTableId string) (resp *DeleteRouteTableResp, err error) {
- params := makeParams("DeleteRouteTable")
- params["RouteTableId"] = routeTableId
- resp = &DeleteRouteTableResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// VPC describes a VPC.
-//
-// See http://goo.gl/WjX0Es for more details.
-type VPC struct {
- CidrBlock string `xml:"cidrBlock"`
- DHCPOptionsID string `xml:"dhcpOptionsId"`
- State string `xml:"state"`
- VpcId string `xml:"vpcId"`
- InstanceTenancy string `xml:"instanceTenancy"`
- IsDefault bool `xml:"isDefault"`
- Tags []Tag `xml:"tagSet>item"`
-}
-
-// CreateVpcResp represents a response from a CreateVpcResp request
-//
-// See http://goo.gl/QoK11F for more details.
-type CreateVpcResp struct {
- RequestId string `xml:"requestId"`
- VPC VPC `xml:"vpc"` // Information about the VPC.
-}
-
-// CreateVpc creates a VPC with the specified CIDR block.
-//
-// The smallest VPC you can create uses a /28 netmask (16 IP addresses),
-// and the largest uses a /16 netmask (65,536 IP addresses).
-//
-// By default, each instance you launch in the VPC has the default DHCP options,
-// which includes only a default DNS server that Amazon provides (AmazonProvidedDNS).
-//
-// See http://goo.gl/QoK11F for more details.
-func (ec2 *EC2) CreateVpc(cidrBlock, instanceTenancy string) (resp *CreateVpcResp, err error) {
- params := makeParams("CreateVpc")
- params["CidrBlock"] = cidrBlock
-
- if instanceTenancy != "" {
- params["InstanceTenancy"] = instanceTenancy
- }
-
- resp = &CreateVpcResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
-
-// DeleteVpcResp represents a response from a DeleteVpc request
-//
-// See http://goo.gl/qawyrz for more details.
-type DeleteVpcResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"` // True if the request succeeds
-}
-
-// DeleteVpc deletes the specified VPC.
-//
-// You must detach or delete all gateways and resources that are associated with
-// the VPC before you can delete it. For example, you must terminate all
-// instances running in the VPC, delete all security groups associated with
-// the VPC (except the default one), delete all route tables associated with
-// the VPC (except the default one), and so on.
-//
-// See http://goo.gl/qawyrz for more details.
-func (ec2 *EC2) DeleteVpc(vpcId string) (resp *DeleteVpcResp, err error) {
- params := makeParams("DeleteVpc")
- params["VpcId"] = vpcId
-
- resp = &DeleteVpcResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// DescribeVpcsResp represents a response from a DescribeVpcs request
-//
-// See http://goo.gl/DWQWvZ for more details.
-type DescribeVpcsResp struct {
- RequestId string `xml:"requestId"`
- VPCs []VPC `xml:"vpcSet>item"` // Information about one or more VPCs.
-}
-
-// DescribeVpcs describes one or more of your VPCs.
-//
-// See http://goo.gl/DWQWvZ for more details.
-func (ec2 *EC2) DescribeVpcs(vpcIds []string, filter *Filter) (resp *DescribeVpcsResp, err error) {
- params := makeParams("DescribeVpcs")
- addParamsList(params, "VpcId", vpcIds)
- filter.addParams(params)
- resp = &DescribeVpcsResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
-
-// DeleteRouteResp represents a response from a DeleteRoute request
-//
-// See http://goo.gl/Uqyt3w for more details.
-type DeleteRouteResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"` // True if the request succeeds
-}
-
-// DeleteRoute deletes the specified route from the specified route table.
-//
-// See http://goo.gl/Uqyt3w for more details.
-func (ec2 *EC2) DeleteRoute(routeTableId, destinationCidrBlock string) (resp *DeleteRouteResp, err error) {
- params := makeParams("DeleteRoute")
- params["RouteTableId"] = routeTableId
- params["DestinationCidrBlock"] = destinationCidrBlock
- resp = &DeleteRouteResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// CreateRouteResp represents a response from a CreateRoute request
-//
-// See http://goo.gl/c6Bg7e for more details.
-type CreateRouteResp struct {
- RequestId string `xml:"requestId"`
- Return bool `xml:"return"` // True if the request succeeds
-}
-
-// CreateRoute structure contains the options for a CreateRoute API call.
-type CreateRoute struct {
- DestinationCidrBlock string
- GatewayId string
- InstanceId string
- NetworkInterfaceId string
- VpcPeeringConnectionId string
-}
-
-// CreateRoute creates a route in a route table within a VPC.
-// You must specify one of the following targets: Internet gateway or virtual
-// private gateway, NAT instance, VPC peering connection, or network interface.
-//
-// See http://goo.gl/c6Bg7e for more details.
-func (ec2 *EC2) CreateRoute(routeTableId string, options *CreateRoute) (resp *CreateRouteResp, err error) {
- params := makeParams("CreateRoute")
- params["RouteTableId"] = routeTableId
- if options.DestinationCidrBlock != "" {
- params["DestinationCidrBlock"] = options.DestinationCidrBlock
- }
- if options.GatewayId != "" {
- params["GatewayId"] = options.GatewayId
- }
- if options.InstanceId != "" {
- params["InstanceId"] = options.InstanceId
- }
- if options.NetworkInterfaceId != "" {
- params["NetworkInterfaceId"] = options.NetworkInterfaceId
- }
- if options.VpcPeeringConnectionId != "" {
- params["VpcPeeringConnectionId"] = options.VpcPeeringConnectionId
- }
- resp = &CreateRouteResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Subnet describes a subnet
-//
-// See http://goo.gl/bifW4R
-type Subnet struct {
- AvailabilityZone string `xml:"availabilityZone"`
- AvailableIpAddressCount int `xml:"availableIpAddressCount"`
- CidrBlock string `xml:"cidrBlock"`
- DefaultForAZ bool `xml:"defaultForAz"`
- MapPublicIpOnLaunch bool `xml:"mapPublicIpOnLaunch"`
- State string `xml:"state"`
- SubnetId string `xml:"subnetId"`
- Tags []Tag `xml:"tagSet>item"`
- VpcId string `xml:"vpcId"`
-}
-
-// DescribeSubnetsResp represents a response from a DescribeSubnets request
-//
-// See https://goo.gl/1s0UQd for more details.
-type DescribeSubnetsResp struct {
- RequestId string `xml:"requestId"`
- Subnets []Subnet `xml:"subnetSet>item"`
-}
-
-// DescribeSubnets describes one or more Subnets.
-//
-// See https://goo.gl/1s0UQd for more details.
-func (ec2 *EC2) DescribeSubnets(subnetIds []string, filter *Filter) (resp *DescribeSubnetsResp, err error) {
- params := makeParams("DescribeSubnets")
- addParamsList(params, "SubnetId", subnetIds)
- filter.addParams(params)
- resp = &DescribeSubnetsResp{}
- err = ec2.query(params, resp)
- if err != nil {
- return nil, err
- }
-
- return
-}
diff --git a/vendor/github.com/goamz/goamz/ec2/vpc_test.go b/vendor/github.com/goamz/goamz/ec2/vpc_test.go
deleted file mode 100644
index a6e67eeed..000000000
--- a/vendor/github.com/goamz/goamz/ec2/vpc_test.go
+++ /dev/null
@@ -1,224 +0,0 @@
-package ec2_test
-
-import (
- "github.com/goamz/goamz/ec2"
- . "gopkg.in/check.v1"
-)
-
-func (s *S) TestCreateRouteTable(c *C) {
- testServer.Response(200, nil, CreateRouteTableExample)
-
- resp, err := s.ec2.CreateRouteTable("vpc-11ad4878")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"CreateRouteTable"})
- c.Assert(req.Form["VpcId"], DeepEquals, []string{"vpc-11ad4878"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59abcd43-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.RouteTable.Id, Equals, "rtb-f9ad4890")
- c.Assert(resp.RouteTable.VpcId, Equals, "vpc-11ad4878")
- c.Assert(resp.RouteTable.Routes, HasLen, 1)
- c.Assert(resp.RouteTable.Routes[0], DeepEquals, ec2.Route{
- DestinationCidrBlock: "10.0.0.0/22",
- GatewayId: "local",
- State: "active",
- })
- c.Assert(resp.RouteTable.Associations, HasLen, 0)
- c.Assert(resp.RouteTable.Tags, HasLen, 0)
-}
-
-func (s *S) TestDescribeRouteTables(c *C) {
- testServer.Response(200, nil, DescribeRouteTablesExample)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.DescribeRouteTables([]string{"rt1", "rt2"}, nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeRouteTables"})
- c.Assert(req.Form["RouteTableId.1"], DeepEquals, []string{"rt1"})
- c.Assert(req.Form["RouteTableId.2"], DeepEquals, []string{"rt2"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "6f570b0b-9c18-4b07-bdec-73740dcf861aEXAMPLE")
- c.Assert(resp.RouteTables, HasLen, 2)
-
- rt1 := resp.RouteTables[0]
- c.Assert(rt1.Id, Equals, "rtb-13ad487a")
- c.Assert(rt1.VpcId, Equals, "vpc-11ad4878")
- c.Assert(rt1.Routes, DeepEquals, []ec2.Route{
- {DestinationCidrBlock: "10.0.0.0/22", GatewayId: "local", State: "active", Origin: "CreateRouteTable"},
- })
- c.Assert(rt1.Associations, DeepEquals, []ec2.RouteTableAssociation{
- {Id: "rtbassoc-12ad487b", RouteTableId: "rtb-13ad487a", Main: true},
- })
-
- rt2 := resp.RouteTables[1]
- c.Assert(rt2.Id, Equals, "rtb-f9ad4890")
- c.Assert(rt2.VpcId, Equals, "vpc-11ad4878")
- c.Assert(rt2.Routes, DeepEquals, []ec2.Route{
- {DestinationCidrBlock: "10.0.0.0/22", GatewayId: "local", State: "active", Origin: "CreateRouteTable"},
- {DestinationCidrBlock: "0.0.0.0/0", GatewayId: "igw-eaad4883", State: "active"},
- })
- c.Assert(rt2.Associations, DeepEquals, []ec2.RouteTableAssociation{
- {Id: "rtbassoc-faad4893", RouteTableId: "rtb-f9ad4890", SubnetId: "subnet-15ad487c"},
- })
-}
-
-func (s *S) TestAssociateRouteTable(c *C) {
- testServer.Response(200, nil, AssociateRouteTableExample)
-
- resp, err := s.ec2.AssociateRouteTable("rtb-e4ad488d", "subnet-15ad487c")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"AssociateRouteTable"})
- c.Assert(req.Form["RouteTableId"], DeepEquals, []string{"rtb-e4ad488d"})
- c.Assert(req.Form["SubnetId"], DeepEquals, []string{"subnet-15ad487c"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.AssociationId, Equals, "rtbassoc-f8ad4891")
-}
-
-func (s *S) TestDisassociateRouteTable(c *C) {
- testServer.Response(200, nil, DisassociateRouteTableExample)
-
- resp, err := s.ec2.DisassociateRouteTable("rtbassoc-f8ad4891")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DisassociateRouteTable"})
- c.Assert(req.Form["AssociationId"], DeepEquals, []string{"rtbassoc-f8ad4891"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Return, Equals, true)
-}
-
-func (s *S) TestReplaceRouteTableAssociation(c *C) {
- testServer.Response(200, nil, ReplaceRouteTableAssociationExample)
-
- resp, err := s.ec2.ReplaceRouteTableAssociation("rtbassoc-f8ad4891", "rtb-f9ad4890")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"ReplaceRouteTableAssociation"})
- c.Assert(req.Form["RouteTableId"], DeepEquals, []string{"rtb-f9ad4890"})
- c.Assert(req.Form["AssociationId"], DeepEquals, []string{"rtbassoc-f8ad4891"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-88ed-be587EXAMPLE")
- c.Assert(resp.NewAssociationId, Equals, "rtbassoc-faad2958")
-}
-
-func (s *S) TestDeleteRouteTable(c *C) {
- testServer.Response(200, nil, DeleteRouteTableExample)
-
- resp, err := s.ec2.DeleteRouteTable("rtb-f9ad4890")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteRouteTable"})
- c.Assert(req.Form["RouteTableId"], DeepEquals, []string{"rtb-f9ad4890"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "49dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Return, Equals, true)
-}
-
-func (s *S) TestDescribeVpcs(c *C) {
- testServer.Response(200, nil, DescribeVpcsExample)
-
- filter := ec2.NewFilter()
- filter.Add("key1", "value1")
- filter.Add("key2", "value2", "value3")
-
- resp, err := s.ec2.DescribeVpcs([]string{"id1", "id2"}, filter)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeVpcs"})
- c.Assert(req.Form["VpcId.1"], DeepEquals, []string{"id1"})
- c.Assert(req.Form["VpcId.2"], DeepEquals, []string{"id2"})
- c.Assert(req.Form["VpcId.3"], IsNil)
- c.Assert(req.Form["Filter.1.Name"], DeepEquals, []string{"key1"})
- c.Assert(req.Form["Filter.1.Value.1"], DeepEquals, []string{"value1"})
- c.Assert(req.Form["Filter.1.Value.2"], IsNil)
- c.Assert(req.Form["Filter.2.Name"], DeepEquals, []string{"key2"})
- c.Assert(req.Form["Filter.2.Value.1"], DeepEquals, []string{"value2"})
- c.Assert(req.Form["Filter.2.Value.2"], DeepEquals, []string{"value3"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
- c.Assert(resp.VPCs[0].VpcId, Equals, "vpc-1a2b3c4d")
- c.Assert(resp.VPCs, HasLen, 1)
-}
-
-func (s *S) TestCreateVpc(c *C) {
- testServer.Response(200, nil, CreateVpcExample)
-
- resp, err := s.ec2.CreateVpc("foo", "bar")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["CidrBlock"], DeepEquals, []string{"foo"})
- c.Assert(req.Form["InstanceTenancy"], DeepEquals, []string{"bar"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
- c.Assert(resp.VPC.VpcId, Equals, "vpc-1a2b3c4d")
- c.Assert(resp.VPC.State, Equals, "pending")
- c.Assert(resp.VPC.CidrBlock, Equals, "10.0.0.0/16")
- c.Assert(resp.VPC.DHCPOptionsID, Equals, "dopt-1a2b3c4d2")
- c.Assert(resp.VPC.InstanceTenancy, Equals, "default")
-}
-
-func (s *S) TestDeleteVpc(c *C) {
- testServer.Response(200, nil, DeleteVpcExample)
-
- resp, err := s.ec2.DeleteVpc("id1")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["VpcId"], DeepEquals, []string{"id1"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestCreateRoute(c *C) {
- testServer.Response(200, nil, CreateRouteExample)
-
- options := ec2.CreateRoute{
- DestinationCidrBlock: "12.34.56.78/90",
- GatewayId: "foo",
- InstanceId: "i-bar",
- NetworkInterfaceId: "foobar",
- VpcPeeringConnectionId: "barfoo",
- }
-
- resp, err := s.ec2.CreateRoute("rtb-deadbeef", &options)
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["RouteTableId"], DeepEquals, []string{"rtb-deadbeef"})
- c.Assert(req.Form["DestinationCidrBlock"], DeepEquals, []string{"12.34.56.78/90"})
- c.Assert(req.Form["GatewayId"], DeepEquals, []string{"foo"})
- c.Assert(req.Form["InstanceId"], DeepEquals, []string{"i-bar"})
- c.Assert(req.Form["NetworkInterfaceId"], DeepEquals, []string{"foobar"})
- c.Assert(req.Form["VpcPeeringConnectionId"], DeepEquals, []string{"barfoo"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "b4998629-3000-437f-b382-cc96fEXAMPLE")
- c.Assert(resp.Return, Equals, true)
-}
-
-func (s *S) TestDeleteRoute(c *C) {
- testServer.Response(200, nil, DeleteRouteExample)
-
- resp, err := s.ec2.DeleteRoute("rtb-baddcafe", "foobar")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["RouteTableId"], DeepEquals, []string{"rtb-baddcafe"})
- c.Assert(req.Form["DestinationCidrBlock"], DeepEquals, []string{"foobar"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
- c.Assert(resp.Return, Equals, true)
-}
diff --git a/vendor/github.com/goamz/goamz/ecs/ecs.go b/vendor/github.com/goamz/goamz/ecs/ecs.go
deleted file mode 100644
index 89c7243d4..000000000
--- a/vendor/github.com/goamz/goamz/ecs/ecs.go
+++ /dev/null
@@ -1,1075 +0,0 @@
-//
-// ecs: This package provides types and functions to interact with the AWS EC2 Container Service API
-//
-// Depends on https://github.com/goamz/goamz
-//
-// Author Boyan Dimitrov <boyann@gmail.com>
-//
-
-package ecs
-
-import (
- "encoding/xml"
- "fmt"
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-const debug = false
-
-var timeNow = time.Now
-
-// ECS contains the details of the AWS region to perform operations against.
-type ECS struct {
- aws.Auth
- aws.Region
-}
-
-// New creates a new ECS Client.
-func New(auth aws.Auth, region aws.Region) *ECS {
- return &ECS{auth, region}
-}
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-// Error encapsulates an error returned by the AWS ECS API.
-//
-// See http://goo.gl/VZGuC for more details.
-type Error struct {
- // HTTP status code (200, 403, ...)
- StatusCode int
- // ECS error code ("UnsupportedOperation", ...)
- Code string
- // The error type
- Type string
- // The human-oriented error message
- Message string
- RequestId string `xml:"RequestID"`
-}
-
-func (err *Error) Error() string {
- if err.Code == "" {
- return err.Message
- }
-
- return fmt.Sprintf("%s (%s)", err.Message, err.Code)
-}
-
-type xmlErrors struct {
- RequestId string `xml:"RequestId"`
- Errors []Error `xml:"Error"`
-}
-
-func (e *ECS) query(params map[string]string, resp interface{}) error {
- params["Version"] = "2014-11-13"
- data := strings.NewReader(multimap(params).Encode())
-
- hreq, err := http.NewRequest("POST", e.Region.ECSEndpoint+"/", data)
- if err != nil {
- return err
- }
-
- hreq.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
-
- token := e.Auth.Token()
- if token != "" {
- hreq.Header.Set("X-Amz-Security-Token", token)
- }
-
- signer := aws.NewV4Signer(e.Auth, "ecs", e.Region)
- signer.Sign(hreq)
-
- if debug {
- log.Printf("%v -> {\n", hreq)
- }
- r, err := http.DefaultClient.Do(hreq)
-
- if err != nil {
- log.Printf("Error calling Amazon %v", err)
- return err
- }
-
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("response:\n")
- log.Printf("%v\n}\n", string(dump))
- }
- if r.StatusCode != 200 {
- return buildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-func buildError(r *http.Response) error {
- var (
- err Error
- errors xmlErrors
- )
- xml.NewDecoder(r.Body).Decode(&errors)
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
-
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-func makeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-func addParamsList(params map[string]string, label string, ids []string) {
- for i, id := range ids {
- params[label+"."+strconv.Itoa(i+1)] = id
- }
-}
-
-// ----------------------------------------------------------------------------
-// ECS types and related functions.
-
-// SimpleResp is the beic response from most actions.
-type SimpleResp struct {
- XMLName xml.Name
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// Cluster encapsulates the cluster datatype
-//
-// See
-type Cluster struct {
- ClusterArn string `xml:"clusterArn"`
- ClusterName string `xml:"clusterName"`
- Status string `xml:"status"`
-}
-
-// CreateClusterReq encapsulates the createcluster req params
-type CreateClusterReq struct {
- ClusterName string
-}
-
-// CreateClusterResp encapsulates the createcluster response
-type CreateClusterResp struct {
- Cluster Cluster `xml:"CreateClusterResult>cluster"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// CreateCluster creates a new Amazon ECS cluster. By default, your account
-// will receive a default cluster when you launch your first container instance
-func (e *ECS) CreateCluster(req *CreateClusterReq) (resp *CreateClusterResp, err error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("CreateCluster")
- params["clusterName"] = req.ClusterName
-
- resp = new(CreateClusterResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Resource describes the resources available for a container instance.
-type Resource struct {
- DoubleValue float64 `xml:"doubleValue"`
- IntegerValue int32 `xml:"integerValue"`
- LongValue int64 `xml:"longValue"`
- Name string `xml:"name"`
- StringSetValue []string `xml:"stringSetValue>member"`
- Type string `xml:"type"`
-}
-
-// ContainerInstance represents n Amazon EC2 instance that is running
-// the Amazon ECS agent and has been registered with a cluster
-type ContainerInstance struct {
- AgentConnected bool `xml:"agentConnected"`
- ContainerInstanceArn string `xml:"containerInstanceArn"`
- Ec2InstanceId string `xml:"ec2InstanceId"`
- RegisteredResources []Resource `xml:"registeredResources>member"`
- RemainingResources []Resource `xml:"remainingResources>member"`
- Status string `xml:"status"`
-}
-
-// DeregisterContainerInstanceReq encapsulates DeregisterContainerInstance request params
-type DeregisterContainerInstanceReq struct {
- Cluster string
- // arn:aws:ecs:region:aws_account_id:container-instance/container_instance_UUID.
- ContainerInstance string
- Force bool
-}
-
-// DeregisterContainerInstanceResp encapsulates DeregisterContainerInstance response
-type DeregisterContainerInstanceResp struct {
- ContainerInstance ContainerInstance `xml:"DeregisterContainerInstanceResult>containerInstance"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DeregisterContainerInstance deregisters an Amazon ECS container instance from the specified cluster
-func (e *ECS) DeregisterContainerInstance(req *DeregisterContainerInstanceReq) (
- resp *DeregisterContainerInstanceResp, err error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("DeregisterContainerInstance")
- params["containerInstance"] = req.ContainerInstance
- params["force"] = strconv.FormatBool(req.Force)
-
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
-
- resp = new(DeregisterContainerInstanceResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// PortMapping encapsulates the PortMapping data type
-type PortMapping struct {
- ContainerPort int32 `xml:containerPort`
- HostPort int32 `xml:hostPort`
-}
-
-// KeyValuePair encapsulates the KeyValuePair data type
-type KeyValuePair struct {
- Name string `xml:"name"`
- Value string `xml:"value"`
-}
-
-// MountPoint encapsulates the MountPoint data type
-type MountPoint struct {
- ContainerPath string `xml:"containerPath"`
- ReadOnly bool `xml:"readOnly"`
- SourceVolume string `xml:"sourceVolume"`
-}
-
-// VolumeFrom encapsulates the VolumeFrom data type
-type VolumeFrom struct {
- ReadOnly bool `xml:"readOnly"`
- SourceContainer string `xml:"sourceContainer"`
-}
-
-// HostVolumeProperties encapsulates the HostVolumeProperties data type
-type HostVolumeProperties struct {
- SourcePath string `xml:"sourcePath"`
-}
-
-// Volume encapsulates the Volume data type
-type Volume struct {
- Host HostVolumeProperties `xml:"host"`
- Name string `xml:"name"`
-}
-
-// ContainerDefinition encapsulates the container definition type
-// Container definitions are used in task definitions to describe
-// the different containers that are launched as part of a task
-type ContainerDefinition struct {
- Command []string `xml:"command>member"`
- Cpu int32 `xml:"cpu"`
- EntryPoint []string `xml:"entryPoint>member"`
- Environment []KeyValuePair `xml:"environment>member"`
- Essential bool `xml:"essential"`
- Image string `xml:"image"`
- Links []string `xml:"links>member"`
- Memory int32 `xml:"memory"`
- MountPoints []MountPoint `xml:"mountPoints>member"`
- Name string `xml:"name"`
- PortMappings []PortMapping `xml:"portMappings>member"`
- VolumesFrom []VolumeFrom `xml:"volumesFrom>member"`
-}
-
-// TaskDefinition encapsulates the task definition type
-type TaskDefinition struct {
- ContainerDefinitions []ContainerDefinition `xml:"containerDefinitions>member"`
- Family string `xml:"family"`
- Revision int32 `xml:"revision"`
- TaskDefinitionArn string `xml:"taskDefinitionArn"`
- Status string `xml:"status"`
- Volumes []Volume `xml:"volumes>member"`
-}
-
-// DeregisterTaskDefinitionReq encapsulates DeregisterTaskDefinition req params
-type DeregisterTaskDefinitionReq struct {
- TaskDefinition string
-}
-
-// DeregisterTaskDefinitionResp encapsuates the DeregisterTaskDefinition response
-type DeregisterTaskDefinitionResp struct {
- TaskDefinition TaskDefinition `xml:"DeregisterTaskDefinitionResult>taskDefinition"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DeregisterTaskDefinition deregisters the specified task definition
-func (e *ECS) DeregisterTaskDefinition(req *DeregisterTaskDefinitionReq) (
- *DeregisterTaskDefinitionResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("DeregisterTaskDefinition")
- params["taskDefinition"] = req.TaskDefinition
-
- resp := new(DeregisterTaskDefinitionResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Failure encapsulates the failure type
-type Failure struct {
- Arn string `xml:"arn"`
- Reason string `xml:"reason"`
-}
-
-// DescribeClustersReq encapsulates DescribeClusters req params
-type DescribeClustersReq struct {
- Clusters []string
-}
-
-// DescribeClustersResp encapsuates the DescribeClusters response
-type DescribeClustersResp struct {
- Clusters []Cluster `xml:"DescribeClustersResult>clusters>member"`
- Failures []Failure `xml:"DescribeClustersResult>failures>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeClusters describes one or more of your clusters
-func (e *ECS) DescribeClusters(req *DescribeClustersReq) (*DescribeClustersResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("DescribeClusters")
- if len(req.Clusters) > 0 {
- addParamsList(params, "clusters.member", req.Clusters)
- }
-
- resp := new(DescribeClustersResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeContainerInstancesReq ecapsulates DescribeContainerInstances req params
-type DescribeContainerInstancesReq struct {
- Cluster string
- ContainerInstances []string
-}
-
-// DescribeContainerInstancesResp ecapsulates DescribeContainerInstances response
-type DescribeContainerInstancesResp struct {
- ContainerInstances []ContainerInstance `xml:"DescribeContainerInstancesResult>containerInstances>member"`
- Failures []Failure `xml:"DescribeContainerInstancesResult>failures>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeContainerInstances describes Amazon EC2 Container Service container instances
-// Returns metadata about registered and remaining resources on each container instance requested
-func (e *ECS) DescribeContainerInstances(req *DescribeContainerInstancesReq) (
- *DescribeContainerInstancesResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("DescribeContainerInstances")
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- if len(req.ContainerInstances) > 0 {
- addParamsList(params, "containerInstances.member", req.ContainerInstances)
- }
-
- resp := new(DescribeContainerInstancesResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DescribeTaskDefinitionReq encapsulates DescribeTaskDefinition req params
-type DescribeTaskDefinitionReq struct {
- TaskDefinition string
-}
-
-// DescribeTaskDefinitionResp encapsuates the DescribeTaskDefinition response
-type DescribeTaskDefinitionResp struct {
- TaskDefinition TaskDefinition `xml:"DescribeTaskDefinitionResult>taskDefinition"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeTaskDefinition describes a task definition
-func (e *ECS) DescribeTaskDefinition(req *DescribeTaskDefinitionReq) (
- *DescribeTaskDefinitionResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("DescribeTaskDefinition")
- params["taskDefinition"] = req.TaskDefinition
-
- resp := new(DescribeTaskDefinitionResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// NetworkBinding encapsulates the network binding data type
-type NetworkBinding struct {
- BindIp string `xml:"bindIp"`
- ContainerPort int32 `xml:"containerPort"`
- HostPort int32 `xml:"hostPort"`
-}
-
-// Container encapsulates the container data type
-type Container struct {
- ContainerArn string `xml:"containerArn"`
- ExitCode int32 `xml:"exitCode"`
- LastStatus string `xml:"lastStatus"`
- Name string `xml:"name"`
- NetworkBindings []NetworkBinding `xml:"networkBindings>member"`
- Reason string `xml:"reason"`
- TaskArn string `xml:"taskArn"`
-}
-
-// ContainerOverride encapsulates the container override data type
-type ContainerOverride struct {
- Command []string `xml:"command>member"`
- Environment []KeyValuePair `xml:"environment>member"`
- Name string `xml:"name"`
-}
-
-// TaskOverride encapsulates the task override data type
-type TaskOverride struct {
- ContainerOverrides []ContainerOverride `xml:"containerOverrides>member"`
-}
-
-// Task encapsulates the task data type
-type Task struct {
- ClusterArn string `xml:"clusterArn"`
- ContainerInstanceArn string `xml:"containerInstanceArn"`
- Containers []Container `xml:"containers>member"`
- DesiredStatus string `xml:"desiredStatus"`
- LastStatus string `xml:"lastStatus"`
- Overrides TaskOverride `xml:"overrides"`
- TaskArn string `xml:"taskArn"`
- TaskDefinitionArn string `xml:"taskDefinitionArn"`
-}
-
-// DescribeTasksReq encapsulates DescribeTasks req params
-type DescribeTasksReq struct {
- Cluster string
- Tasks []string
-}
-
-// DescribeTasksResp encapsuates the DescribeTasks response
-type DescribeTasksResp struct {
- Tasks []Task `xml:"DescribeTasksResult>tasks>member"`
- Failures []Failure `xml:"DescribeTasksResult>failures>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeTasks describes a task definition
-func (e *ECS) DescribeTasks(req *DescribeTasksReq) (*DescribeTasksResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("DescribeTasks")
- if len(req.Tasks) > 0 {
- addParamsList(params, "tasks.member", req.Tasks)
- }
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
-
- resp := new(DescribeTasksResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DiscoverPollEndpointReq encapsulates DiscoverPollEndpoint req params
-type DiscoverPollEndpointReq struct {
- ContainerInstance string
-}
-
-// DiscoverPollEndpointResp encapsuates the DiscoverPollEndpoint response
-type DiscoverPollEndpointResp struct {
- Endpoint string `xml:"DiscoverPollEndpointResult>endpoint"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DiscoverPollEndpoint returns an endpoint for the Amazon EC2 Container Service agent
-// to poll for updates
-func (e *ECS) DiscoverPollEndpoint(req *DiscoverPollEndpointReq) (
- *DiscoverPollEndpointResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("DiscoverPollEndpoint")
- if req.ContainerInstance != "" {
- params["containerInstance"] = req.ContainerInstance
- }
-
- resp := new(DiscoverPollEndpointResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ListClustersReq encapsulates ListClusters req params
-type ListClustersReq struct {
- MaxResults int32
- NextToken string
-}
-
-// ListClustersResp encapsuates the ListClusters response
-type ListClustersResp struct {
- ClusterArns []string `xml:"ListClustersResult>clusterArns>member"`
- NextToken string `xml:"ListClustersResult>nextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ListClusters returns a list of existing clusters
-func (e *ECS) ListClusters(req *ListClustersReq) (
- *ListClustersResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("ListClusters")
- if req.MaxResults > 0 {
- params["maxResults"] = strconv.Itoa(int(req.MaxResults))
- }
- if req.NextToken != "" {
- params["nextToken"] = req.NextToken
- }
-
- resp := new(ListClustersResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ListContainerInstancesReq encapsulates ListContainerInstances req params
-type ListContainerInstancesReq struct {
- Cluster string
- MaxResults int32
- NextToken string
-}
-
-// ListContainerInstancesResp encapsuates the ListContainerInstances response
-type ListContainerInstancesResp struct {
- ContainerInstanceArns []string `xml:"ListContainerInstancesResult>containerInstanceArns>member"`
- NextToken string `xml:"ListContainerInstancesResult>nextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ListContainerInstances returns a list of container instances in a specified cluster.
-func (e *ECS) ListContainerInstances(req *ListContainerInstancesReq) (
- *ListContainerInstancesResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("ListContainerInstances")
- if req.MaxResults > 0 {
- params["maxResults"] = strconv.Itoa(int(req.MaxResults))
- }
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- if req.NextToken != "" {
- params["nextToken"] = req.NextToken
- }
-
- resp := new(ListContainerInstancesResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ListTaskDefinitionsReq encapsulates ListTaskDefinitions req params
-type ListTaskDefinitionsReq struct {
- FamilyPrefix string
- MaxResults int32
- NextToken string
-}
-
-// ListTaskDefinitionsResp encapsuates the ListTaskDefinitions response
-type ListTaskDefinitionsResp struct {
- TaskDefinitionArns []string `xml:"ListTaskDefinitionsResult>taskDefinitionArns>member"`
- NextToken string `xml:"ListTaskDefinitionsResult>nextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ListTaskDefinitions Returns a list of task definitions that are registered to your account.
-func (e *ECS) ListTaskDefinitions(req *ListTaskDefinitionsReq) (
- *ListTaskDefinitionsResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("ListTaskDefinitions")
- if req.MaxResults > 0 {
- params["maxResults"] = strconv.Itoa(int(req.MaxResults))
- }
- if req.FamilyPrefix != "" {
- params["familyPrefix"] = req.FamilyPrefix
- }
- if req.NextToken != "" {
- params["nextToken"] = req.NextToken
- }
-
- resp := new(ListTaskDefinitionsResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ListTasksReq encapsulates ListTasks req params
-type ListTasksReq struct {
- Cluster string
- ContainerInstance string
- Family string
- MaxResults int32
- NextToken string
-}
-
-// ListTasksResp encapsuates the ListTasks response
-type ListTasksResp struct {
- TaskArns []string `xml:"ListTasksResult>taskArns>member"`
- NextToken string `xml:"ListTasksResult>nextToken"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ListTasks Returns a list of tasks for a specified cluster.
-// You can filter the results by family name or by a particular container instance
-// with the family and containerInstance parameters.
-func (e *ECS) ListTasks(req *ListTasksReq) (
- *ListTasksResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("ListTasks")
- if req.MaxResults > 0 {
- params["maxResults"] = strconv.Itoa(int(req.MaxResults))
- }
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- if req.ContainerInstance != "" {
- params["containerInstance"] = req.ContainerInstance
- }
- if req.Family != "" {
- params["family"] = req.Family
- }
- if req.NextToken != "" {
- params["nextToken"] = req.NextToken
- }
-
- resp := new(ListTasksResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// RegisterContainerInstanceReq encapsulates RegisterContainerInstance req params
-type RegisterContainerInstanceReq struct {
- Cluster string
- InstanceIdentityDocument string
- InstanceIdentityDocumentSignature string
- TotalResources []Resource
-}
-
-// DeregisterContainerInstanceResp encapsulates RegisterContainerInstance response
-type RegisterContainerInstanceResp struct {
- ContainerInstance ContainerInstance `xml:"RegisterContainerInstanceResult>containerInstance"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// RegisterContainerInstance registers an Amazon EC2 instance into the specified cluster.
-// This instance will become available to place containers on.
-func (e *ECS) RegisterContainerInstance(req *RegisterContainerInstanceReq) (
- resp *RegisterContainerInstanceResp, err error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("RegisterContainerInstance")
- if req.InstanceIdentityDocument != "" {
- params["instanceIdentityDocument"] = req.InstanceIdentityDocument
- }
- if req.InstanceIdentityDocumentSignature != "" {
- params["instanceIdentityDocumentSignature"] = req.InstanceIdentityDocumentSignature
- }
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- // Marshal Resources
- for i, r := range req.TotalResources {
- key := fmt.Sprintf("totalResources.member.%d", i+1)
- params[fmt.Sprintf("%s.doubleValue", key)] = strconv.FormatFloat(r.DoubleValue, 'f', 1, 64)
- params[fmt.Sprintf("%s.integerValue", key)] = strconv.Itoa(int(r.IntegerValue))
- params[fmt.Sprintf("%s.longValue", key)] = strconv.Itoa(int(r.LongValue))
- params[fmt.Sprintf("%s.name", key)] = r.Name
- params[fmt.Sprintf("%s.type", key)] = r.Type
- for k, sv := range r.StringSetValue {
- params[fmt.Sprintf("%s.stringSetValue.member.%d", key, k+1)] = sv
- }
- }
-
- resp = new(RegisterContainerInstanceResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// RegisterTaskDefinitionReq encapsulates RegisterTaskDefinition req params
-type RegisterTaskDefinitionReq struct {
- Family string
- ContainerDefinitions []ContainerDefinition
- Volumes []Volume
-}
-
-// RegisterTaskDefinitionResp encapsulates RegisterTaskDefinition response
-type RegisterTaskDefinitionResp struct {
- TaskDefinition TaskDefinition `xml:"RegisterTaskDefinitionResult>taskDefinition"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// RegisterTaskDefinition registers a new task definition from the supplied family and containerDefinitions.
-func (e *ECS) RegisterTaskDefinition(req *RegisterTaskDefinitionReq) (
- resp *RegisterTaskDefinitionResp, err error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
- params := makeParams("RegisterTaskDefinition")
- if req.Family != "" {
- params["family"] = req.Family
- }
-
- // Marshal Container Definitions
- for i, c := range req.ContainerDefinitions {
- key := fmt.Sprintf("containerDefinitions.member.%d", i+1)
- params[fmt.Sprintf("%s.cpu", key)] = strconv.Itoa(int(c.Cpu))
- params[fmt.Sprintf("%s.essential", key)] = strconv.FormatBool(c.Essential)
- params[fmt.Sprintf("%s.image", key)] = c.Image
- params[fmt.Sprintf("%s.memory", key)] = strconv.Itoa(int(c.Memory))
- params[fmt.Sprintf("%s.name", key)] = c.Name
-
- for k, cmd := range c.Command {
- params[fmt.Sprintf("%s.command.member.%d", key, k+1)] = cmd
- }
- for k, ep := range c.EntryPoint {
- params[fmt.Sprintf("%s.entryPoint.member.%d", key, k+1)] = ep
- }
- for k, env := range c.Environment {
- params[fmt.Sprintf("%s.environment.member.%d.name", key, k+1)] = env.Name
- params[fmt.Sprintf("%s.environment.member.%d.value", key, k+1)] = env.Value
- }
- for k, l := range c.Links {
- params[fmt.Sprintf("%s.links.member.%d", key, k+1)] = l
- }
- for k, p := range c.PortMappings {
- params[fmt.Sprintf("%s.portMappings.member.%d.containerPort", key, k+1)] = strconv.Itoa(int(p.ContainerPort))
- params[fmt.Sprintf("%s.portMappings.member.%d.hostPort", key, k+1)] = strconv.Itoa(int(p.HostPort))
- }
- for k, m := range c.MountPoints {
- params[fmt.Sprintf("%s.mountPoints.member.%d.containerPath", key, k+1)] = m.ContainerPath
- params[fmt.Sprintf("%s.mountPoints.member.%d.readOnly", key, k+1)] = strconv.FormatBool(m.ReadOnly)
- params[fmt.Sprintf("%s.mountPoints.member.%d.sourceVolume", key, k+1)] = m.SourceVolume
- }
- for k, v := range c.VolumesFrom {
- params[fmt.Sprintf("%s.volumesFrom.member.%d.readOnly", key, k+1)] = strconv.FormatBool(v.ReadOnly)
- params[fmt.Sprintf("%s.volumesFrom.member.%d.sourceContainer", key, k+1)] = v.SourceContainer
- }
- }
-
- for k, v := range req.Volumes {
- params[fmt.Sprintf("volumes.member.%d.name", k+1)] = v.Name
- params[fmt.Sprintf("volumes.member.%d.host.sourcePath", k+1)] = v.Host.SourcePath
- }
-
- resp = new(RegisterTaskDefinitionResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// RunTaskReq encapsulates RunTask req params
-type RunTaskReq struct {
- Cluster string
- Count int32
- Overrides TaskOverride
- TaskDefinition string
-}
-
-// RunTaskResp encapsuates the RunTask response
-type RunTaskResp struct {
- Tasks []Task `xml:"RunTaskResult>tasks>member"`
- Failures []Failure `xml:"RunTaskResult>failures>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// RunTask Start a task using random placement and the default Amazon ECS scheduler.
-// If you want to use your own scheduler or place a task on a specific container instance,
-// use StartTask instead.
-func (e *ECS) RunTask(req *RunTaskReq) (*RunTaskResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("RunTask")
- if req.Count > 0 {
- params["count"] = strconv.Itoa(int(req.Count))
- }
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- if req.TaskDefinition != "" {
- params["taskDefinition"] = req.TaskDefinition
- }
-
- for i, co := range req.Overrides.ContainerOverrides {
- key := fmt.Sprintf("overrides.containerOverrides.member.%d", i+1)
- params[fmt.Sprintf("%s.name", key)] = co.Name
- for k, cmd := range co.Command {
- params[fmt.Sprintf("%s.command.member.%d", key, k+1)] = cmd
- }
- for k, env := range co.Environment {
- params[fmt.Sprintf("%s.environment.member.%d.name", key, k+1)] = env.Name
- params[fmt.Sprintf("%s.environment.member.%d.value", key, k+1)] = env.Value
- }
- }
-
- resp := new(RunTaskResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StartTaskReq encapsulates StartTask req params
-type StartTaskReq struct {
- Cluster string
- ContainerInstances []string
- Overrides TaskOverride
- TaskDefinition string
-}
-
-// StartTaskResp encapsuates the StartTask response
-type StartTaskResp struct {
- Tasks []Task `xml:"StartTaskResult>tasks>member"`
- Failures []Failure `xml:"StartTaskResult>failures>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// StartTask Starts a new task from the specified task definition on the specified
-// container instance or instances. If you want to use the default Amazon ECS scheduler
-// to place your task, use RunTask instead.
-func (e *ECS) StartTask(req *StartTaskReq) (*StartTaskResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("StartTask")
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- if req.TaskDefinition != "" {
- params["taskDefinition"] = req.TaskDefinition
- }
- for i, ci := range req.ContainerInstances {
- params[fmt.Sprintf("containerInstances.member.%d", i+1)] = ci
- }
- for i, co := range req.Overrides.ContainerOverrides {
- key := fmt.Sprintf("overrides.containerOverrides.member.%d", i+1)
- params[fmt.Sprintf("%s.name", key)] = co.Name
- for k, cmd := range co.Command {
- params[fmt.Sprintf("%s.command.member.%d", key, k+1)] = cmd
- }
- }
-
- resp := new(StartTaskResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// StopTaskReq encapsulates StopTask req params
-type StopTaskReq struct {
- Cluster string
- Task string
-}
-
-// StopTaskResp encapsuates the StopTask response
-type StopTaskResp struct {
- Task Task `xml:"StopTaskResult>task"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// StopTask stops a running task
-func (e *ECS) StopTask(req *StopTaskReq) (*StopTaskResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("StopTask")
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- if req.Task != "" {
- params["task"] = req.Task
- }
-
- resp := new(StopTaskResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// SubmitContainerStateChangeReq encapsulates SubmitContainerStateChange req params
-type SubmitContainerStateChangeReq struct {
- Cluster string
- ContainerName string
- ExitCode int32
- NetworkBindings []NetworkBinding
- Reason string
- Status string
- Task string
-}
-
-// SubmitContainerStateChangeResp encapsuates the SubmitContainerStateChange response
-type SubmitContainerStateChangeResp struct {
- Acknowledgment string `xml:"SubmitContainerStateChangeResult>acknowledgment"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// SubmitContainerStateChange is used to acknowledge that a container changed states.
-// Note: This action is only used by the Amazon EC2 Container Service agent,
-// and it is not intended for use outside of the agent.
-func (e *ECS) SubmitContainerStateChange(req *SubmitContainerStateChangeReq) (
- *SubmitContainerStateChangeResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("SubmitContainerStateChange")
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
- if req.ContainerName != "" {
- params["containerName"] = req.ContainerName
- }
- if req.Reason != "" {
- params["reason"] = req.Reason
- }
- if req.Status != "" {
- params["status"] = req.Status
- }
- if req.Task != "" {
- params["task"] = req.Task
- }
- for i, nb := range req.NetworkBindings {
- key := fmt.Sprintf("networkBindings.member.%d", i+1)
- params[fmt.Sprintf("%s.bindIp", key)] = nb.BindIp
- params[fmt.Sprintf("%s.containerPort", key)] = strconv.Itoa(int(nb.ContainerPort))
- params[fmt.Sprintf("%s.hostPort", key)] = strconv.Itoa(int(nb.HostPort))
- }
- params["exitCode"] = strconv.Itoa(int(req.ExitCode))
-
- resp := new(SubmitContainerStateChangeResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// SubmitTaskStateChangeReq encapsulates SubmitTaskStateChange req params
-type SubmitTaskStateChangeReq struct {
- Cluster string
- Reason string
- Status string
- Task string
-}
-
-// SubmitTaskStateChangeResp encapsuates the SubmitTaskStateChange response
-type SubmitTaskStateChangeResp struct {
- Acknowledgment string `xml:"SubmitTaskStateChangeResult>acknowledgment"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// SubmitTaskStateChange is used to acknowledge that a task changed states.
-// Note: This action is only used by the Amazon EC2 Container Service agent,
-// and it is not intended for use outside of the agent.
-func (e *ECS) SubmitTaskStateChange(req *SubmitTaskStateChangeReq) (
- *SubmitTaskStateChangeResp, error) {
- if req == nil {
- return nil, fmt.Errorf("The req params cannot be nil")
- }
-
- params := makeParams("SubmitTaskStateChange")
- if req.Cluster != "" {
- params["cluster"] = req.Cluster
- }
-
- if req.Reason != "" {
- params["reason"] = req.Reason
- }
- if req.Status != "" {
- params["status"] = req.Status
- }
- if req.Task != "" {
- params["task"] = req.Task
- }
-
- resp := new(SubmitTaskStateChangeResp)
- if err := e.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
diff --git a/vendor/github.com/goamz/goamz/ecs/ecs_test.go b/vendor/github.com/goamz/goamz/ecs/ecs_test.go
deleted file mode 100644
index 7fe4a74ae..000000000
--- a/vendor/github.com/goamz/goamz/ecs/ecs_test.go
+++ /dev/null
@@ -1,806 +0,0 @@
-package ecs
-
-import (
- "testing"
-
- . "gopkg.in/check.v1"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/testutil"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- ecs *ECS
-}
-
-var testServer = testutil.NewHTTPServer()
-
-var mockTest bool
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.ecs = New(auth, aws.Region{ECSEndpoint: testServer.URL})
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-// --------------------------------------------------------------------------
-// Detailed Unit Tests
-
-func (s *S) TestCreateCluster(c *C) {
- testServer.Response(200, nil, CreateClusterResponse)
- req := &CreateClusterReq{
- ClusterName: "default",
- }
- resp, err := s.ecs.CreateCluster(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "CreateCluster")
- c.Assert(values.Get("clusterName"), Equals, "default")
-
- c.Assert(resp.Cluster.ClusterArn, Equals, "arn:aws:ecs:region:aws_account_id:cluster/default")
- c.Assert(resp.Cluster.ClusterName, Equals, "default")
- c.Assert(resp.Cluster.Status, Equals, "ACTIVE")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestDeregisterContainerInstance(c *C) {
- testServer.Response(200, nil, DeregisterContainerInstanceResponse)
- req := &DeregisterContainerInstanceReq{
- Cluster: "default",
- ContainerInstance: "uuid",
- Force: true,
- }
- resp, err := s.ecs.DeregisterContainerInstance(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "DeregisterContainerInstance")
- c.Assert(values.Get("cluster"), Equals, "default")
- c.Assert(values.Get("containerInstance"), Equals, "uuid")
- c.Assert(values.Get("force"), Equals, "true")
-
- expectedResource := []Resource{
- {
- DoubleValue: 0.0,
- IntegerValue: 2048,
- LongValue: 0,
- Name: "CPU",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 3955,
- LongValue: 0,
- Name: "MEMORY",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 0,
- LongValue: 0,
- Name: "PORTS",
- StringSetValue: []string{"2376", "22", "51678", "2375"},
- Type: "STRINGSET",
- },
- }
-
- c.Assert(resp.ContainerInstance.AgentConnected, Equals, false)
- c.Assert(resp.ContainerInstance.ContainerInstanceArn, Equals, "arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID")
- c.Assert(resp.ContainerInstance.Status, Equals, "INACTIVE")
- c.Assert(resp.ContainerInstance.Ec2InstanceId, Equals, "instance_id")
- c.Assert(resp.ContainerInstance.RegisteredResources, DeepEquals, expectedResource)
- c.Assert(resp.ContainerInstance.RemainingResources, DeepEquals, expectedResource)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestDeregisterTaskDefinition(c *C) {
- testServer.Response(200, nil, DeregisterTaskDefinitionResponse)
- req := &DeregisterTaskDefinitionReq{
- TaskDefinition: "sleep360:2",
- }
- resp, err := s.ecs.DeregisterTaskDefinition(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "DeregisterTaskDefinition")
- c.Assert(values.Get("taskDefinition"), Equals, "sleep360:2")
-
- expected := TaskDefinition{
- Family: "sleep360",
- Revision: 2,
- TaskDefinitionArn: "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2",
- ContainerDefinitions: []ContainerDefinition{
- {
- Command: []string{"sleep", "360"},
- Cpu: 10,
- EntryPoint: []string{"/bin/sh"},
- Environment: []KeyValuePair{
- {
- Name: "envVar",
- Value: "foo",
- },
- },
- Essential: true,
- Image: "busybox",
- Memory: 10,
- Name: "sleep",
- },
- },
- }
-
- c.Assert(resp.TaskDefinition, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestDescribeClusters(c *C) {
- testServer.Response(200, nil, DescribeClustersResponse)
- req := &DescribeClustersReq{
- Clusters: []string{"test", "default"},
- }
- resp, err := s.ecs.DescribeClusters(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "DescribeClusters")
- c.Assert(values.Get("clusters.member.1"), Equals, "test")
- c.Assert(values.Get("clusters.member.2"), Equals, "default")
-
- expected := []Cluster{
- {
- ClusterName: "test",
- ClusterArn: "arn:aws:ecs:us-east-1:aws_account_id:cluster/test",
- Status: "ACTIVE",
- },
- {
- ClusterName: "default",
- ClusterArn: "arn:aws:ecs:us-east-1:aws_account_id:cluster/default",
- Status: "ACTIVE",
- },
- }
-
- c.Assert(resp.Clusters, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestDescribeContainerInstances(c *C) {
- testServer.Response(200, nil, DescribeContainerInstancesResponse)
- req := &DescribeContainerInstancesReq{
- Cluster: "test",
- ContainerInstances: []string{"arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID"},
- }
- resp, err := s.ecs.DescribeContainerInstances(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "DescribeContainerInstances")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("containerInstances.member.1"),
- Equals, "arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID")
-
- expected := []ContainerInstance{
- ContainerInstance{
- AgentConnected: true,
- ContainerInstanceArn: "arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID",
- Status: "ACTIVE",
- Ec2InstanceId: "instance_id",
- RegisteredResources: []Resource{
- {
- DoubleValue: 0.0,
- IntegerValue: 2048,
- LongValue: 0,
- Name: "CPU",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 3955,
- LongValue: 0,
- Name: "MEMORY",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 0,
- LongValue: 0,
- Name: "PORTS",
- StringSetValue: []string{"2376", "22", "51678", "2375"},
- Type: "STRINGSET",
- },
- },
- RemainingResources: []Resource{
- {
- DoubleValue: 0.0,
- IntegerValue: 2048,
- LongValue: 0,
- Name: "CPU",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 3955,
- LongValue: 0,
- Name: "MEMORY",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 0,
- LongValue: 0,
- Name: "PORTS",
- StringSetValue: []string{"2376", "22", "51678", "2375"},
- Type: "STRINGSET",
- },
- },
- },
- }
-
- c.Assert(resp.ContainerInstances, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestDescribeTaskDefinition(c *C) {
- testServer.Response(200, nil, DescribeTaskDefinitionResponse)
- req := &DescribeTaskDefinitionReq{
- TaskDefinition: "sleep360:2",
- }
- resp, err := s.ecs.DescribeTaskDefinition(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "DescribeTaskDefinition")
- c.Assert(values.Get("taskDefinition"), Equals, "sleep360:2")
-
- expected := TaskDefinition{
- Family: "sleep360",
- Revision: 2,
- TaskDefinitionArn: "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2",
- ContainerDefinitions: []ContainerDefinition{
- {
- Command: []string{"sleep", "360"},
- Cpu: 10,
- EntryPoint: []string{"/bin/sh"},
- Environment: []KeyValuePair{
- {
- Name: "envVar",
- Value: "foo",
- },
- },
- Essential: true,
- Image: "busybox",
- Memory: 10,
- Name: "sleep",
- },
- },
- }
-
- c.Assert(resp.TaskDefinition, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestDescribeTasks(c *C) {
- testServer.Response(200, nil, DescribeTasksResponse)
- req := &DescribeTasksReq{
- Cluster: "test",
- Tasks: []string{"arn:aws:ecs:us-east-1:aws_account_id:task/UUID"},
- }
- resp, err := s.ecs.DescribeTasks(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "DescribeTasks")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("tasks.member.1"),
- Equals, "arn:aws:ecs:us-east-1:aws_account_id:task/UUID")
-
- expected := []Task{
- Task{
- Containers: []Container{
- {
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- Name: "sleep",
- ContainerArn: "arn:aws:ecs:us-east-1:aws_account_id:container/UUID",
- LastStatus: "RUNNING",
- },
- },
- Overrides: TaskOverride{
- ContainerOverrides: []ContainerOverride{
- {
- Name: "sleep",
- },
- },
- },
- DesiredStatus: "RUNNING",
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- ContainerInstanceArn: "arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID",
- LastStatus: "RUNNING",
- TaskDefinitionArn: "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2",
- },
- }
-
- c.Assert(resp.Tasks, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestDiscoverPollEndpoint(c *C) {
- testServer.Response(200, nil, DiscoverPollEndpointResponse)
- req := &DiscoverPollEndpointReq{
- ContainerInstance: "arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID",
- }
- resp, err := s.ecs.DiscoverPollEndpoint(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "DiscoverPollEndpoint")
- c.Assert(values.Get("containerInstance"),
- Equals, "arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID")
-
- c.Assert(resp.Endpoint, Equals, "https://ecs-x-1.us-east-1.amazonaws.com/")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestListClusters(c *C) {
- testServer.Response(200, nil, ListClustersResponse)
- req := &ListClustersReq{
- MaxResults: 2,
- NextToken: "Token_UUID",
- }
- resp, err := s.ecs.ListClusters(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "ListClusters")
- c.Assert(values.Get("maxResults"), Equals, "2")
- c.Assert(values.Get("nextToken"), Equals, "Token_UUID")
-
- c.Assert(resp.ClusterArns, DeepEquals, []string{"arn:aws:ecs:us-east-1:aws_account_id:cluster/default",
- "arn:aws:ecs:us-east-1:aws_account_id:cluster/test"})
- c.Assert(resp.NextToken, Equals, "token_UUID")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestListContainerInstances(c *C) {
- testServer.Response(200, nil, ListContainerInstancesResponse)
- req := &ListContainerInstancesReq{
- MaxResults: 2,
- NextToken: "Token_UUID",
- Cluster: "test",
- }
- resp, err := s.ecs.ListContainerInstances(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "ListContainerInstances")
- c.Assert(values.Get("maxResults"), Equals, "2")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("nextToken"), Equals, "Token_UUID")
-
- c.Assert(resp.ContainerInstanceArns, DeepEquals, []string{
- "arn:aws:ecs:us-east-1:aws_account_id:container-instance/uuid-1",
- "arn:aws:ecs:us-east-1:aws_account_id:container-instance/uuid-2"})
- c.Assert(resp.NextToken, Equals, "token_UUID")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestListTaskDefinitions(c *C) {
- testServer.Response(200, nil, ListTaskDefinitionsResponse)
- req := &ListTaskDefinitionsReq{
- MaxResults: 2,
- NextToken: "Token_UUID",
- FamilyPrefix: "sleep360",
- }
- resp, err := s.ecs.ListTaskDefinitions(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "ListTaskDefinitions")
- c.Assert(values.Get("maxResults"), Equals, "2")
- c.Assert(values.Get("familyPrefix"), Equals, "sleep360")
- c.Assert(values.Get("nextToken"), Equals, "Token_UUID")
-
- c.Assert(resp.TaskDefinitionArns, DeepEquals, []string{
- "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:1",
- "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2"})
- c.Assert(resp.NextToken, Equals, "token_UUID")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestListTasks(c *C) {
- testServer.Response(200, nil, ListTasksResponse)
- req := &ListTasksReq{
- MaxResults: 2,
- NextToken: "Token_UUID",
- Family: "sleep360",
- Cluster: "test",
- ContainerInstance: "container_uuid",
- }
- resp, err := s.ecs.ListTasks(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "ListTasks")
- c.Assert(values.Get("maxResults"), Equals, "2")
- c.Assert(values.Get("family"), Equals, "sleep360")
- c.Assert(values.Get("containerInstance"), Equals, "container_uuid")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("nextToken"), Equals, "Token_UUID")
-
- c.Assert(resp.TaskArns, DeepEquals, []string{
- "arn:aws:ecs:us-east-1:aws_account_id:task/uuid_1",
- "arn:aws:ecs:us-east-1:aws_account_id:task/uuid_2"})
- c.Assert(resp.NextToken, Equals, "token_UUID")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestRegisterContainerInstance(c *C) {
- testServer.Response(200, nil, RegisterContainerInstanceResponse)
-
- resources := []Resource{
- {
- DoubleValue: 0.0,
- IntegerValue: 2048,
- LongValue: 0,
- Name: "CPU",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 3955,
- LongValue: 0,
- Name: "MEMORY",
- Type: "INTEGER",
- },
- {
- DoubleValue: 0.0,
- IntegerValue: 0,
- LongValue: 0,
- Name: "PORTS",
- StringSetValue: []string{"2376", "22", "51678", "2375"},
- Type: "STRINGSET",
- },
- }
-
- req := &RegisterContainerInstanceReq{
- Cluster: "default",
- InstanceIdentityDocument: "foo",
- InstanceIdentityDocumentSignature: "baz",
- TotalResources: resources,
- }
-
- resp, err := s.ecs.RegisterContainerInstance(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "RegisterContainerInstance")
- c.Assert(values.Get("cluster"), Equals, "default")
- c.Assert(values.Get("instanceIdentityDocument"), Equals, "foo")
- c.Assert(values.Get("instanceIdentityDocumentSignature"), Equals, "baz")
- c.Assert(values.Get("totalResources.member.1.doubleValue"), Equals, "0.0")
- c.Assert(values.Get("totalResources.member.1.integerValue"), Equals, "2048")
- c.Assert(values.Get("totalResources.member.1.longValue"), Equals, "0")
- c.Assert(values.Get("totalResources.member.1.name"), Equals, "CPU")
- c.Assert(values.Get("totalResources.member.1.type"), Equals, "INTEGER")
- c.Assert(values.Get("totalResources.member.2.doubleValue"), Equals, "0.0")
- c.Assert(values.Get("totalResources.member.2.integerValue"), Equals, "3955")
- c.Assert(values.Get("totalResources.member.2.longValue"), Equals, "0")
- c.Assert(values.Get("totalResources.member.2.name"), Equals, "MEMORY")
- c.Assert(values.Get("totalResources.member.2.type"), Equals, "INTEGER")
- c.Assert(values.Get("totalResources.member.3.doubleValue"), Equals, "0.0")
- c.Assert(values.Get("totalResources.member.3.integerValue"), Equals, "0")
- c.Assert(values.Get("totalResources.member.3.longValue"), Equals, "0")
- c.Assert(values.Get("totalResources.member.3.name"), Equals, "PORTS")
- c.Assert(values.Get("totalResources.member.3.stringSetValue.member.1"), Equals, "2376")
- c.Assert(values.Get("totalResources.member.3.stringSetValue.member.2"), Equals, "22")
- c.Assert(values.Get("totalResources.member.3.stringSetValue.member.3"), Equals, "51678")
- c.Assert(values.Get("totalResources.member.3.stringSetValue.member.4"), Equals, "2375")
- c.Assert(values.Get("totalResources.member.3.type"), Equals, "STRINGSET")
-
- c.Assert(resp.ContainerInstance.AgentConnected, Equals, true)
- c.Assert(resp.ContainerInstance.ContainerInstanceArn, Equals, "arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID")
- c.Assert(resp.ContainerInstance.Status, Equals, "ACTIVE")
- c.Assert(resp.ContainerInstance.Ec2InstanceId, Equals, "instance_id")
- c.Assert(resp.ContainerInstance.RegisteredResources, DeepEquals, resources)
- c.Assert(resp.ContainerInstance.RemainingResources, DeepEquals, resources)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestRegisterTaskDefinition(c *C) {
- testServer.Response(200, nil, RegisterTaskDefinitionResponse)
-
- CDefinitions := []ContainerDefinition{
- {
- Command: []string{"sleep", "360"},
- Cpu: 10,
- EntryPoint: []string{"/bin/sh"},
- Environment: []KeyValuePair{
- {
- Name: "envVar",
- Value: "foo",
- },
- },
- Essential: true,
- Image: "busybox",
- Memory: 10,
- Name: "sleep",
- MountPoints: []MountPoint{
- {
- ContainerPath: "/tmp/myfile",
- ReadOnly: false,
- SourceVolume: "/srv/myfile",
- },
- {
- ContainerPath: "/tmp/myfile2",
- ReadOnly: true,
- SourceVolume: "/srv/myfile2",
- },
- },
- VolumesFrom: []VolumeFrom{
- {
- ReadOnly: true,
- SourceContainer: "foo",
- },
- },
- },
- }
-
- req := &RegisterTaskDefinitionReq{
- Family: "sleep360",
- ContainerDefinitions: CDefinitions,
- Volumes: []Volume{
- {
- Name: "/srv/myfile",
- Host: HostVolumeProperties{
- SourcePath: "/srv/myfile",
- },
- },
- },
- }
- resp, err := s.ecs.RegisterTaskDefinition(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "RegisterTaskDefinition")
- c.Assert(values.Get("containerDefinitions.member.1.command.member.1"), Equals, "sleep")
- c.Assert(values.Get("containerDefinitions.member.1.command.member.2"), Equals, "360")
- c.Assert(values.Get("containerDefinitions.member.1.cpu"), Equals, "10")
- c.Assert(values.Get("containerDefinitions.member.1.memory"), Equals, "10")
- c.Assert(values.Get("containerDefinitions.member.1.entryPoint.member.1"), Equals, "/bin/sh")
- c.Assert(values.Get("containerDefinitions.member.1.environment.member.1.name"), Equals, "envVar")
- c.Assert(values.Get("containerDefinitions.member.1.environment.member.1.value"), Equals, "foo")
- c.Assert(values.Get("containerDefinitions.member.1.essential"), Equals, "true")
- c.Assert(values.Get("containerDefinitions.member.1.image"), Equals, "busybox")
- c.Assert(values.Get("containerDefinitions.member.1.memory"), Equals, "10")
- c.Assert(values.Get("containerDefinitions.member.1.name"), Equals, "sleep")
- c.Assert(values.Get("containerDefinitions.member.1.mountPoints.member.1.containerPath"), Equals, "/tmp/myfile")
- c.Assert(values.Get("containerDefinitions.member.1.mountPoints.member.1.readOnly"), Equals, "false")
- c.Assert(values.Get("containerDefinitions.member.1.mountPoints.member.1.sourceVolume"), Equals, "/srv/myfile")
- c.Assert(values.Get("containerDefinitions.member.1.mountPoints.member.2.containerPath"), Equals, "/tmp/myfile2")
- c.Assert(values.Get("containerDefinitions.member.1.mountPoints.member.2.readOnly"), Equals, "true")
- c.Assert(values.Get("containerDefinitions.member.1.mountPoints.member.2.sourceVolume"), Equals, "/srv/myfile2")
- c.Assert(values.Get("containerDefinitions.member.1.volumesFrom.member.1.readOnly"), Equals, "true")
- c.Assert(values.Get("containerDefinitions.member.1.volumesFrom.member.1.sourceContainer"), Equals, "foo")
-
- c.Assert(values.Get("family"), Equals, "sleep360")
- c.Assert(values.Get("volumes.member.1.name"), Equals, "/srv/myfile")
- c.Assert(values.Get("volumes.member.1.host.sourcePath"), Equals, "/srv/myfile")
-
- expected := TaskDefinition{
- Family: "sleep360",
- Revision: 2,
- TaskDefinitionArn: "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2",
- ContainerDefinitions: CDefinitions,
- Volumes: []Volume{
- {
- Name: "/srv/myfile",
- Host: HostVolumeProperties{
- SourcePath: "/srv/myfile",
- },
- },
- },
- }
-
- c.Assert(resp.TaskDefinition, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestRunTask(c *C) {
- testServer.Response(200, nil, RunTaskResponse)
- req := &RunTaskReq{
- Cluster: "test",
- Count: 1,
- TaskDefinition: "sleep360:2",
- }
- resp, err := s.ecs.RunTask(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "RunTask")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("count"), Equals, "1")
- c.Assert(values.Get("taskDefinition"), Equals, "sleep360:2")
-
- expected := []Task{
- Task{
- Containers: []Container{
- {
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- Name: "sleep",
- ContainerArn: "arn:aws:ecs:us-east-1:aws_account_id:container/UUID",
- LastStatus: "RUNNING",
- },
- },
- Overrides: TaskOverride{
- ContainerOverrides: []ContainerOverride{
- {
- Name: "sleep",
- },
- },
- },
- DesiredStatus: "RUNNING",
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- ContainerInstanceArn: "arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID",
- LastStatus: "PENDING",
- TaskDefinitionArn: "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2",
- },
- }
-
- c.Assert(resp.Tasks, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestStartTask(c *C) {
- testServer.Response(200, nil, StartTaskResponse)
- req := &StartTaskReq{
- Cluster: "test",
- ContainerInstances: []string{"containerUUID"},
- TaskDefinition: "sleep360:2",
- }
- resp, err := s.ecs.StartTask(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "StartTask")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("taskDefinition"), Equals, "sleep360:2")
- c.Assert(values.Get("containerInstances.member.1"), Equals, "containerUUID")
-
- expected := []Task{
- Task{
- Containers: []Container{
- {
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- Name: "sleep",
- ContainerArn: "arn:aws:ecs:us-east-1:aws_account_id:container/UUID",
- LastStatus: "RUNNING",
- },
- },
- Overrides: TaskOverride{
- ContainerOverrides: []ContainerOverride{
- {
- Name: "sleep",
- },
- },
- },
- DesiredStatus: "RUNNING",
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- ContainerInstanceArn: "arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID",
- LastStatus: "PENDING",
- TaskDefinitionArn: "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2",
- },
- }
-
- c.Assert(resp.Tasks, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestStopTask(c *C) {
- testServer.Response(200, nil, StopTaskResponse)
- req := &StopTaskReq{
- Cluster: "test",
- Task: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- }
- resp, err := s.ecs.StopTask(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "StopTask")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("task"), Equals, "arn:aws:ecs:us-east-1:aws_account_id:task/UUID")
-
- expected := Task{
- Containers: []Container{
- {
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- Name: "sleep",
- ContainerArn: "arn:aws:ecs:us-east-1:aws_account_id:container/UUID",
- LastStatus: "RUNNING",
- },
- },
- Overrides: TaskOverride{
- ContainerOverrides: []ContainerOverride{
- {
- Name: "sleep",
- },
- },
- },
- DesiredStatus: "STOPPED",
- TaskArn: "arn:aws:ecs:us-east-1:aws_account_id:task/UUID",
- ContainerInstanceArn: "arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID",
- LastStatus: "RUNNING",
- TaskDefinitionArn: "arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2",
- }
-
- c.Assert(resp.Task, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestSubmitContainerStateChange(c *C) {
- testServer.Response(200, nil, SubmitContainerStateChangeResponse)
- networkBindings := []NetworkBinding{
- {
- BindIp: "127.0.0.1",
- ContainerPort: 80,
- HostPort: 80,
- },
- }
- req := &SubmitContainerStateChangeReq{
- Cluster: "test",
- ContainerName: "container",
- ExitCode: 0,
- Reason: "reason",
- Status: "status",
- Task: "taskUUID",
- NetworkBindings: networkBindings,
- }
-
- resp, err := s.ecs.SubmitContainerStateChange(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "SubmitContainerStateChange")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("containerName"), Equals, "container")
- c.Assert(values.Get("exitCode"), Equals, "0")
- c.Assert(values.Get("reason"), Equals, "reason")
- c.Assert(values.Get("status"), Equals, "status")
- c.Assert(values.Get("task"), Equals, "taskUUID")
- c.Assert(values.Get("networkBindings.member.1.bindIp"), Equals, "127.0.0.1")
- c.Assert(values.Get("networkBindings.member.1.containerPort"), Equals, "80")
- c.Assert(values.Get("networkBindings.member.1.hostPort"), Equals, "80")
-
- c.Assert(resp.Acknowledgment, Equals, "ACK")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
-
-func (s *S) TestSubmitTaskStateChange(c *C) {
- testServer.Response(200, nil, SubmitTaskStateChangeResponse)
- req := &SubmitTaskStateChangeReq{
- Cluster: "test",
- Reason: "reason",
- Status: "status",
- Task: "taskUUID",
- }
-
- resp, err := s.ecs.SubmitTaskStateChange(req)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- c.Assert(values.Get("Version"), Equals, "2014-11-13")
- c.Assert(values.Get("Action"), Equals, "SubmitTaskStateChange")
- c.Assert(values.Get("cluster"), Equals, "test")
- c.Assert(values.Get("reason"), Equals, "reason")
- c.Assert(values.Get("status"), Equals, "status")
- c.Assert(values.Get("task"), Equals, "taskUUID")
-
- c.Assert(resp.Acknowledgment, Equals, "ACK")
- c.Assert(resp.RequestId, Equals, "8d798a29-f083-11e1-bdfb-cb223EXAMPLE")
-}
diff --git a/vendor/github.com/goamz/goamz/ecs/responses_test.go b/vendor/github.com/goamz/goamz/ecs/responses_test.go
deleted file mode 100644
index 6a4b0ce71..000000000
--- a/vendor/github.com/goamz/goamz/ecs/responses_test.go
+++ /dev/null
@@ -1,637 +0,0 @@
-package ecs
-
-var CreateClusterResponse = `
-<CreateClusterResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
- <CreateClusterResult>
- <cluster>
- <clusterArn>arn:aws:ecs:region:aws_account_id:cluster/default</clusterArn>
- <clusterName>default</clusterName>
- <status>ACTIVE</status>
- </cluster>
- </CreateClusterResult>
-</CreateClusterResponse>
-`
-var DeregisterContainerInstanceResponse = `
-<DeregisterContainerInstanceResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
- <DeregisterContainerInstanceResult>
- <containerInstance>
- <agentConnected>False</agentConnected>
- <containerInstanceArn>arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID</containerInstanceArn>
- <ec2InstanceId>instance_id</ec2InstanceId>
- <status>INACTIVE</status>
- <registeredResources>
- <member>
- <integerValue>2048</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>CPU</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>3955</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>MEMORY</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>0</integerValue>
- <longValue>0</longValue>
- <type>STRINGSET</type>
- <stringSetValue>
- <member>2376</member>
- <member>22</member>
- <member>51678</member>
- <member>2375</member>
- </stringSetValue>
- <name>PORTS</name>
- <doubleValue>0.0</doubleValue>
- </member>
- </registeredResources>
- <remainingResources>
- <member>
- <integerValue>2048</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>CPU</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>3955</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>MEMORY</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>0</integerValue>
- <longValue>0</longValue>
- <type>STRINGSET</type>
- <stringSetValue>
- <member>2376</member>
- <member>22</member>
- <member>51678</member>
- <member>2375</member>
- </stringSetValue>
- <name>PORTS</name>
- <doubleValue>0.0</doubleValue>
- </member>
- </remainingResources>
- </containerInstance>
- </DeregisterContainerInstanceResult>
-</DeregisterContainerInstanceResponse>
-`
-
-var DeregisterTaskDefinitionResponse = `
-<DeregisterTaskDefinitionResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <DeregisterTaskDefinitionResult>
- <taskDefinition>
- <revision>2</revision>
- <family>sleep360</family>
- <containerDefinitions>
- <member>
- <portMappings/>
- <essential>true</essential>
- <environment>
- <member>
- <name>envVar</name>
- <value>foo</value>
- </member>
- </environment>
- <entryPoint>
- <member>/bin/sh</member>
- </entryPoint>
- <name>sleep</name>
- <command>
- <member>sleep</member>
- <member>360</member>
- </command>
- <cpu>10</cpu>
- <image>busybox</image>
- <memory>10</memory>
- </member>
- </containerDefinitions>
- <taskDefinitionArn>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</taskDefinitionArn>
- </taskDefinition>
- </DeregisterTaskDefinitionResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</DeregisterTaskDefinitionResponse>
-`
-
-var DescribeClustersResponse = `
-<DescribeClustersResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <DescribeClustersResult>
- <failures/>
- <clusters>
- <member>
- <clusterName>test</clusterName>
- <clusterArn>arn:aws:ecs:us-east-1:aws_account_id:cluster/test</clusterArn>
- <status>ACTIVE</status>
- </member>
- <member>
- <clusterName>default</clusterName>
- <clusterArn>arn:aws:ecs:us-east-1:aws_account_id:cluster/default</clusterArn>
- <status>ACTIVE</status>
- </member>
- </clusters>
- </DescribeClustersResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeClustersResponse>
-`
-
-var DescribeContainerInstancesResponse = `
-<DescribeContainerInstancesResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
- <DescribeContainerInstancesResult>
- <failures/>
- <containerInstances>
- <member>
- <agentConnected>true</agentConnected>
- <containerInstanceArn>arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID</containerInstanceArn>
- <ec2InstanceId>instance_id</ec2InstanceId>
- <status>ACTIVE</status>
- <registeredResources>
- <member>
- <integerValue>2048</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>CPU</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>3955</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>MEMORY</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>0</integerValue>
- <longValue>0</longValue>
- <type>STRINGSET</type>
- <stringSetValue>
- <member>2376</member>
- <member>22</member>
- <member>51678</member>
- <member>2375</member>
- </stringSetValue>
- <name>PORTS</name>
- <doubleValue>0.0</doubleValue>
- </member>
- </registeredResources>
- <remainingResources>
- <member>
- <integerValue>2048</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>CPU</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>3955</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>MEMORY</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>0</integerValue>
- <longValue>0</longValue>
- <type>STRINGSET</type>
- <stringSetValue>
- <member>2376</member>
- <member>22</member>
- <member>51678</member>
- <member>2375</member>
- </stringSetValue>
- <name>PORTS</name>
- <doubleValue>0.0</doubleValue>
- </member>
- </remainingResources>
- </member>
- </containerInstances>
- </DescribeContainerInstancesResult>
-</DescribeContainerInstancesResponse>
-`
-
-var DescribeTaskDefinitionResponse = `
-<DescribeTaskDefinitionResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <DescribeTaskDefinitionResult>
- <taskDefinition>
- <revision>2</revision>
- <family>sleep360</family>
- <containerDefinitions>
- <member>
- <portMappings/>
- <essential>true</essential>
- <environment>
- <member>
- <name>envVar</name>
- <value>foo</value>
- </member>
- </environment>
- <entryPoint>
- <member>/bin/sh</member>
- </entryPoint>
- <name>sleep</name>
- <command>
- <member>sleep</member>
- <member>360</member>
- </command>
- <cpu>10</cpu>
- <image>busybox</image>
- <memory>10</memory>
- </member>
- </containerDefinitions>
- <taskDefinitionArn>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</taskDefinitionArn>
- </taskDefinition>
- </DescribeTaskDefinitionResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeTaskDefinitionResponse>
-`
-
-var DescribeTasksResponse = `
-<DescribeTasksResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <DescribeTasksResult>
- <failures/>
- <tasks>
- <member>
- <containers>
- <member>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <name>sleep</name>
- <containerArn>arn:aws:ecs:us-east-1:aws_account_id:container/UUID</containerArn>
- <networkBindings/>
- <lastStatus>RUNNING</lastStatus>
- </member>
- </containers>
- <overrides>
- <containerOverrides>
- <member>
- <name>sleep</name>
- </member>
- </containerOverrides>
- </overrides>
- <desiredStatus>RUNNING</desiredStatus>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <containerInstanceArn>arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID</containerInstanceArn>
- <lastStatus>RUNNING</lastStatus>
- <taskDefinitionArn>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</taskDefinitionArn>
- </member>
- </tasks>
- </DescribeTasksResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</DescribeTasksResponse>
-`
-
-var DiscoverPollEndpointResponse = `
-<DiscoverPollEndpointResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <DiscoverPollEndpointResult>
- <endpoint>https://ecs-x-1.us-east-1.amazonaws.com/</endpoint>
- </DiscoverPollEndpointResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</DiscoverPollEndpointResponse>
-`
-
-var ListClustersResponse = `
-<ListClustersResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ListClustersResult>
- <clusterArns>
- <member>arn:aws:ecs:us-east-1:aws_account_id:cluster/default</member>
- <member>arn:aws:ecs:us-east-1:aws_account_id:cluster/test</member>
- </clusterArns>
- <nextToken>token_UUID</nextToken>
- </ListClustersResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</ListClustersResponse>
-`
-
-var ListContainerInstancesResponse = `
-<ListContainerInstancesResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ListContainerInstancesResult>
- <containerInstanceArns>
- <member>arn:aws:ecs:us-east-1:aws_account_id:container-instance/uuid-1</member>
- <member>arn:aws:ecs:us-east-1:aws_account_id:container-instance/uuid-2</member>
- </containerInstanceArns>
- <nextToken>token_UUID</nextToken>
- </ListContainerInstancesResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</ListContainerInstancesResponse>
-`
-
-var ListTaskDefinitionsResponse = `
-<ListTaskDefinitionsResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ListTaskDefinitionsResult>
- <taskDefinitionArns>
- <member>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:1</member>
- <member>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</member>
- </taskDefinitionArns>
- <nextToken>token_UUID</nextToken>
- </ListTaskDefinitionsResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</ListTaskDefinitionsResponse>
-`
-
-var ListTasksResponse = `
-<ListTasksResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ListTasksResult>
- <taskArns>
- <member>arn:aws:ecs:us-east-1:aws_account_id:task/uuid_1</member>
- <member>arn:aws:ecs:us-east-1:aws_account_id:task/uuid_2</member>
- </taskArns>
- <nextToken>token_UUID</nextToken>
- </ListTasksResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</ListTasksResponse>
-`
-
-var RegisterContainerInstanceResponse = `
-<RegisterContainerInstanceResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
- <RegisterContainerInstanceResult>
- <containerInstance>
- <agentConnected>True</agentConnected>
- <containerInstanceArn>arn:aws:ecs:us-east-1:aws_account_id:container-instance/container_instance_UUID</containerInstanceArn>
- <ec2InstanceId>instance_id</ec2InstanceId>
- <status>ACTIVE</status>
- <registeredResources>
- <member>
- <integerValue>2048</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>CPU</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>3955</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>MEMORY</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>0</integerValue>
- <longValue>0</longValue>
- <type>STRINGSET</type>
- <stringSetValue>
- <member>2376</member>
- <member>22</member>
- <member>51678</member>
- <member>2375</member>
- </stringSetValue>
- <name>PORTS</name>
- <doubleValue>0.0</doubleValue>
- </member>
- </registeredResources>
- <remainingResources>
- <member>
- <integerValue>2048</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>CPU</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>3955</integerValue>
- <longValue>0</longValue>
- <type>INTEGER</type>
- <name>MEMORY</name>
- <doubleValue>0.0</doubleValue>
- </member>
- <member>
- <integerValue>0</integerValue>
- <longValue>0</longValue>
- <type>STRINGSET</type>
- <stringSetValue>
- <member>2376</member>
- <member>22</member>
- <member>51678</member>
- <member>2375</member>
- </stringSetValue>
- <name>PORTS</name>
- <doubleValue>0.0</doubleValue>
- </member>
- </remainingResources>
- </containerInstance>
- </RegisterContainerInstanceResult>
-</RegisterContainerInstanceResponse>
-`
-
-var RegisterTaskDefinitionResponse = `
-<RegisterTaskDefinitionResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <RegisterTaskDefinitionResult>
- <taskDefinition>
- <revision>2</revision>
- <family>sleep360</family>
- <containerDefinitions>
- <member>
- <portMappings/>
- <essential>true</essential>
- <environment>
- <member>
- <name>envVar</name>
- <value>foo</value>
- </member>
- </environment>
- <entryPoint>
- <member>/bin/sh</member>
- </entryPoint>
- <name>sleep</name>
- <command>
- <member>sleep</member>
- <member>360</member>
- </command>
- <cpu>10</cpu>
- <image>busybox</image>
- <memory>10</memory>
- <mountPoints>
- <member>
- <containerPath>/tmp/myfile</containerPath>
- <readOnly>false</readOnly>
- <sourceVolume>/srv/myfile</sourceVolume>
- </member>
- <member>
- <containerPath>/tmp/myfile2</containerPath>
- <readOnly>true</readOnly>
- <sourceVolume>/srv/myfile2</sourceVolume>
- </member>
- </mountPoints>
- <volumesFrom>
- <member>
- <readOnly>true</readOnly>
- <sourceContainer>foo</sourceContainer>
- </member>
- </volumesFrom>
- </member>
- </containerDefinitions>
- <taskDefinitionArn>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</taskDefinitionArn>
- <volumes>
- <member>
- <name>/srv/myfile</name>
- <host>
- <sourcePath>/srv/myfile</sourcePath>
- </host>
- </member>
- </volumes>
- </taskDefinition>
- </RegisterTaskDefinitionResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</RegisterTaskDefinitionResponse>
-`
-
-var RunTaskResponse = `
-<RunTaskResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <RunTaskResult>
- <failures/>
- <tasks>
- <member>
- <containers>
- <member>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <name>sleep</name>
- <containerArn>arn:aws:ecs:us-east-1:aws_account_id:container/UUID</containerArn>
- <networkBindings/>
- <lastStatus>RUNNING</lastStatus>
- </member>
- </containers>
- <overrides>
- <containerOverrides>
- <member>
- <name>sleep</name>
- </member>
- </containerOverrides>
- </overrides>
- <desiredStatus>RUNNING</desiredStatus>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <containerInstanceArn>arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID</containerInstanceArn>
- <lastStatus>PENDING</lastStatus>
- <taskDefinitionArn>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</taskDefinitionArn>
- </member>
- </tasks>
- </RunTaskResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</RunTaskResponse>
-`
-
-var StartTaskResponse = `
-<StartTaskResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <StartTaskResult>
- <failures/>
- <tasks>
- <member>
- <containers>
- <member>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <name>sleep</name>
- <containerArn>arn:aws:ecs:us-east-1:aws_account_id:container/UUID</containerArn>
- <networkBindings/>
- <lastStatus>RUNNING</lastStatus>
- </member>
- </containers>
- <overrides>
- <containerOverrides>
- <member>
- <name>sleep</name>
- </member>
- </containerOverrides>
- </overrides>
- <desiredStatus>RUNNING</desiredStatus>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <containerInstanceArn>arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID</containerInstanceArn>
- <lastStatus>PENDING</lastStatus>
- <taskDefinitionArn>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</taskDefinitionArn>
- </member>
- </tasks>
- </StartTaskResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</StartTaskResponse>
-`
-
-var StopTaskResponse = `
-<StopTaskResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <StopTaskResult>
- <task>
- <containers>
- <member>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <name>sleep</name>
- <containerArn>arn:aws:ecs:us-east-1:aws_account_id:container/UUID</containerArn>
- <networkBindings/>
- <lastStatus>RUNNING</lastStatus>
- </member>
- </containers>
- <overrides>
- <containerOverrides>
- <member>
- <name>sleep</name>
- </member>
- </containerOverrides>
- </overrides>
- <desiredStatus>STOPPED</desiredStatus>
- <taskArn>arn:aws:ecs:us-east-1:aws_account_id:task/UUID</taskArn>
- <containerInstanceArn>arn:aws:ecs:us-east-1:aws_account_id:container-instance/UUID</containerInstanceArn>
- <lastStatus>RUNNING</lastStatus>
- <taskDefinitionArn>arn:aws:ecs:us-east-1:aws_account_id:task-definition/sleep360:2</taskDefinitionArn>
- </task>
- </StopTaskResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</StopTaskResponse>
-`
-
-var SubmitContainerStateChangeResponse = `
-<SubmitContainerStateChangeResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <SubmitContainerStateChangeResult>
- <acknowledgment>ACK</acknowledgment>
- </SubmitContainerStateChangeResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</SubmitContainerStateChangeResponse>
-`
-
-var SubmitTaskStateChangeResponse = `
-<SubmitTaskStateChangeResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
- <SubmitTaskStateChangeResult>
- <acknowledgment>ACK</acknowledgment>
- </SubmitTaskStateChangeResult>
- <ResponseMetadata>
- <RequestId>8d798a29-f083-11e1-bdfb-cb223EXAMPLE</RequestId>
- </ResponseMetadata>
-</SubmitTaskStateChangeResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/elb/elb.go b/vendor/github.com/goamz/goamz/elb/elb.go
deleted file mode 100644
index 0127435a7..000000000
--- a/vendor/github.com/goamz/goamz/elb/elb.go
+++ /dev/null
@@ -1,435 +0,0 @@
-// This package provides types and functions to interact Elastic Load Balancing service
-package elb
-
-import (
- "encoding/xml"
- "fmt"
- "net/http"
- "net/url"
- "sort"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-type ELB struct {
- aws.Auth
- aws.Region
-}
-
-func New(auth aws.Auth, region aws.Region) *ELB {
- return &ELB{auth, region}
-}
-
-// The CreateLoadBalancer type encapsulates options for the respective request in AWS.
-// The creation of a Load Balancer may differ inside EC2 and VPC.
-//
-// See http://goo.gl/4QFKi for more details.
-type CreateLoadBalancer struct {
- Name string
- AvailabilityZones []string
- Listeners []Listener
- Scheme string
- SecurityGroups []string
- Subnets []string
-}
-
-// Listener to configure in Load Balancer.
-//
-// See http://goo.gl/NJQCj for more details.
-type Listener struct {
- InstancePort int
- InstanceProtocol string
- LoadBalancerPort int
- Protocol string
- SSLCertificateId string
-}
-
-// Response to a CreateLoadBalance request.
-//
-// See http://goo.gl/4QFKi for more details.
-type CreateLoadBalancerResp struct {
- DNSName string `xml:"CreateLoadBalancerResult>DNSName"`
-}
-
-type SimpleResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// Creates a Load Balancer in Amazon.
-//
-// See http://goo.gl/4QFKi for more details.
-func (elb *ELB) CreateLoadBalancer(options *CreateLoadBalancer) (resp *CreateLoadBalancerResp, err error) {
- params := makeCreateParams(options)
- resp = new(CreateLoadBalancerResp)
- if err := elb.query(params, resp); err != nil {
- return nil, err
- }
- return
-}
-
-// Deletes a Load Balancer.
-//
-// See http://goo.gl/sDmPp for more details.
-func (elb *ELB) DeleteLoadBalancer(name string) (resp *SimpleResp, err error) {
- params := map[string]string{
- "Action": "DeleteLoadBalancer",
- "LoadBalancerName": name,
- }
- resp = new(SimpleResp)
- if err := elb.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-type RegisterInstancesResp struct {
- InstanceIds []string `xml:"RegisterInstancesWithLoadBalancerResult>Instances>member>InstanceId"`
-}
-
-// Register N instances with a given Load Balancer.
-//
-// See http://goo.gl/x9hru for more details.
-func (elb *ELB) RegisterInstancesWithLoadBalancer(instanceIds []string, lbName string) (resp *RegisterInstancesResp, err error) {
- // TODO: change params order and use ..., e.g (lbName string, instanceIds ...string)
- params := map[string]string{
- "Action": "RegisterInstancesWithLoadBalancer",
- "LoadBalancerName": lbName,
- }
- for i, instanceId := range instanceIds {
- key := fmt.Sprintf("Instances.member.%d.InstanceId", i+1)
- params[key] = instanceId
- }
- resp = new(RegisterInstancesResp)
- if err := elb.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Deregister N instances from a given Load Balancer.
-//
-// See http://goo.gl/Hgo4U for more details.
-func (elb *ELB) DeregisterInstancesFromLoadBalancer(instanceIds []string, lbName string) (resp *SimpleResp, err error) {
- // TODO: change params order and use ..., e.g (lbName string, instanceIds ...string)
- params := map[string]string{
- "Action": "DeregisterInstancesFromLoadBalancer",
- "LoadBalancerName": lbName,
- }
- for i, instanceId := range instanceIds {
- key := fmt.Sprintf("Instances.member.%d.InstanceId", i+1)
- params[key] = instanceId
- }
- resp = new(SimpleResp)
- if err := elb.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-type DescribeLoadBalancerResp struct {
- LoadBalancerDescriptions []LoadBalancerDescription `xml:"DescribeLoadBalancersResult>LoadBalancerDescriptions>member"`
-}
-
-type LoadBalancerDescription struct {
- AvailabilityZones []string `xml:"AvailabilityZones>member"`
- BackendServerDescriptions []BackendServerDescriptions `xml:"BackendServerDescriptions>member"`
- CanonicalHostedZoneName string `xml:"CanonicalHostedZoneName"`
- CanonicalHostedZoneNameId string `xml:"CanonicalHostedZoneNameID"`
- CreatedTime time.Time `xml:"CreatedTime"`
- DNSName string `xml:"DNSName"`
- HealthCheck HealthCheck `xml:"HealthCheck"`
- Instances []Instance `xml:"Instances>member"`
- ListenerDescriptions []ListenerDescription `xml:"ListenerDescriptions>member"`
- LoadBalancerName string `xml:"LoadBalancerName"`
- Policies Policies `xml:"Policies"`
- Scheme string `xml:"Scheme"`
- SecurityGroups []string `xml:"SecurityGroups>member"` //vpc only
- SourceSecurityGroup SourceSecurityGroup `xml:"SourceSecurityGroup"`
- Subnets []string `xml:"Subnets>member"`
- VPCId string `xml:"VPCId"`
-}
-
-// Describe Load Balancers.
-// It can be used to describe all Load Balancers or specific ones.
-//
-// See http://goo.gl/wofJA for more details.
-func (elb *ELB) DescribeLoadBalancers(names ...string) (*DescribeLoadBalancerResp, error) {
- params := map[string]string{"Action": "DescribeLoadBalancers"}
- for i, name := range names {
- index := fmt.Sprintf("LoadBalancerNames.member.%d", i+1)
- params[index] = name
- }
- resp := new(DescribeLoadBalancerResp)
- if err := elb.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-type BackendServerDescriptions struct {
- InstancePort int `xml:"InstancePort"`
- PolicyNames []string `xml:"PolicyNames>member"`
-}
-
-type HealthCheck struct {
- HealthyThreshold int `xml:"HealthyThreshold"`
- Interval int `xml:"Interval"`
- Target string `xml:"Target"`
- Timeout int `xml:"Timeout"`
- UnhealthyThreshold int `xml:"UnhealthyThreshold"`
-}
-
-type Instance struct {
- InstanceId string `xml:"InstanceId"`
-}
-
-type ListenerDescription struct {
- Listener Listener `xml:"Listener"`
- PolicyNames []string `xml:"PolicyNames>member"`
-}
-
-type Policies struct {
- AppCookieStickinessPolicies []AppCookieStickinessPolicies `xml:"AppCookieStickinessPolicies>member"`
- LBCookieStickinessPolicies []LBCookieStickinessPolicies `xml:"LBCookieStickinessPolicies>member"`
- OtherPolicies []string `xml:"OtherPolicies>member"`
-}
-
-// see http://goo.gl/clXGV for more information.
-type AppCookieStickinessPolicies struct {
- CookieName string `xml:"CookieName"`
- PolicyName string `xml:"PolicyName"`
-}
-
-type LBCookieStickinessPolicies struct {
- CookieExpirationPeriod int `xml:"CookieExpirationPeriod"`
- PolicyName string `xml:"PolicyName"`
-}
-
-type SourceSecurityGroup struct {
- GroupName string `xml:"GroupName"`
- OwnerAlias string `xml:"OwnerAlias"`
-}
-
-// Represents a XML response for DescribeInstanceHealth action
-//
-// See http://goo.gl/ovIB1 for more information.
-type DescribeInstanceHealthResp struct {
- InstanceStates []InstanceState `xml:"DescribeInstanceHealthResult>InstanceStates>member"`
-}
-
-// See http://goo.gl/dzWfP for more information.
-type InstanceState struct {
- Description string `xml:"Description"`
- InstanceId string `xml:"InstanceId"`
- ReasonCode string `xml:"ReasonCode"`
- State string `xml:"State"`
-}
-
-// Describe instance health.
-//
-// See http://goo.gl/ovIB1 for more information.
-func (elb *ELB) DescribeInstanceHealth(lbName string, instanceIds ...string) (*DescribeInstanceHealthResp, error) {
- params := map[string]string{
- "Action": "DescribeInstanceHealth",
- "LoadBalancerName": lbName,
- }
- for i, iId := range instanceIds {
- key := fmt.Sprintf("Instances.member.%d.InstanceId", i+1)
- params[key] = iId
- }
- resp := new(DescribeInstanceHealthResp)
- if err := elb.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-type HealthCheckResp struct {
- HealthCheck *HealthCheck `xml:"ConfigureHealthCheckResult>HealthCheck"`
-}
-
-// Configure health check for a LB
-//
-// See http://goo.gl/2HE6a for more information
-func (elb *ELB) ConfigureHealthCheck(lbName string, healthCheck *HealthCheck) (*HealthCheckResp, error) {
- params := map[string]string{
- "Action": "ConfigureHealthCheck",
- "LoadBalancerName": lbName,
- "HealthCheck.HealthyThreshold": strconv.Itoa(healthCheck.HealthyThreshold),
- "HealthCheck.Interval": strconv.Itoa(healthCheck.Interval),
- "HealthCheck.Target": healthCheck.Target,
- "HealthCheck.Timeout": strconv.Itoa(healthCheck.Timeout),
- "HealthCheck.UnhealthyThreshold": strconv.Itoa(healthCheck.UnhealthyThreshold),
- }
- resp := new(HealthCheckResp)
- if err := elb.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Add tags to the named ELB
-//
-// Note that AWS only accepts one ELB name at a time (even though it is sent as a list)
-//
-// See http://goo.gl/6JW4Wf for the rest of the details
-func (elb *ELB) AddTags(elbName string, tags map[string]string) (*SimpleResp, error) {
- var sortedKeys []string
- params := make(map[string]string)
- response := &SimpleResp{}
-
- for tagKey := range tags {
- sortedKeys = append(sortedKeys, tagKey)
- }
-
- sort.Strings(sortedKeys)
-
- for _, key := range sortedKeys {
- number := len(tags)
- params[fmt.Sprintf("Tags.member.%d.Key", number)] = key
- params[fmt.Sprintf("Tags.member.%d.Value", number)] = tags[key]
- delete(tags, key)
- }
-
- params["Action"] = "AddTags"
- params["LoadBalancerNames.member.1"] = elbName
-
- if err := elb.query(params, response); err != nil {
- return nil, err
- }
-
- return response, nil
-}
-
-// Remove tags from the named ELB
-//
-// Note that AWS only accepts one ELB name at a time (even though it is sent as a list)
-//
-// see http://goo.gl/ochFqo for more details
-
-func (elb *ELB) RemoveTags(elbName string, tagKeys []string) (*SimpleResp, error) {
- response := &SimpleResp{}
- params := make(map[string]string)
-
- params["Action"] = "RemoveTags"
- params["LoadBalancerNames.member.1"] = elbName
-
- for i, tagKey := range tagKeys {
- params[fmt.Sprintf("Tags.member.%d.Key", i+1)] = tagKey
- }
-
- if err := elb.query(params, response); err != nil {
- return nil, err
- }
-
- return response, nil
-}
-
-func (elb *ELB) query(params map[string]string, resp interface{}) error {
- params["Version"] = "2012-06-01"
- params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
- data := strings.NewReader(multimap(params).Encode())
- hreq, err := http.NewRequest("GET", elb.Region.ELBEndpoint+"/", data)
- if err != nil {
- return err
- }
-
- hreq.URL.RawQuery = multimap(params).Encode()
- token := elb.Auth.Token()
- if token != "" {
- hreq.Header.Set("X-Amz-Security-Token", token)
- }
-
- signer := aws.NewV4Signer(elb.Auth, "elasticloadbalancing", elb.Region)
- signer.Sign(hreq)
-
- r, err := http.DefaultClient.Do(hreq)
-
- if err != nil {
- return err
- }
- defer r.Body.Close()
- if r.StatusCode != 200 {
- return buildError(r)
- }
- return xml.NewDecoder(r.Body).Decode(resp)
-}
-
-// Error encapsulates an error returned by ELB.
-type Error struct {
- // HTTP status code
- StatusCode int
- // AWS error code
- Code string
- // The human-oriented error message
- Message string
-}
-
-func (err *Error) Error() string {
- if err.Code == "" {
- return err.Message
- }
-
- return fmt.Sprintf("%s (%s)", err.Message, err.Code)
-}
-
-type xmlErrors struct {
- Errors []Error `xml:"Error"`
-}
-
-func buildError(r *http.Response) error {
- var (
- err Error
- errors xmlErrors
- )
- xml.NewDecoder(r.Body).Decode(&errors)
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-func makeCreateParams(createLB *CreateLoadBalancer) map[string]string {
- params := make(map[string]string)
- params["LoadBalancerName"] = createLB.Name
- params["Action"] = "CreateLoadBalancer"
- if createLB.Scheme != "" {
- params["Scheme"] = createLB.Scheme
- }
- for i, s := range createLB.SecurityGroups {
- key := fmt.Sprintf("SecurityGroups.member.%d", i+1)
- params[key] = s
- }
- for i, s := range createLB.Subnets {
- key := fmt.Sprintf("Subnets.member.%d", i+1)
- params[key] = s
- }
- for i, l := range createLB.Listeners {
- key := "Listeners.member.%d.%s"
- index := i + 1
- params[fmt.Sprintf(key, index, "InstancePort")] = strconv.Itoa(l.InstancePort)
- params[fmt.Sprintf(key, index, "InstanceProtocol")] = l.InstanceProtocol
- params[fmt.Sprintf(key, index, "Protocol")] = l.Protocol
- params[fmt.Sprintf(key, index, "LoadBalancerPort")] = strconv.Itoa(l.LoadBalancerPort)
- }
- for i, az := range createLB.AvailabilityZones {
- key := fmt.Sprintf("AvailabilityZones.member.%d", i+1)
- params[key] = az
- }
- return params
-}
diff --git a/vendor/github.com/goamz/goamz/elb/elb_test.go b/vendor/github.com/goamz/goamz/elb/elb_test.go
deleted file mode 100644
index db799fdfc..000000000
--- a/vendor/github.com/goamz/goamz/elb/elb_test.go
+++ /dev/null
@@ -1,369 +0,0 @@
-package elb_test
-
-import (
- "time"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/elb"
- . "gopkg.in/check.v1"
-)
-
-type S struct {
- HTTPSuite
- elb *elb.ELB
-}
-
-var _ = Suite(&S{})
-
-func (s *S) SetUpSuite(c *C) {
- s.HTTPSuite.SetUpSuite(c)
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.elb = elb.New(auth, aws.Region{ELBEndpoint: testServer.URL})
-}
-
-func (s *S) TestCreateLoadBalancer(c *C) {
- testServer.PrepareResponse(200, nil, CreateLoadBalancer)
- createLB := &elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a", "us-east-1b"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- Protocol: "http",
- LoadBalancerPort: 80,
- },
- },
- }
- resp, err := s.elb.CreateLoadBalancer(createLB)
- c.Assert(err, IsNil)
- defer s.elb.DeleteLoadBalancer(createLB.Name)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Action"), Equals, "CreateLoadBalancer")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("LoadBalancerName"), Equals, "testlb")
- c.Assert(values.Get("AvailabilityZones.member.1"), Equals, "us-east-1a")
- c.Assert(values.Get("AvailabilityZones.member.2"), Equals, "us-east-1b")
- c.Assert(values.Get("Listeners.member.1.InstancePort"), Equals, "80")
- c.Assert(values.Get("Listeners.member.1.InstanceProtocol"), Equals, "http")
- c.Assert(values.Get("Listeners.member.1.Protocol"), Equals, "http")
- c.Assert(values.Get("Listeners.member.1.LoadBalancerPort"), Equals, "80")
- c.Assert(resp.DNSName, Equals, "testlb-339187009.us-east-1.elb.amazonaws.com")
-}
-
-func (s *S) TestCreateLoadBalancerWithSubnetsAndMoreListeners(c *C) {
- testServer.PrepareResponse(200, nil, CreateLoadBalancer)
- createLB := &elb.CreateLoadBalancer{
- Name: "testlb",
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- Protocol: "http",
- LoadBalancerPort: 80,
- },
- {
- InstancePort: 8080,
- InstanceProtocol: "http",
- Protocol: "http",
- LoadBalancerPort: 8080,
- },
- },
- Subnets: []string{"subnetid-1", "subnetid-2"},
- SecurityGroups: []string{"sg-1", "sg-2"},
- }
- _, err := s.elb.CreateLoadBalancer(createLB)
- c.Assert(err, IsNil)
- defer s.elb.DeleteLoadBalancer(createLB.Name)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Listeners.member.1.InstancePort"), Equals, "80")
- c.Assert(values.Get("Listeners.member.1.LoadBalancerPort"), Equals, "80")
- c.Assert(values.Get("Listeners.member.2.InstancePort"), Equals, "8080")
- c.Assert(values.Get("Listeners.member.2.LoadBalancerPort"), Equals, "8080")
- c.Assert(values.Get("Subnets.member.1"), Equals, "subnetid-1")
- c.Assert(values.Get("Subnets.member.2"), Equals, "subnetid-2")
- c.Assert(values.Get("SecurityGroups.member.1"), Equals, "sg-1")
- c.Assert(values.Get("SecurityGroups.member.2"), Equals, "sg-2")
-}
-
-func (s *S) TestCreateLoadBalancerWithWrongParamsCombination(c *C) {
- testServer.PrepareResponse(400, nil, CreateLoadBalancerBadRequest)
- createLB := &elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a", "us-east-1b"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- Protocol: "http",
- LoadBalancerPort: 80,
- },
- },
- Subnets: []string{"subnetid-1", "subnetid2"},
- }
- resp, err := s.elb.CreateLoadBalancer(createLB)
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- e, ok := err.(*elb.Error)
- c.Assert(ok, Equals, true)
- c.Assert(e.Message, Equals, "Only one of SubnetIds or AvailabilityZones may be specified")
- c.Assert(e.Code, Equals, "ValidationError")
-}
-
-func (s *S) TestDeleteLoadBalancer(c *C) {
- testServer.PrepareResponse(200, nil, DeleteLoadBalancer)
- resp, err := s.elb.DeleteLoadBalancer("testlb")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("Action"), Equals, "DeleteLoadBalancer")
- c.Assert(values.Get("LoadBalancerName"), Equals, "testlb")
- c.Assert(resp.RequestId, Equals, "8d7223db-49d7-11e2-bba9-35ba56032fe1")
-}
-
-func (s *S) TestRegisterInstancesWithLoadBalancer(c *C) {
- testServer.PrepareResponse(200, nil, RegisterInstancesWithLoadBalancer)
- resp, err := s.elb.RegisterInstancesWithLoadBalancer([]string{"i-b44db8ca", "i-461ecf38"}, "testlb")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("Action"), Equals, "RegisterInstancesWithLoadBalancer")
- c.Assert(values.Get("LoadBalancerName"), Equals, "testlb")
- c.Assert(values.Get("Instances.member.1.InstanceId"), Equals, "i-b44db8ca")
- c.Assert(values.Get("Instances.member.2.InstanceId"), Equals, "i-461ecf38")
- c.Assert(resp.InstanceIds, DeepEquals, []string{"i-b44db8ca", "i-461ecf38"})
-}
-
-func (s *S) TestRegisterInstancesWithLoadBalancerBadRequest(c *C) {
- testServer.PrepareResponse(400, nil, RegisterInstancesWithLoadBalancerBadRequest)
- resp, err := s.elb.RegisterInstancesWithLoadBalancer([]string{"i-b44db8ca", "i-461ecf38"}, "absentLB")
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- e, ok := err.(*elb.Error)
- c.Assert(ok, Equals, true)
- c.Assert(e.Message, Equals, "There is no ACTIVE Load Balancer named 'absentLB'")
- c.Assert(e.Code, Equals, "LoadBalancerNotFound")
-}
-
-func (s *S) TestDeregisterInstancesFromLoadBalancer(c *C) {
- testServer.PrepareResponse(200, nil, DeregisterInstancesFromLoadBalancer)
- resp, err := s.elb.DeregisterInstancesFromLoadBalancer([]string{"i-b44db8ca", "i-461ecf38"}, "testlb")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("Action"), Equals, "DeregisterInstancesFromLoadBalancer")
- c.Assert(values.Get("LoadBalancerName"), Equals, "testlb")
- c.Assert(values.Get("Instances.member.1.InstanceId"), Equals, "i-b44db8ca")
- c.Assert(values.Get("Instances.member.2.InstanceId"), Equals, "i-461ecf38")
- c.Assert(resp.RequestId, Equals, "d6490837-49fd-11e2-bba9-35ba56032fe1")
-}
-
-func (s *S) TestDeregisterInstancesFromLoadBalancerBadRequest(c *C) {
- testServer.PrepareResponse(400, nil, DeregisterInstancesFromLoadBalancerBadRequest)
- resp, err := s.elb.DeregisterInstancesFromLoadBalancer([]string{"i-b44db8ca", "i-461ecf38"}, "testlb")
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- e, ok := err.(*elb.Error)
- c.Assert(ok, Equals, true)
- c.Assert(e.Message, Equals, "There is no ACTIVE Load Balancer named 'absentlb'")
- c.Assert(e.Code, Equals, "LoadBalancerNotFound")
-}
-
-func (s *S) TestDescribeLoadBalancers(c *C) {
- testServer.PrepareResponse(200, nil, DescribeLoadBalancers)
- resp, err := s.elb.DescribeLoadBalancers()
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("Action"), Equals, "DescribeLoadBalancers")
- t, _ := time.Parse(time.RFC3339, "2012-12-27T11:51:52.970Z")
- expected := &elb.DescribeLoadBalancerResp{
- []elb.LoadBalancerDescription{
- {
- AvailabilityZones: []string{"us-east-1a"},
- BackendServerDescriptions: []elb.BackendServerDescriptions(nil),
- CanonicalHostedZoneName: "testlb-2087227216.us-east-1.elb.amazonaws.com",
- CanonicalHostedZoneNameId: "Z3DZXE0Q79N41H",
- CreatedTime: t,
- DNSName: "testlb-2087227216.us-east-1.elb.amazonaws.com",
- HealthCheck: elb.HealthCheck{
- HealthyThreshold: 10,
- Interval: 30,
- Target: "TCP:80",
- Timeout: 5,
- UnhealthyThreshold: 2,
- },
- Instances: []elb.Instance(nil),
- ListenerDescriptions: []elb.ListenerDescription{
- {
- Listener: elb.Listener{
- Protocol: "HTTP",
- LoadBalancerPort: 80,
- InstanceProtocol: "HTTP",
- InstancePort: 80,
- },
- },
- },
- LoadBalancerName: "testlb",
- //Policies: elb.Policies(nil),
- Scheme: "internet-facing",
- SecurityGroups: []string(nil),
- SourceSecurityGroup: elb.SourceSecurityGroup{
- GroupName: "amazon-elb-sg",
- OwnerAlias: "amazon-elb",
- },
- Subnets: []string(nil),
- },
- },
- }
- c.Assert(resp, DeepEquals, expected)
-}
-
-func (s *S) TestDescribeLoadBalancersByName(c *C) {
- testServer.PrepareResponse(200, nil, DescribeLoadBalancers)
- s.elb.DescribeLoadBalancers("somelb")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("Action"), Equals, "DescribeLoadBalancers")
- c.Assert(values.Get("LoadBalancerNames.member.1"), Equals, "somelb")
-}
-
-func (s *S) TestDescribeLoadBalancersBadRequest(c *C) {
- testServer.PrepareResponse(400, nil, DescribeLoadBalancersBadRequest)
- resp, err := s.elb.DescribeLoadBalancers()
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- c.Assert(err, ErrorMatches, `^Cannot find Load Balancer absentlb \(LoadBalancerNotFound\)$`)
-}
-
-func (s *S) TestDescribeInstanceHealth(c *C) {
- testServer.PrepareResponse(200, nil, DescribeInstanceHealth)
- resp, err := s.elb.DescribeInstanceHealth("testlb", "i-b44db8ca")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("Action"), Equals, "DescribeInstanceHealth")
- c.Assert(values.Get("LoadBalancerName"), Equals, "testlb")
- c.Assert(values.Get("Instances.member.1.InstanceId"), Equals, "i-b44db8ca")
- c.Assert(len(resp.InstanceStates) > 0, Equals, true)
- c.Assert(resp.InstanceStates[0].Description, Equals, "Instance registration is still in progress.")
- c.Assert(resp.InstanceStates[0].InstanceId, Equals, "i-b44db8ca")
- c.Assert(resp.InstanceStates[0].State, Equals, "OutOfService")
- c.Assert(resp.InstanceStates[0].ReasonCode, Equals, "ELB")
-}
-
-func (s *S) TestDescribeInstanceHealthBadRequest(c *C) {
- testServer.PrepareResponse(400, nil, DescribeInstanceHealthBadRequest)
- resp, err := s.elb.DescribeInstanceHealth("testlb", "i-foooo")
- c.Assert(err, NotNil)
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, ".*i-foooo.*(InvalidInstance).*")
-}
-
-func (s *S) TestConfigureHealthCheck(c *C) {
- testServer.PrepareResponse(200, nil, ConfigureHealthCheck)
- hc := elb.HealthCheck{
- HealthyThreshold: 10,
- Interval: 30,
- Target: "HTTP:80/",
- Timeout: 5,
- UnhealthyThreshold: 2,
- }
- resp, err := s.elb.ConfigureHealthCheck("testlb", &hc)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("Action"), Equals, "ConfigureHealthCheck")
- c.Assert(values.Get("LoadBalancerName"), Equals, "testlb")
- c.Assert(values.Get("HealthCheck.HealthyThreshold"), Equals, "10")
- c.Assert(values.Get("HealthCheck.Interval"), Equals, "30")
- c.Assert(values.Get("HealthCheck.Target"), Equals, "HTTP:80/")
- c.Assert(values.Get("HealthCheck.Timeout"), Equals, "5")
- c.Assert(values.Get("HealthCheck.UnhealthyThreshold"), Equals, "2")
- c.Assert(resp.HealthCheck.HealthyThreshold, Equals, 10)
- c.Assert(resp.HealthCheck.Interval, Equals, 30)
- c.Assert(resp.HealthCheck.Target, Equals, "HTTP:80/")
- c.Assert(resp.HealthCheck.Timeout, Equals, 5)
- c.Assert(resp.HealthCheck.UnhealthyThreshold, Equals, 2)
-}
-
-func (s *S) TestConfigureHealthCheckBadRequest(c *C) {
- testServer.PrepareResponse(400, nil, ConfigureHealthCheckBadRequest)
- hc := elb.HealthCheck{
- HealthyThreshold: 10,
- Interval: 30,
- Target: "HTTP:80/",
- Timeout: 5,
- UnhealthyThreshold: 2,
- }
- resp, err := s.elb.ConfigureHealthCheck("foolb", &hc)
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- c.Assert(err, ErrorMatches, ".*foolb.*(LoadBalancerNotFound).*")
-}
-
-func (s *S) TestAddTags(c *C) {
- testServer.PrepareResponse(200, nil, AddTagsSuccessResponse)
- tagsToAdd := map[string]string{
- "my-key": "my-value",
- "my-super-silly-tag": "its-another-valid-value",
- }
-
- resp, err := s.elb.AddTags("my-elb", tagsToAdd)
- c.Assert(err, IsNil)
-
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Action"), Equals, "AddTags")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("LoadBalancerNames.member.1"), Equals, "my-elb")
- c.Assert(values.Get("Tags.member.1.Key"), Equals, "my-super-silly-tag")
- c.Assert(values.Get("Tags.member.1.Value"), Equals, "its-another-valid-value")
- c.Assert(values.Get("Tags.member.2.Key"), Equals, "my-key")
- c.Assert(values.Get("Tags.member.2.Value"), Equals, "my-value")
-
- c.Assert(resp.RequestId, Equals, "360e81f7-1100-11e4-b6ed-0f30SOME-SAUCY-EXAMPLE")
-}
-
-func (s *S) TestAddBadTags(c *C) {
- testServer.PrepareResponse(400, nil, TagsBadRequest)
- tagsToAdd := map[string]string{
- "my-first-key": "an invalid value",
- }
-
- resp, err := s.elb.AddTags("my-bad-elb", tagsToAdd)
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, ".*(InvalidParameterValue).*")
-}
-
-func (s *S) TestRemoveTags(c *C) {
- testServer.PrepareResponse(200, nil, RemoveTagsSuccessResponse)
- tagKeysToRemove := []string{"a-key-one", "a-key-two"}
-
- resp, err := s.elb.RemoveTags("my-test-elb-1", tagKeysToRemove)
- c.Assert(err, IsNil)
-
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Version"), Equals, "2012-06-01")
- c.Assert(values.Get("Action"), Equals, "RemoveTags")
- c.Assert(values.Get("Timestamp"), Not(Equals), "")
- c.Assert(values.Get("LoadBalancerNames.member.1"), Equals, "my-test-elb-1")
- c.Assert([]string{values.Get("Tags.member.1.Key"), values.Get("Tags.member.2.Key")}, DeepEquals, tagKeysToRemove)
- c.Assert(resp.RequestId, Equals, "83c88b9d-12b7-11e3-8b82-87b12DIFFEXAMPLE")
-}
-
-func (s *S) TestRemoveTagsFailure(c *C) {
- testServer.PrepareResponse(400, nil, TagsBadRequest)
-
- resp, err := s.elb.RemoveTags("my-test-elb", []string{"non-existant-tag"})
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, ".*(InvalidParameterValue).*")
-}
diff --git a/vendor/github.com/goamz/goamz/elb/elbi_test.go b/vendor/github.com/goamz/goamz/elb/elbi_test.go
deleted file mode 100644
index 4c21f9e38..000000000
--- a/vendor/github.com/goamz/goamz/elb/elbi_test.go
+++ /dev/null
@@ -1,308 +0,0 @@
-package elb_test
-
-import (
- "flag"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/ec2"
- "github.com/goamz/goamz/elb"
- . "gopkg.in/check.v1"
-)
-
-var amazon = flag.Bool("amazon", false, "Enable tests against amazon server")
-
-// AmazonServer represents an Amazon AWS server.
-type AmazonServer struct {
- auth aws.Auth
-}
-
-func (s *AmazonServer) SetUp(c *C) {
- auth, err := aws.EnvAuth()
- if err != nil {
- c.Fatal(err)
- }
- s.auth = auth
-}
-
-var _ = Suite(&AmazonClientSuite{})
-
-// AmazonClientSuite tests the client against a live AWS server.
-type AmazonClientSuite struct {
- srv AmazonServer
- ClientTests
-}
-
-// ClientTests defines integration tests designed to test the client.
-// It is not used as a test suite in itself, but embedded within
-// another type.
-type ClientTests struct {
- elb *elb.ELB
- ec2 *ec2.EC2
-}
-
-func (s *AmazonClientSuite) SetUpSuite(c *C) {
- if !*amazon {
- c.Skip("AmazonClientSuite tests not enabled")
- }
- s.srv.SetUp(c)
- s.elb = elb.New(s.srv.auth, aws.USEast)
- s.ec2 = ec2.New(s.srv.auth, aws.USEast)
-}
-
-func (s *ClientTests) TestCreateAndDeleteLoadBalancer(c *C) {
- createLBReq := elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- LoadBalancerPort: 80,
- Protocol: "http",
- },
- },
- }
- resp, err := s.elb.CreateLoadBalancer(&createLBReq)
- c.Assert(err, IsNil)
- defer s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Assert(resp.DNSName, Not(Equals), "")
- deleteResp, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Assert(err, IsNil)
- c.Assert(deleteResp.RequestId, Not(Equals), "")
-}
-
-func (s *ClientTests) TestCreateLoadBalancerError(c *C) {
- createLBReq := elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a"},
- Subnets: []string{"subnetid-1"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- LoadBalancerPort: 80,
- Protocol: "http",
- },
- },
- }
- resp, err := s.elb.CreateLoadBalancer(&createLBReq)
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- e, ok := err.(*elb.Error)
- c.Assert(ok, Equals, true)
- c.Assert(e.Message, Matches, "Only one of .* or .* may be specified")
- c.Assert(e.Code, Equals, "ValidationError")
-}
-
-func (s *ClientTests) createInstanceAndLB(c *C) (*elb.CreateLoadBalancer, string) {
- options := ec2.RunInstancesOptions{
- ImageId: "ami-ccf405a5",
- InstanceType: "t1.micro",
- AvailabilityZone: "us-east-1c",
- }
- resp1, err := s.ec2.RunInstances(&options)
- c.Assert(err, IsNil)
- instId := resp1.Instances[0].InstanceId
- createLBReq := elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1c"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- LoadBalancerPort: 80,
- Protocol: "http",
- },
- },
- }
- _, err = s.elb.CreateLoadBalancer(&createLBReq)
- c.Assert(err, IsNil)
- return &createLBReq, instId
-}
-
-// Cost: 0.02 USD
-func (s *ClientTests) TestCreateRegisterAndDeregisterInstanceWithLoadBalancer(c *C) {
- createLBReq, instId := s.createInstanceAndLB(c)
- defer func() {
- _, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Check(err, IsNil)
- _, err = s.ec2.TerminateInstances([]string{instId})
- c.Check(err, IsNil)
- }()
- resp, err := s.elb.RegisterInstancesWithLoadBalancer([]string{instId}, createLBReq.Name)
- c.Assert(err, IsNil)
- c.Assert(resp.InstanceIds, DeepEquals, []string{instId})
- resp2, err := s.elb.DeregisterInstancesFromLoadBalancer([]string{instId}, createLBReq.Name)
- c.Assert(err, IsNil)
- c.Assert(resp2, Not(Equals), "")
-}
-
-func (s *ClientTests) TestDescribeLoadBalancers(c *C) {
- createLBReq := elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- LoadBalancerPort: 80,
- Protocol: "http",
- },
- },
- }
- _, err := s.elb.CreateLoadBalancer(&createLBReq)
- c.Assert(err, IsNil)
- defer func() {
- _, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Check(err, IsNil)
- }()
- resp, err := s.elb.DescribeLoadBalancers()
- c.Assert(err, IsNil)
- c.Assert(len(resp.LoadBalancerDescriptions) > 0, Equals, true)
- c.Assert(resp.LoadBalancerDescriptions[0].AvailabilityZones, DeepEquals, []string{"us-east-1a"})
- c.Assert(resp.LoadBalancerDescriptions[0].LoadBalancerName, Equals, "testlb")
- c.Assert(resp.LoadBalancerDescriptions[0].Scheme, Equals, "internet-facing")
- hc := elb.HealthCheck{
- HealthyThreshold: 10,
- Interval: 30,
- Target: "TCP:80",
- Timeout: 5,
- UnhealthyThreshold: 2,
- }
- c.Assert(resp.LoadBalancerDescriptions[0].HealthCheck, DeepEquals, hc)
- ld := []elb.ListenerDescription{
- {
- Listener: elb.Listener{
- Protocol: "HTTP",
- LoadBalancerPort: 80,
- InstanceProtocol: "HTTP",
- InstancePort: 80,
- },
- },
- }
- c.Assert(resp.LoadBalancerDescriptions[0].ListenerDescriptions, DeepEquals, ld)
- ssg := elb.SourceSecurityGroup{
- GroupName: "amazon-elb-sg",
- OwnerAlias: "amazon-elb",
- }
- c.Assert(resp.LoadBalancerDescriptions[0].SourceSecurityGroup, DeepEquals, ssg)
-}
-
-func (s *ClientTests) TestDescribeLoadBalancersBadRequest(c *C) {
- resp, err := s.elb.DescribeLoadBalancers("absentlb")
- c.Assert(err, NotNil)
- c.Assert(resp, IsNil)
- c.Assert(err, ErrorMatches, ".*(LoadBalancerNotFound).*")
-}
-
-func (s *ClientTests) TestDescribeInstanceHealth(c *C) {
- createLBReq, instId := s.createInstanceAndLB(c)
- defer func() {
- _, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Check(err, IsNil)
- _, err = s.ec2.TerminateInstances([]string{instId})
- c.Check(err, IsNil)
- }()
- _, err := s.elb.RegisterInstancesWithLoadBalancer([]string{instId}, createLBReq.Name)
- c.Assert(err, IsNil)
- resp, err := s.elb.DescribeInstanceHealth(createLBReq.Name, instId)
- c.Assert(err, IsNil)
- c.Assert(len(resp.InstanceStates) > 0, Equals, true)
- c.Assert(resp.InstanceStates[0].Description, Equals, "Instance is in pending state.")
- c.Assert(resp.InstanceStates[0].InstanceId, Equals, instId)
- c.Assert(resp.InstanceStates[0].State, Equals, "OutOfService")
- c.Assert(resp.InstanceStates[0].ReasonCode, Equals, "Instance")
-}
-
-func (s *ClientTests) TestDescribeInstanceHealthBadRequest(c *C) {
- createLBReq := elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- LoadBalancerPort: 80,
- Protocol: "http",
- },
- },
- }
- _, err := s.elb.CreateLoadBalancer(&createLBReq)
- c.Assert(err, IsNil)
- defer func() {
- _, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Check(err, IsNil)
- }()
- resp, err := s.elb.DescribeInstanceHealth(createLBReq.Name, "i-foo")
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- c.Assert(err, ErrorMatches, ".*i-foo.*(InvalidInstance).*")
-}
-
-func (s *ClientTests) TestConfigureHealthCheck(c *C) {
- createLBReq := elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- LoadBalancerPort: 80,
- Protocol: "http",
- },
- },
- }
- _, err := s.elb.CreateLoadBalancer(&createLBReq)
- c.Assert(err, IsNil)
- defer func() {
- _, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Check(err, IsNil)
- }()
- hc := elb.HealthCheck{
- HealthyThreshold: 10,
- Interval: 30,
- Target: "HTTP:80/",
- Timeout: 5,
- UnhealthyThreshold: 2,
- }
- resp, err := s.elb.ConfigureHealthCheck(createLBReq.Name, &hc)
- c.Assert(err, IsNil)
- c.Assert(resp.HealthCheck.HealthyThreshold, Equals, 10)
- c.Assert(resp.HealthCheck.Interval, Equals, 30)
- c.Assert(resp.HealthCheck.Target, Equals, "HTTP:80/")
- c.Assert(resp.HealthCheck.Timeout, Equals, 5)
- c.Assert(resp.HealthCheck.UnhealthyThreshold, Equals, 2)
-}
-
-func (s *ClientTests) TestConfigureHealthCheckBadRequest(c *C) {
- createLBReq := elb.CreateLoadBalancer{
- Name: "testlb",
- AvailabilityZones: []string{"us-east-1a"},
- Listeners: []elb.Listener{
- {
- InstancePort: 80,
- InstanceProtocol: "http",
- LoadBalancerPort: 80,
- Protocol: "http",
- },
- },
- }
- _, err := s.elb.CreateLoadBalancer(&createLBReq)
- c.Assert(err, IsNil)
- defer func() {
- _, err := s.elb.DeleteLoadBalancer(createLBReq.Name)
- c.Check(err, IsNil)
- }()
- hc := elb.HealthCheck{
- HealthyThreshold: 10,
- Interval: 30,
- Target: "HTTP:80",
- Timeout: 5,
- UnhealthyThreshold: 2,
- }
- resp, err := s.elb.ConfigureHealthCheck(createLBReq.Name, &hc)
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- expected := "HealthCheck HTTP Target must specify a port followed by a path that begins with a slash. e.g. HTTP:80/ping/this/path (ValidationError)"
- c.Assert(err.Error(), Equals, expected)
-}
diff --git a/vendor/github.com/goamz/goamz/elb/elbt_test.go b/vendor/github.com/goamz/goamz/elb/elbt_test.go
deleted file mode 100644
index 2ea529452..000000000
--- a/vendor/github.com/goamz/goamz/elb/elbt_test.go
+++ /dev/null
@@ -1,243 +0,0 @@
-package elb_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/elb"
- "github.com/goamz/goamz/elb/elbtest"
- . "gopkg.in/check.v1"
-)
-
-// LocalServer represents a local elbtest fake server.
-type LocalServer struct {
- auth aws.Auth
- region aws.Region
- srv *elbtest.Server
-}
-
-func (s *LocalServer) SetUp(c *C) {
- srv, err := elbtest.NewServer()
- c.Assert(err, IsNil)
- c.Assert(srv, NotNil)
- s.srv = srv
- s.region = aws.Region{ELBEndpoint: srv.URL()}
-}
-
-// LocalServerSuite defines tests that will run
-// against the local elbtest server. It includes
-// selected tests from ClientTests;
-// when the elbtest functionality is sufficient, it should
-// include all of them, and ClientTests can be simply embedded.
-type LocalServerSuite struct {
- srv LocalServer
- ServerTests
- clientTests ClientTests
-}
-
-// ServerTests defines a set of tests designed to test
-// the elbtest local fake elb server.
-// It is not used as a test suite in itself, but embedded within
-// another type.
-type ServerTests struct {
- elb *elb.ELB
-}
-
-// AmazonServerSuite runs the elbtest server tests against a live ELB server.
-// It will only be activated if the -all flag is specified.
-type AmazonServerSuite struct {
- srv AmazonServer
- ServerTests
-}
-
-var _ = Suite(&AmazonServerSuite{})
-
-func (s *AmazonServerSuite) SetUpSuite(c *C) {
- if !*amazon {
- c.Skip("AmazonServerSuite tests not enabled")
- }
- s.srv.SetUp(c)
- s.ServerTests.elb = elb.New(s.srv.auth, aws.USEast)
-}
-
-var _ = Suite(&LocalServerSuite{})
-
-func (s *LocalServerSuite) SetUpSuite(c *C) {
- s.srv.SetUp(c)
- s.ServerTests.elb = elb.New(s.srv.auth, s.srv.region)
- s.clientTests.elb = elb.New(s.srv.auth, s.srv.region)
-}
-
-func (s *LocalServerSuite) TestCreateLoadBalancer(c *C) {
- s.clientTests.TestCreateAndDeleteLoadBalancer(c)
-}
-
-func (s *LocalServerSuite) TestCreateLoadBalancerError(c *C) {
- s.clientTests.TestCreateLoadBalancerError(c)
-}
-
-func (s *LocalServerSuite) TestDescribeLoadBalancer(c *C) {
- s.clientTests.TestDescribeLoadBalancers(c)
-}
-
-func (s *LocalServerSuite) TestDescribeLoadBalancerListsAddedByNewLoadbalancerFunc(c *C) {
- srv := s.srv.srv
- srv.NewLoadBalancer("wierdlb")
- defer srv.RemoveLoadBalancer("wierdlb")
- resp, err := s.clientTests.elb.DescribeLoadBalancers()
- c.Assert(err, IsNil)
- isPresent := false
- for _, desc := range resp.LoadBalancerDescriptions {
- if desc.LoadBalancerName == "wierdlb" {
- isPresent = true
- }
- }
- c.Assert(isPresent, Equals, true)
-}
-
-func (s *LocalServerSuite) TestDescribeLoadBalancerListsInstancesAddedByRegisterInstancesFunc(c *C) {
- srv := s.srv.srv
- lbName := "somelb"
- srv.NewLoadBalancer(lbName)
- defer srv.RemoveLoadBalancer(lbName)
- instId := srv.NewInstance()
- defer srv.RemoveInstance(instId)
- srv.RegisterInstance(instId, lbName) // no need to deregister, since we're removing the lb
- resp, err := s.clientTests.elb.DescribeLoadBalancers()
- c.Assert(err, IsNil)
- c.Assert(len(resp.LoadBalancerDescriptions) > 0, Equals, true)
- c.Assert(len(resp.LoadBalancerDescriptions[0].Instances) > 0, Equals, true)
- c.Assert(resp.LoadBalancerDescriptions[0].Instances, DeepEquals, []elb.Instance{{InstanceId: instId}})
- srv.DeregisterInstance(instId, lbName)
- resp, err = s.clientTests.elb.DescribeLoadBalancers()
- c.Assert(err, IsNil)
- c.Assert(resp.LoadBalancerDescriptions[0].Instances, DeepEquals, []elb.Instance(nil))
-}
-
-func (s *LocalServerSuite) TestDescribeLoadBalancersBadRequest(c *C) {
- s.clientTests.TestDescribeLoadBalancersBadRequest(c)
-}
-
-func (s *LocalServerSuite) TestRegisterInstanceWithLoadBalancer(c *C) {
- srv := s.srv.srv
- instId := srv.NewInstance()
- defer srv.RemoveInstance(instId)
- srv.NewLoadBalancer("testlb")
- defer srv.RemoveLoadBalancer("testlb")
- resp, err := s.clientTests.elb.RegisterInstancesWithLoadBalancer([]string{instId}, "testlb")
- c.Assert(err, IsNil)
- c.Assert(resp.InstanceIds, DeepEquals, []string{instId})
-}
-
-func (s *LocalServerSuite) TestRegisterInstanceWithLoadBalancerWithAbsentInstance(c *C) {
- srv := s.srv.srv
- srv.NewLoadBalancer("testlb")
- defer srv.RemoveLoadBalancer("testlb")
- resp, err := s.clientTests.elb.RegisterInstancesWithLoadBalancer([]string{"i-212"}, "testlb")
- c.Assert(err, NotNil)
- c.Assert(err, ErrorMatches, `^InvalidInstance found in \[i-212\]. Invalid id: "i-212" \(InvalidInstance\)$`)
- c.Assert(resp, IsNil)
-}
-
-func (s *LocalServerSuite) TestRegisterInstanceWithLoadBalancerWithAbsentLoadBalancer(c *C) {
- // the verification if the lb exists is done before the instances, so there is no need to create
- // fixture instances for this test, it'll never get that far
- resp, err := s.clientTests.elb.RegisterInstancesWithLoadBalancer([]string{"i-212"}, "absentlb")
- c.Assert(err, NotNil)
- c.Assert(err, ErrorMatches, `^There is no ACTIVE Load Balancer named 'absentlb' \(LoadBalancerNotFound\)$`)
- c.Assert(resp, IsNil)
-}
-
-func (s *LocalServerSuite) TestDeregisterInstanceWithLoadBalancer(c *C) {
- // there is no need to register the instance first, amazon returns the same response
- // in both cases (instance registered or not)
- srv := s.srv.srv
- instId := srv.NewInstance()
- defer srv.RemoveInstance(instId)
- srv.NewLoadBalancer("testlb")
- defer srv.RemoveLoadBalancer("testlb")
- resp, err := s.clientTests.elb.DeregisterInstancesFromLoadBalancer([]string{instId}, "testlb")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Not(Equals), "")
-}
-
-func (s *LocalServerSuite) TestDeregisterInstanceWithLoadBalancerWithAbsentLoadBalancer(c *C) {
- resp, err := s.clientTests.elb.DeregisterInstancesFromLoadBalancer([]string{"i-212"}, "absentlb")
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- c.Assert(err, ErrorMatches, `^There is no ACTIVE Load Balancer named 'absentlb' \(LoadBalancerNotFound\)$`)
-}
-
-func (s *LocalServerSuite) TestDeregisterInstancewithLoadBalancerWithAbsentInstance(c *C) {
- srv := s.srv.srv
- srv.NewLoadBalancer("testlb")
- defer srv.RemoveLoadBalancer("testlb")
- resp, err := s.clientTests.elb.DeregisterInstancesFromLoadBalancer([]string{"i-212"}, "testlb")
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- c.Assert(err, ErrorMatches, `^InvalidInstance found in \[i-212\]. Invalid id: "i-212" \(InvalidInstance\)$`)
-}
-
-func (s *LocalServerSuite) TestDescribeInstanceHealth(c *C) {
- srv := s.srv.srv
- instId := srv.NewInstance()
- defer srv.RemoveInstance(instId)
- srv.NewLoadBalancer("testlb")
- defer srv.RemoveLoadBalancer("testlb")
- resp, err := s.clientTests.elb.DescribeInstanceHealth("testlb", instId)
- c.Assert(err, IsNil)
- c.Assert(len(resp.InstanceStates) > 0, Equals, true)
- c.Assert(resp.InstanceStates[0].Description, Equals, "Instance is in pending state.")
- c.Assert(resp.InstanceStates[0].InstanceId, Equals, instId)
- c.Assert(resp.InstanceStates[0].State, Equals, "OutOfService")
- c.Assert(resp.InstanceStates[0].ReasonCode, Equals, "Instance")
-}
-
-func (s *LocalServerSuite) TestDescribeInstanceHealthBadRequest(c *C) {
- s.clientTests.TestDescribeInstanceHealthBadRequest(c)
-}
-
-func (s *LocalServerSuite) TestDescribeInstanceHealthWithoutSpecifyingInstances(c *C) {
- srv := s.srv.srv
- instId := srv.NewInstance()
- defer srv.RemoveInstance(instId)
- srv.NewLoadBalancer("testlb")
- defer srv.RemoveLoadBalancer("testlb")
- srv.RegisterInstance(instId, "testlb")
- resp, err := s.clientTests.elb.DescribeInstanceHealth("testlb")
- c.Assert(err, IsNil)
- c.Assert(len(resp.InstanceStates) > 0, Equals, true)
- c.Assert(resp.InstanceStates[0].Description, Equals, "Instance is in pending state.")
- c.Assert(resp.InstanceStates[0].InstanceId, Equals, instId)
- c.Assert(resp.InstanceStates[0].State, Equals, "OutOfService")
- c.Assert(resp.InstanceStates[0].ReasonCode, Equals, "Instance")
-}
-
-func (s *LocalServerSuite) TestDescribeInstanceHealthChangingIt(c *C) {
- srv := s.srv.srv
- instId := srv.NewInstance()
- defer srv.RemoveInstance(instId)
- srv.NewLoadBalancer("somelb")
- defer srv.RemoveLoadBalancer("somelb")
- srv.RegisterInstance(instId, "somelb")
- state := elb.InstanceState{
- Description: "Instance has failed at least the UnhealthyThreshold number of health checks consecutively",
- InstanceId: instId,
- State: "OutOfService",
- ReasonCode: "Instance",
- }
- srv.ChangeInstanceState("somelb", state)
- resp, err := s.clientTests.elb.DescribeInstanceHealth("somelb")
- c.Assert(err, IsNil)
- c.Assert(len(resp.InstanceStates) > 0, Equals, true)
- c.Assert(resp.InstanceStates[0].Description, Equals, "Instance has failed at least the UnhealthyThreshold number of health checks consecutively")
- c.Assert(resp.InstanceStates[0].InstanceId, Equals, instId)
- c.Assert(resp.InstanceStates[0].State, Equals, "OutOfService")
- c.Assert(resp.InstanceStates[0].ReasonCode, Equals, "Instance")
-}
-
-func (s *LocalServerSuite) TestConfigureHealthCheck(c *C) {
- s.clientTests.TestConfigureHealthCheck(c)
-}
-
-func (s *LocalServerSuite) TestConfigureHealthCheckBadRequest(c *C) {
- s.clientTests.TestConfigureHealthCheckBadRequest(c)
-}
diff --git a/vendor/github.com/goamz/goamz/elb/elbtest/server.go b/vendor/github.com/goamz/goamz/elb/elbtest/server.go
deleted file mode 100644
index 9b8f79d4e..000000000
--- a/vendor/github.com/goamz/goamz/elb/elbtest/server.go
+++ /dev/null
@@ -1,551 +0,0 @@
-// Package elbtest implements a fake ELB provider with the capability of
-// inducing errors on any given operation, and retrospectively determining what
-// operations have been carried out.
-package elbtest
-
-import (
- "encoding/xml"
- "fmt"
- "github.com/goamz/goamz/elb"
- "net"
- "net/http"
- "net/url"
- "regexp"
- "strconv"
- "strings"
- "sync"
-)
-
-// Server implements an ELB simulator for use in testing.
-type Server struct {
- url string
- listener net.Listener
- mutex sync.Mutex
- reqId int
- lbs map[string]*elb.LoadBalancerDescription
- lbsReqs map[string]url.Values
- instances []string
- instanceStates map[string][]*elb.InstanceState
- instCount int
-}
-
-// Starts and returns a new server
-func NewServer() (*Server, error) {
- l, err := net.Listen("tcp", "localhost:0")
- if err != nil {
- return nil, fmt.Errorf("cannot listen on localhost: %v", err)
- }
- srv := &Server{
- listener: l,
- url: "http://" + l.Addr().String(),
- lbs: make(map[string]*elb.LoadBalancerDescription),
- instanceStates: make(map[string][]*elb.InstanceState),
- }
- go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
- srv.serveHTTP(w, req)
- }))
- return srv, nil
-}
-
-// Quit closes down the server.
-func (srv *Server) Quit() {
- srv.listener.Close()
-}
-
-// URL returns the URL of the server.
-func (srv *Server) URL() string {
- return srv.url
-}
-
-type xmlErrors struct {
- XMLName string `xml:"ErrorResponse"`
- Error elb.Error
-}
-
-func (srv *Server) error(w http.ResponseWriter, err *elb.Error) {
- w.WriteHeader(err.StatusCode)
- xmlErr := xmlErrors{Error: *err}
- if e := xml.NewEncoder(w).Encode(xmlErr); e != nil {
- panic(e)
- }
-}
-
-func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
- req.ParseForm()
- srv.mutex.Lock()
- defer srv.mutex.Unlock()
- f := actions[req.Form.Get("Action")]
- if f == nil {
- srv.error(w, &elb.Error{
- StatusCode: 400,
- Code: "InvalidParameterValue",
- Message: "Unrecognized Action",
- })
- }
- reqId := fmt.Sprintf("req%0X", srv.reqId)
- srv.reqId++
- if resp, err := f(srv, w, req, reqId); err == nil {
- if err := xml.NewEncoder(w).Encode(resp); err != nil {
- panic(err)
- }
- } else {
- switch err.(type) {
- case *elb.Error:
- srv.error(w, err.(*elb.Error))
- default:
- panic(err)
- }
- }
-}
-
-func (srv *Server) createLoadBalancer(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- composition := map[string]string{
- "AvailabilityZones.member.1": "Subnets.member.1",
- }
- if err := srv.validateComposition(req, composition); err != nil {
- return nil, err
- }
- required := []string{
- "Listeners.member.1.InstancePort",
- "Listeners.member.1.InstanceProtocol",
- "Listeners.member.1.Protocol",
- "Listeners.member.1.LoadBalancerPort",
- "LoadBalancerName",
- }
- if err := srv.validate(req, required); err != nil {
- return nil, err
- }
- path := req.FormValue("Path")
- if path == "" {
- path = "/"
- }
- lbName := req.FormValue("LoadBalancerName")
- srv.lbs[lbName] = srv.makeLoadBalancerDescription(req.Form)
- srv.lbs[lbName].DNSName = fmt.Sprintf("%s-some-aws-stuff.us-east-1.elb.amazonaws.com", lbName)
- return elb.CreateLoadBalancerResp{
- DNSName: srv.lbs[lbName].DNSName,
- }, nil
-}
-
-func (srv *Server) deleteLoadBalancer(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"LoadBalancerName"}); err != nil {
- return nil, err
- }
- srv.RemoveLoadBalancer(req.FormValue("LoadBalancerName"))
- return elb.SimpleResp{RequestId: reqId}, nil
-}
-
-func (srv *Server) registerInstancesWithLoadBalancer(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- required := []string{"LoadBalancerName", "Instances.member.1.InstanceId"}
- if err := srv.validate(req, required); err != nil {
- return nil, err
- }
- lbName := req.FormValue("LoadBalancerName")
- if err := srv.lbExists(lbName); err != nil {
- return nil, err
- }
- instIds := []string{}
- instances := []elb.Instance{}
- i := 1
- instId := req.FormValue(fmt.Sprintf("Instances.member.%d.InstanceId", i))
- for instId != "" {
- if err := srv.instanceExists(instId); err != nil {
- return nil, err
- }
- instIds = append(instIds, instId)
- instances = append(instances, elb.Instance{InstanceId: instId})
- i++
- instId = req.FormValue(fmt.Sprintf("Instances.member.%d.InstanceId", i))
- }
- srv.instanceStates[lbName] = append(srv.instanceStates[lbName], srv.makeInstanceState(instId))
- srv.lbs[lbName].Instances = append(srv.lbs[lbName].Instances, instances...)
- return elb.RegisterInstancesResp{InstanceIds: instIds}, nil
-}
-
-func (srv *Server) deregisterInstancesFromLoadBalancer(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- required := []string{"LoadBalancerName"}
- if err := srv.validate(req, required); err != nil {
- return nil, err
- }
- lbName := req.FormValue("LoadBalancerName")
- if err := srv.lbExists(lbName); err != nil {
- return nil, err
- }
- i := 1
- lb := srv.lbs[lbName]
- instId := req.FormValue(fmt.Sprintf("Instances.member.%d.InstanceId", i))
- for instId != "" {
- if err := srv.instanceExists(instId); err != nil {
- return nil, err
- }
- i++
- removeInstanceFromLB(lb, instId)
- instId = req.FormValue(fmt.Sprintf("Instances.member.%d.InstanceId", i))
- }
- srv.lbs[lbName] = lb
- srv.removeInstanceStatesFromLoadBalancer(lbName, instId)
- return elb.SimpleResp{RequestId: reqId}, nil
-}
-
-func (srv *Server) describeLoadBalancers(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- i := 1
- lbName := req.FormValue(fmt.Sprintf("LoadBalancerNames.member.%d", i))
- for lbName != "" {
- key := fmt.Sprintf("LoadBalancerNames.member.%d", i)
- if req.FormValue(key) != "" {
- if err := srv.lbExists(req.FormValue(key)); err != nil {
- return nil, err
- }
- }
- i++
- lbName = req.FormValue(fmt.Sprintf("LoadBalancerNames.member.%d", i))
- }
- lbsDesc := make([]elb.LoadBalancerDescription, len(srv.lbs))
- i = 0
- for _, lb := range srv.lbs {
- lbsDesc[i] = *lb
- i++
- }
- resp := elb.DescribeLoadBalancerResp{
- LoadBalancerDescriptions: lbsDesc,
- }
- return resp, nil
-}
-
-// getParameters returns the value all parameters from a request that matches a
-// prefix.
-//
-// For example, for the prefix "Subnets.member.", it will return a slice
-// containing the value of keys "Subnets.member.1", "Subnets.member.2" ...
-// "Subnets.member.N". The prefix must include the trailing dot.
-func (srv *Server) getParameters(prefix string, values url.Values) []string {
- i, key := 1, ""
- var k = func(n int) string {
- return fmt.Sprintf(prefix+"%d", n)
- }
- var result []string
- for i, key = 2, k(i); values.Get(key) != ""; i, key = i+1, k(i) {
- result = append(result, values.Get(key))
- }
- return result
-}
-
-func (srv *Server) makeInstanceState(id string) *elb.InstanceState {
- return &elb.InstanceState{
- Description: "Instance is in pending state.",
- InstanceId: id,
- State: "OutOfService",
- ReasonCode: "Instance",
- }
-}
-
-func removeInstanceFromLB(lb *elb.LoadBalancerDescription, id string) {
- index := -1
- for i, instance := range lb.Instances {
- if instance.InstanceId == id {
- index = i
- break
- }
- }
- if index > -1 {
- copy(lb.Instances[index:], lb.Instances[index+1:])
- lb.Instances = lb.Instances[:len(lb.Instances)-1]
- }
-}
-
-func (srv *Server) removeInstanceStatesFromLoadBalancer(lb, id string) {
- for i, state := range srv.instanceStates[lb] {
- if state.InstanceId == id {
- a := srv.instanceStates[lb]
- a[i], a = a[len(a)-1], a[:len(a)-1]
- srv.instanceStates[lb] = a
- return
- }
- }
-}
-
-func (srv *Server) makeLoadBalancerDescription(value url.Values) *elb.LoadBalancerDescription {
- lds := []elb.ListenerDescription{}
- i := 1
- protocol := value.Get(fmt.Sprintf("Listeners.member.%d.Protocol", i))
- for protocol != "" {
- key := fmt.Sprintf("Listeners.member.%d.", i)
- lInstPort, _ := strconv.Atoi(value.Get(key + "InstancePort"))
- lLBPort, _ := strconv.Atoi(value.Get(key + "LoadBalancerPort"))
- lDescription := elb.ListenerDescription{
- Listener: elb.Listener{
- Protocol: strings.ToUpper(protocol),
- InstanceProtocol: strings.ToUpper(value.Get(key + "InstanceProtocol")),
- LoadBalancerPort: lLBPort,
- InstancePort: lInstPort,
- },
- }
- i++
- protocol = value.Get(fmt.Sprintf("Listeners.member.%d.Protocol", i))
- lds = append(lds, lDescription)
- }
- sourceSecGroup := srv.makeSourceSecGroup(value)
- lbDesc := elb.LoadBalancerDescription{
- AvailabilityZones: srv.getParameters("AvailabilityZones.member.", value),
- Subnets: srv.getParameters("Subnets.member.", value),
- SecurityGroups: srv.getParameters("SecurityGroups.member.", value),
- HealthCheck: srv.makeHealthCheck(value),
- ListenerDescriptions: lds,
- Scheme: value.Get("Scheme"),
- SourceSecurityGroup: sourceSecGroup,
- LoadBalancerName: value.Get("LoadBalancerName"),
- }
- if lbDesc.Scheme == "" {
- lbDesc.Scheme = "internet-facing"
- }
- return &lbDesc
-}
-
-func (srv *Server) makeHealthCheck(value url.Values) elb.HealthCheck {
- ht := 10
- timeout := 5
- ut := 2
- interval := 30
- target := "TCP:80"
- if v := value.Get("HealthCheck.HealthyThreshold"); v != "" {
- ht, _ = strconv.Atoi(v)
- }
- if v := value.Get("HealthCheck.Timeout"); v != "" {
- timeout, _ = strconv.Atoi(v)
- }
- if v := value.Get("HealthCheck.UnhealthyThreshold"); v != "" {
- ut, _ = strconv.Atoi(v)
- }
- if v := value.Get("HealthCheck.Interval"); v != "" {
- interval, _ = strconv.Atoi(v)
- }
- if v := value.Get("HealthCheck.Target"); v != "" {
- target = v
- }
- return elb.HealthCheck{
- HealthyThreshold: ht,
- Interval: interval,
- Target: target,
- Timeout: timeout,
- UnhealthyThreshold: ut,
- }
-}
-
-func (srv *Server) makeSourceSecGroup(value url.Values) elb.SourceSecurityGroup {
- name := "amazon-elb-sg"
- alias := "amazon-elb"
- if v := value.Get("SourceSecurityGroup.GroupName"); v != "" {
- name = v
- }
- if v := value.Get("SourceSecurityGroup.OwnerAlias"); v != "" {
- alias = v
- }
- return elb.SourceSecurityGroup{
- GroupName: name,
- OwnerAlias: alias,
- }
-}
-
-func (srv *Server) describeInstanceHealth(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.lbExists(req.FormValue("LoadBalancerName")); err != nil {
- return nil, err
- }
- resp := elb.DescribeInstanceHealthResp{
- InstanceStates: []elb.InstanceState{},
- }
- for _, state := range srv.instanceStates[req.FormValue("LoadBalancerName")] {
- resp.InstanceStates = append(resp.InstanceStates, *state)
- }
- i := 1
- instanceId := req.FormValue("Instances.member.1.InstanceId")
- for instanceId != "" {
- if err := srv.instanceExists(instanceId); err != nil {
- return nil, err
- }
- is := elb.InstanceState{
- Description: "Instance is in pending state.",
- InstanceId: instanceId,
- State: "OutOfService",
- ReasonCode: "Instance",
- }
- resp.InstanceStates = append(resp.InstanceStates, is)
- i++
- instanceId = req.FormValue(fmt.Sprintf("Instances.member.%d.InstanceId", i))
- }
- return resp, nil
-}
-
-func (srv *Server) configureHealthCheck(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- required := []string{
- "LoadBalancerName",
- "HealthCheck.HealthyThreshold",
- "HealthCheck.Interval",
- "HealthCheck.Target",
- "HealthCheck.Timeout",
- "HealthCheck.UnhealthyThreshold",
- }
- if err := srv.validate(req, required); err != nil {
- return nil, err
- }
- target := req.FormValue("HealthCheck.Target")
- r, err := regexp.Compile(`[\w]+:[\d]+\/+`)
- if err != nil {
- panic(err)
- }
- if m := r.FindStringSubmatch(target); m == nil {
- return nil, &elb.Error{
- StatusCode: 400,
- Code: "ValidationError",
- Message: "HealthCheck HTTP Target must specify a port followed by a path that begins with a slash. e.g. HTTP:80/ping/this/path",
- }
- }
- ht, _ := strconv.Atoi(req.FormValue("HealthCheck.HealthyThreshold"))
- interval, _ := strconv.Atoi(req.FormValue("HealthCheck.Interval"))
- timeout, _ := strconv.Atoi(req.FormValue("HealthCheck.Timeout"))
- ut, _ := strconv.Atoi(req.FormValue("HealthCheck.UnhealthyThreshold"))
- return elb.HealthCheckResp{
- HealthCheck: &elb.HealthCheck{
- HealthyThreshold: ht,
- Interval: interval,
- Target: target,
- Timeout: timeout,
- UnhealthyThreshold: ut,
- },
- }, nil
-}
-
-func (srv *Server) instanceExists(id string) error {
- for _, instId := range srv.instances {
- if instId == id {
- return nil
- }
- }
- return &elb.Error{
- StatusCode: 400,
- Code: "InvalidInstance",
- Message: fmt.Sprintf("InvalidInstance found in [%s]. Invalid id: \"%s\"", id, id),
- }
-}
-
-func (srv *Server) lbExists(name string) error {
- if _, ok := srv.lbs[name]; !ok {
- return &elb.Error{
- StatusCode: 400,
- Code: "LoadBalancerNotFound",
- Message: fmt.Sprintf("There is no ACTIVE Load Balancer named '%s'", name),
- }
- }
- return nil
-}
-
-func (srv *Server) validate(req *http.Request, required []string) error {
- for _, field := range required {
- if req.FormValue(field) == "" {
- return &elb.Error{
- StatusCode: 400,
- Code: "ValidationError",
- Message: fmt.Sprintf("%s is required.", field),
- }
- }
- }
- return nil
-}
-
-// Validates the composition of the fields.
-//
-// Some fields cannot be together in the same request, such as AvailabilityZones and Subnets.
-// A sample map with the above requirement would be
-// c := map[string]string{
-// "AvailabilityZones.member.1": "Subnets.member.1",
-// }
-//
-// The server also requires that at least one of those fields are specified.
-func (srv *Server) validateComposition(req *http.Request, composition map[string]string) error {
- for k, v := range composition {
- if req.FormValue(k) != "" && req.FormValue(v) != "" {
- return &elb.Error{
- StatusCode: 400,
- Code: "ValidationError",
- Message: fmt.Sprintf("Only one of %s or %s may be specified", k, v),
- }
- }
- if req.FormValue(k) == "" && req.FormValue(v) == "" {
- return &elb.Error{
- StatusCode: 400,
- Code: "ValidationError",
- Message: fmt.Sprintf("Either %s or %s must be specified", k, v),
- }
- }
- }
- return nil
-}
-
-// Creates a fake instance in the server
-func (srv *Server) NewInstance() string {
- srv.instCount++
- instId := fmt.Sprintf("i-%d", srv.instCount)
- srv.instances = append(srv.instances, instId)
- return instId
-}
-
-// Removes a fake instance from the server
-//
-// If no instance is found it does nothing
-func (srv *Server) RemoveInstance(instId string) {
- for i, id := range srv.instances {
- if id == instId {
- srv.instances[i], srv.instances = srv.instances[len(srv.instances)-1], srv.instances[:len(srv.instances)-1]
- }
- }
-}
-
-// Creates a fake load balancer in the fake server
-func (srv *Server) NewLoadBalancer(name string) {
- srv.lbs[name] = &elb.LoadBalancerDescription{
- LoadBalancerName: name,
- DNSName: fmt.Sprintf("%s-some-aws-stuff.sa-east-1.amazonaws.com", name),
- }
-}
-
-// Removes a fake load balancer from the fake server
-func (srv *Server) RemoveLoadBalancer(name string) {
- delete(srv.lbs, name)
-}
-
-// Register a fake instance with a fake Load Balancer
-//
-// If the Load Balancer does not exists it does nothing
-func (srv *Server) RegisterInstance(instId, lbName string) {
- lb, ok := srv.lbs[lbName]
- if !ok {
- fmt.Println("lb not found :/")
- return
- }
- lb.Instances = append(lb.Instances, elb.Instance{InstanceId: instId})
- srv.instanceStates[lbName] = append(srv.instanceStates[lbName], srv.makeInstanceState(instId))
-}
-
-func (srv *Server) DeregisterInstance(instId, lbName string) {
- removeInstanceFromLB(srv.lbs[lbName], instId)
- srv.removeInstanceStatesFromLoadBalancer(lbName, instId)
-}
-
-func (srv *Server) ChangeInstanceState(lb string, state elb.InstanceState) {
- states := srv.instanceStates[lb]
- for i, s := range states {
- if s.InstanceId == state.InstanceId {
- srv.instanceStates[lb][i] = &state
- return
- }
- }
-}
-
-var actions = map[string]func(*Server, http.ResponseWriter, *http.Request, string) (interface{}, error){
- "CreateLoadBalancer": (*Server).createLoadBalancer,
- "DeleteLoadBalancer": (*Server).deleteLoadBalancer,
- "RegisterInstancesWithLoadBalancer": (*Server).registerInstancesWithLoadBalancer,
- "DeregisterInstancesFromLoadBalancer": (*Server).deregisterInstancesFromLoadBalancer,
- "DescribeLoadBalancers": (*Server).describeLoadBalancers,
- "DescribeInstanceHealth": (*Server).describeInstanceHealth,
- "ConfigureHealthCheck": (*Server).configureHealthCheck,
-}
diff --git a/vendor/github.com/goamz/goamz/elb/export_test.go b/vendor/github.com/goamz/goamz/elb/export_test.go
deleted file mode 100644
index 49a2d50fe..000000000
--- a/vendor/github.com/goamz/goamz/elb/export_test.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package elb
-
-import (
- "github.com/goamz/goamz/aws"
-)
-
-func Sign(auth aws.Auth, method, path string, params map[string]string, host string) {
- sign(auth, method, path, params, host)
-}
diff --git a/vendor/github.com/goamz/goamz/elb/response_test.go b/vendor/github.com/goamz/goamz/elb/response_test.go
deleted file mode 100644
index 637d1e140..000000000
--- a/vendor/github.com/goamz/goamz/elb/response_test.go
+++ /dev/null
@@ -1,234 +0,0 @@
-package elb_test
-
-var CreateLoadBalancer = `
-<CreateLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <CreateLoadBalancerResult>
- <DNSName>testlb-339187009.us-east-1.elb.amazonaws.com</DNSName>
- </CreateLoadBalancerResult>
- <ResponseMetadata>
- <RequestId>0c3a8e29-490e-11e2-8647-e14ad5151f1f</RequestId>
- </ResponseMetadata>
-</CreateLoadBalancerResponse>
-`
-
-var CreateLoadBalancerBadRequest = `
-<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <Error>
- <Type>Sender</Type>
- <Code>ValidationError</Code>
- <Message>Only one of SubnetIds or AvailabilityZones may be specified</Message>
- </Error>
- <RequestId>159253fc-49dc-11e2-a47d-cde463c91a3c</RequestId>
-</ErrorResponse>
-`
-
-var DeleteLoadBalancer = `
-<DeleteLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <DeleteLoadBalancerResult/>
- <ResponseMetadata>
- <RequestId>8d7223db-49d7-11e2-bba9-35ba56032fe1</RequestId>
- </ResponseMetadata>
-</DeleteLoadBalancerResponse>
-`
-
-var RegisterInstancesWithLoadBalancer = `
-<RegisterInstancesWithLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <RegisterInstancesWithLoadBalancerResult>
- <Instances>
- <member>
- <InstanceId>i-b44db8ca</InstanceId>
- </member>
- <member>
- <InstanceId>i-461ecf38</InstanceId>
- </member>
- </Instances>
- </RegisterInstancesWithLoadBalancerResult>
- <ResponseMetadata>
- <RequestId>0fc82478-49e1-11e2-b947-8768f15220aa</RequestId>
- </ResponseMetadata>
-</RegisterInstancesWithLoadBalancerResponse>
-`
-
-var RegisterInstancesWithLoadBalancerBadRequest = `
-<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <Error>
- <Type>Sender</Type>
- <Code>LoadBalancerNotFound</Code>
- <Message>There is no ACTIVE Load Balancer named 'absentLB'</Message>
- </Error>
- <RequestId>19a0bb97-49f7-11e2-90b4-6bb9ec8331bf</RequestId>
-</ErrorResponse>
-`
-
-var DeregisterInstancesFromLoadBalancer = `
-<DeregisterInstancesFromLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <DeregisterInstancesFromLoadBalancerResult>
- <Instances/>
- </DeregisterInstancesFromLoadBalancerResult>
- <ResponseMetadata>
- <RequestId>d6490837-49fd-11e2-bba9-35ba56032fe1</RequestId>
- </ResponseMetadata>
-</DeregisterInstancesFromLoadBalancerResponse>
-`
-
-var DeregisterInstancesFromLoadBalancerBadRequest = `
-<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <Error>
- <Type>Sender</Type>
- <Code>LoadBalancerNotFound</Code>
- <Message>There is no ACTIVE Load Balancer named 'absentlb'</Message>
- </Error>
- <RequestId>498e2b4a-4aa1-11e2-8839-d19a879f2eec</RequestId>
-</ErrorResponse>
-`
-
-var DescribeLoadBalancers = `
-<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <DescribeLoadBalancersResult>
- <LoadBalancerDescriptions>
- <member>
- <SecurityGroups/>
- <CreatedTime>2012-12-27T11:51:52.970Z</CreatedTime>
- <LoadBalancerName>testlb</LoadBalancerName>
- <HealthCheck>
- <Interval>30</Interval>
- <Target>TCP:80</Target>
- <HealthyThreshold>10</HealthyThreshold>
- <Timeout>5</Timeout>
- <UnhealthyThreshold>2</UnhealthyThreshold>
- </HealthCheck>
- <ListenerDescriptions>
- <member>
- <PolicyNames/>
- <Listener>
- <Protocol>HTTP</Protocol>
- <LoadBalancerPort>80</LoadBalancerPort>
- <InstanceProtocol>HTTP</InstanceProtocol>
- <InstancePort>80</InstancePort>
- </Listener>
- </member>
- </ListenerDescriptions>
- <Instances/>
- <Policies>
- <AppCookieStickinessPolicies/>
- <OtherPolicies/>
- <LBCookieStickinessPolicies/>
- </Policies>
- <AvailabilityZones>
- <member>us-east-1a</member>
- </AvailabilityZones>
- <CanonicalHostedZoneName>testlb-2087227216.us-east-1.elb.amazonaws.com</CanonicalHostedZoneName>
- <CanonicalHostedZoneNameID>Z3DZXE0Q79N41H</CanonicalHostedZoneNameID>
- <Scheme>internet-facing</Scheme>
- <SourceSecurityGroup>
- <OwnerAlias>amazon-elb</OwnerAlias>
- <GroupName>amazon-elb-sg</GroupName>
- </SourceSecurityGroup>
- <DNSName>testlb-2087227216.us-east-1.elb.amazonaws.com</DNSName>
- <BackendServerDescriptions/>
- <Subnets/>
- </member>
- </LoadBalancerDescriptions>
- </DescribeLoadBalancersResult>
- <ResponseMetadata>
- <RequestId>e2e81963-5055-11e2-99c7-434205631d9b</RequestId>
- </ResponseMetadata>
-</DescribeLoadBalancersResponse>
-`
-
-var DescribeLoadBalancersBadRequest = `
-<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <Error>
- <Type>Sender</Type>
- <Code>LoadBalancerNotFound</Code>
- <Message>Cannot find Load Balancer absentlb</Message>
- </Error>
- <RequestId>f14f348e-50f7-11e2-9831-f770dd71c209</RequestId>
-</ErrorResponse>
-`
-
-var DescribeInstanceHealth = `
-<DescribeInstanceHealthResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <DescribeInstanceHealthResult>
- <InstanceStates>
- <member>
- <Description>Instance registration is still in progress.</Description>
- <InstanceId>i-b44db8ca</InstanceId>
- <State>OutOfService</State>
- <ReasonCode>ELB</ReasonCode>
- </member>
- </InstanceStates>
- </DescribeInstanceHealthResult>
- <ResponseMetadata>
- <RequestId>da0d0f9e-5669-11e2-9f81-319facce7423</RequestId>
- </ResponseMetadata>
-</DescribeInstanceHealthResponse>
-`
-
-var DescribeInstanceHealthBadRequest = `
-<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <Error>
- <Type>Sender</Type>
- <Code>InvalidInstance</Code>
- <Message>Could not find EC2 instance i-foooo.</Message>
- </Error>
- <RequestId>352e00d6-566c-11e2-a46d-313272bbb522</RequestId>
-</ErrorResponse>
-`
-
-var ConfigureHealthCheck = `
-<ConfigureHealthCheckResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <ConfigureHealthCheckResult>
- <HealthCheck>
- <Interval>30</Interval>
- <Target>HTTP:80/</Target>
- <HealthyThreshold>10</HealthyThreshold>
- <Timeout>5</Timeout>
- <UnhealthyThreshold>2</UnhealthyThreshold>
- </HealthCheck>
- </ConfigureHealthCheckResult>
- <ResponseMetadata>
- <RequestId>a882d12c-5694-11e2-b647-594652c9487c</RequestId>
- </ResponseMetadata>
-</ConfigureHealthCheckResponse>
-`
-
-var ConfigureHealthCheckBadRequest = `
-<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <Error>
- <Type>Sender</Type>
- <Code>LoadBalancerNotFound</Code>
- <Message>There is no ACTIVE Load Balancer named 'foolb'</Message>
- </Error>
- <RequestId>2d9fe4a5-5697-11e2-9415-e325c02171d7</RequestId>
-</ErrorResponse>
-`
-
-var AddTagsSuccessResponse = `
-<AddTagsResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06- 01/">
- <AddTagsResult/>
- <ResponseMetadata>
- <RequestId>360e81f7-1100-11e4-b6ed-0f30SOME-SAUCY-EXAMPLE</RequestId>
- </ResponseMetadata>
-</AddTagsResponse>
-`
-
-var TagsBadRequest = `
-<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <Error>
- <Type>Sender</Type>
- <Code>InvalidParameterValue</Code>
- <Message>An invalid or out-of-range value was supplied for the input parameter.</Message>
- </Error>
- <RequestId>terrible-request-id</RequestId>
-</ErrorResponse>
-`
-
-var RemoveTagsSuccessResponse = `
-<RemoveTagsResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
- <RemoveTagsResult/>
- <ResponseMetadata>
- <RequestId>83c88b9d-12b7-11e3-8b82-87b12DIFFEXAMPLE</RequestId>
- </ResponseMetadata>
-</RemoveTagsResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/elb/sign.go b/vendor/github.com/goamz/goamz/elb/sign.go
deleted file mode 100644
index b7da14772..000000000
--- a/vendor/github.com/goamz/goamz/elb/sign.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package elb
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "github.com/goamz/goamz/aws"
- "sort"
- "strings"
-)
-
-var b64 = base64.StdEncoding
-
-func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
- params["AWSAccessKeyId"] = auth.AccessKey
- params["SignatureVersion"] = "2"
- params["SignatureMethod"] = "HmacSHA256"
-
- var keys, sarray []string
- for k := range params {
- keys = append(keys, k)
- }
- sort.Strings(keys)
- for _, k := range keys {
- sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(params[k]))
- }
- joined := strings.Join(sarray, "&")
- payload := method + "\n" + host + "\n" + path + "\n" + joined
- hash := hmac.New(sha256.New, []byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- params["Signature"] = string(signature)
-}
diff --git a/vendor/github.com/goamz/goamz/elb/sign_test.go b/vendor/github.com/goamz/goamz/elb/sign_test.go
deleted file mode 100644
index 0dda1667e..000000000
--- a/vendor/github.com/goamz/goamz/elb/sign_test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package elb_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/elb"
- . "gopkg.in/check.v1"
-)
-
-var testAuth = aws.Auth{AccessKey: "user", SecretKey: "secret"}
-
-func (s *S) TestBasicSignature(c *C) {
- params := map[string]string{}
- elb.Sign(testAuth, "GET", "/path", params, "localhost")
- c.Assert(params["SignatureVersion"], Equals, "2")
- c.Assert(params["SignatureMethod"], Equals, "HmacSHA256")
- expected := "6lSe5QyXum0jMVc7cOUz32/52ZnL7N5RyKRk/09yiK4="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestParamSignature(c *C) {
- params := map[string]string{
- "param1": "value1",
- "param2": "value2",
- "param3": "value3",
- }
- elb.Sign(testAuth, "GET", "/path", params, "localhost")
- expected := "XWOR4+0lmK8bD8CGDGZ4kfuSPbb2JibLJiCl/OPu1oU="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestManyParams(c *C) {
- params := map[string]string{
- "param1": "value10",
- "param2": "value2",
- "param3": "value3",
- "param4": "value4",
- "param5": "value5",
- "param6": "value6",
- "param7": "value7",
- "param8": "value8",
- "param9": "value9",
- "param10": "value1",
- }
- elb.Sign(testAuth, "GET", "/path", params, "localhost")
- expected := "di0sjxIvezUgQ1SIL6i+C/H8lL+U0CQ9frLIak8jkVg="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestEscaping(c *C) {
- params := map[string]string{"Nonce": "+ +"}
- elb.Sign(testAuth, "GET", "/path", params, "localhost")
- c.Assert(params["Nonce"], Equals, "+ +")
- expected := "bqffDELReIqwjg/W0DnsnVUmfLK4wXVLO4/LuG+1VFA="
- c.Assert(params["Signature"], Equals, expected)
-}
-
-func (s *S) TestSignatureExample1(c *C) {
- params := map[string]string{
- "Timestamp": "2009-02-01T12:53:20+00:00",
- "Version": "2007-11-07",
- "Action": "ListDomains",
- }
- elb.Sign(aws.Auth{AccessKey: "access", SecretKey: "secret"}, "GET", "/", params, "sdb.amazonaws.com")
- expected := "okj96/5ucWBSc1uR2zXVfm6mDHtgfNv657rRtt/aunQ="
- c.Assert(params["Signature"], Equals, expected)
-}
diff --git a/vendor/github.com/goamz/goamz/elb/suite_test.go b/vendor/github.com/goamz/goamz/elb/suite_test.go
deleted file mode 100644
index fe4c81d47..000000000
--- a/vendor/github.com/goamz/goamz/elb/suite_test.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package elb_test
-
-import (
- "fmt"
- "net/http"
- "net/url"
- "os"
- "testing"
- "time"
-
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-type HTTPSuite struct{}
-
-var testServer = NewTestHTTPServer("http://localhost:4444", 5*time.Second)
-
-func (s *HTTPSuite) SetUpSuite(c *C) {
- testServer.Start()
-}
-
-func (s *HTTPSuite) TearDownTest(c *C) {
- testServer.FlushRequests()
-}
-
-type TestHTTPServer struct {
- URL string
- Timeout time.Duration
- started bool
- request chan *http.Request
- response chan *testResponse
- pending chan bool
-}
-
-type testResponse struct {
- Status int
- Headers map[string]string
- Body string
-}
-
-func NewTestHTTPServer(url string, timeout time.Duration) *TestHTTPServer {
- return &TestHTTPServer{URL: url, Timeout: timeout}
-}
-
-func (s *TestHTTPServer) Start() {
- if s.started {
- return
- }
- s.started = true
-
- s.request = make(chan *http.Request, 64)
- s.response = make(chan *testResponse, 64)
- s.pending = make(chan bool, 64)
-
- url, _ := url.Parse(s.URL)
- go http.ListenAndServe(url.Host, s)
-
- s.PrepareResponse(202, nil, "Nothing.")
- for {
- // Wait for it to be up.
- resp, err := http.Get(s.URL)
- if err == nil && resp.StatusCode == 202 {
- break
- }
- time.Sleep(1e8)
- }
- s.WaitRequest() // Consume dummy request.
-}
-
-// FlushRequests discards requests which were not yet consumed by WaitRequest.
-func (s *TestHTTPServer) FlushRequests() {
- for {
- select {
- case <-s.request:
- default:
- return
- }
- }
-}
-
-func (s *TestHTTPServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
- s.request <- req
- var resp *testResponse
- select {
- case resp = <-s.response:
- case <-time.After(s.Timeout):
- fmt.Fprintf(os.Stderr, "ERROR: Timeout waiting for test to provide response\n")
- resp = &testResponse{500, nil, ""}
- }
- if resp.Headers != nil {
- h := w.Header()
- for k, v := range resp.Headers {
- h.Set(k, v)
- }
- }
- if resp.Status != 0 {
- w.WriteHeader(resp.Status)
- }
- w.Write([]byte(resp.Body))
-}
-
-func (s *TestHTTPServer) WaitRequest() *http.Request {
- select {
- case req := <-s.request:
- req.ParseForm()
- return req
- case <-time.After(s.Timeout):
- panic("Timeout waiting for goamz request")
- }
- panic("unreached")
-}
-
-func (s *TestHTTPServer) PrepareResponse(status int, headers map[string]string, body string) {
- s.response <- &testResponse{status, headers, body}
-}
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/example_test.go b/vendor/github.com/goamz/goamz/exp/mturk/example_test.go
deleted file mode 100644
index 806ce95fd..000000000
--- a/vendor/github.com/goamz/goamz/exp/mturk/example_test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package mturk_test
-
-import (
- "fmt"
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/exp/mturk"
-)
-
-var turk *mturk.MTurk
-
-func ExampleNew() {
- // These are your AWS tokens. Note that Turk do not support IAM.
- // So you'll have to use your main profile's tokens.
- var auth = aws.Auth{AccessKey: "<ACCESS_KEY>", SecretKey: "<SECRET_KEY>"}
- turk = mturk.New(auth, true) // true to use sandbox mode
-}
-
-func Examplemturk_CreateHIT_withExternalQuestion() {
- question := mturk.ExternalQuestion{
- ExternalURL: "http://www.amazon.com",
- FrameHeight: 200,
- }
- reward := mturk.Price{
- Amount: "0.01",
- CurrencyCode: "USD",
- }
-
- hit, err := turk.CreateHIT("title", "description", question, reward, 30, 30, "key1,key2", 3, nil, "annotation")
-
- if err == nil {
- fmt.Println(hit)
- }
-}
-
-func Examplemturk_CreateHIT_withHTMLQuestion() {
- question := mturk.HTMLQuestion{
- HTMLContent: mturk.HTMLContent{`<![CDATA[
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
- <script type='text/javascript' src='https://s3.amazonaws.com/mturk-public/externalHIT_v1.js'></script>
- </head>
- <body>
- <form name='mturk_form' method='post' id='mturk_form' action='https://www.mturk.com/mturk/externalSubmit'>
- <input type='hidden' value='' name='assignmentId' id='assignmentId'/>
- <h1>What's up?</h1>
- <p><textarea name='comment' cols='80' rows='3'></textarea></p>
- <p><input type='submit' id='submitButton' value='Submit' /></p></form>
- <script language='Javascript'>turkSetAssignmentID();</script>
- </body>
-</html>
-]]>`},
- FrameHeight: 200,
- }
- reward := mturk.Price{
- Amount: "0.01",
- CurrencyCode: "USD",
- }
-
- hit, err := turk.CreateHIT("title", "description", question, reward, 30, 30, "key1,key2", 3, nil, "")
-
- if err == nil {
- fmt.Println(hit)
- }
-}
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/export_test.go b/vendor/github.com/goamz/goamz/exp/mturk/export_test.go
deleted file mode 100644
index 736678a56..000000000
--- a/vendor/github.com/goamz/goamz/exp/mturk/export_test.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package mturk
-
-import (
- "github.com/goamz/goamz/aws"
-)
-
-func Sign(auth aws.Auth, service, method, timestamp string, params map[string]string) {
- sign(auth, service, method, timestamp, params)
-}
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/mturk.go b/vendor/github.com/goamz/goamz/exp/mturk/mturk.go
deleted file mode 100644
index fbbf700c2..000000000
--- a/vendor/github.com/goamz/goamz/exp/mturk/mturk.go
+++ /dev/null
@@ -1,480 +0,0 @@
-//
-// goamz - Go packages to interact with the Amazon Web Services.
-//
-// https://wiki.ubuntu.com/goamz
-//
-// Copyright (c) 2011 Canonical Ltd.
-//
-// Written by Graham Miller <graham.miller@gmail.com>
-
-// This package is in an experimental state, and does not currently
-// follow conventions and style of the rest of goamz or common
-// Go conventions. It must be polished before it's considered a
-// first-class package in goamz.
-package mturk
-
-import (
- "encoding/xml"
- "errors"
- "fmt"
- "github.com/goamz/goamz/aws"
- "net/http"
- //"net/http/httputil"
- "net/url"
- "strconv"
- "strings"
- "time"
-)
-
-type MTurk struct {
- aws.Auth
- URL *url.URL
-}
-
-func New(auth aws.Auth, sandbox bool) *MTurk {
- mt := &MTurk{Auth: auth}
- var err error
- if sandbox {
- mt.URL, err = url.Parse("https://mechanicalturk.sandbox.amazonaws.com/")
- } else {
- mt.URL, err = url.Parse("https://mechanicalturk.amazonaws.com/")
- }
- if err != nil {
- panic(err.Error())
- }
- return mt
-}
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-// Error encapsulates an error returned by MTurk.
-type Error struct {
- StatusCode int // HTTP status code (200, 403, ...)
- Code string // EC2 error code ("UnsupportedOperation", ...)
- Message string // The human-oriented error message
- RequestId string
-}
-
-func (err *Error) Error() string {
- return err.Message
-}
-
-// The request stanza included in several response types, for example
-// in a "CreateHITResponse". http://goo.gl/qGeKf
-type xmlRequest struct {
- RequestId string
- IsValid string
- Errors []Error `xml:"Errors>Error"`
-}
-
-/*
-A Price represents an amount of money in a given currency.
-
-Reference:
-http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_PriceDataStructureArticle.html
-*/
-type Price struct {
- // The amount of money, as a number. The amount is in the currency specified
- // by the CurrencyCode. For example, if CurrencyCode is USD, the amount will
- // be in United States dollars (e.g. 12.75 is $12.75 US).
- Amount string
-
- // A code that represents the country and units of the currency. Its value is
- // Type an ISO 4217 currency code, such as USD for United States dollars.
- //
- // Constraints: Currently only USD is supported.
- CurrencyCode string
-
- // A textual representation of the price, using symbols and formatting
- // appropriate for the currency. Symbols are represented using the Unicode
- // character set. You do not need to specify FormattedPrice in a request.
- // It is only provided by the service in responses, as a convenience to
- // your application.
- FormattedPrice string
-}
-
-/*
-Really just a country string.
-
-Reference:
-
-- http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_LocaleDataStructureArticle.html
-- http://www.iso.org/iso/country_codes/country_codes
-*/
-type Locale string
-
-/*
-A QualificationRequirement describes a Qualification a Worker must
-have before the Worker is allowed to accept a HIT. A requirement may optionally
-state that a Worker must have the Qualification to preview the HIT.
-
-Reference:
-
-http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_QualificationRequirementDataStructureArticle.html
-*/
-type QualificationRequirement struct {
- // The ID of the Qualification type for the requirement.
- // See http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_QualificationRequirementDataStructureArticle.html#ApiReference_QualificationType-IDs
- QualificationTypeId string
-
- // The kind of comparison to make against a Qualification's value.
- // Two values can be compared to see if one value is "LessThan",
- // "LessThanOrEqualTo", "GreaterThan", "GreaterThanOrEqualTo", "EqualTo", or
- // "NotEqualTo" the other. A Qualification requirement can also test if a
- // Qualification "Exists" in the user's profile, regardless of its value.
- Comparator string
-
- // The integer value to compare against the Qualification's value.
- IntegerValue int
-
- // The locale value to compare against the Qualification's value, if the
- // Qualification being compared is the locale Qualification.
- LocaleValue Locale
-
- // If true, the question data for the HIT will not be shown when a Worker
- // whose Qualifications do not meet this requirement tries to preview the HIT.
- // That is, a Worker's Qualifications must meet all of the requirements for
- // which RequiredToPreview is true in order to preview the HIT.
- //
- // If a Worker meets all of the requirements where RequiredToPreview is true
- // (or if there are no such requirements), but does not meet all of the
- // requirements for the HIT, the Worker will be allowed to preview the HIT's
- // question data, but will not be allowed to accept and complete the HIT.
- RequiredToPreview bool
-}
-
-// Data structure holding the contents of an "external"
-// question. http://goo.gl/NP8Aa
-type ExternalQuestion struct {
- XMLName xml.Name `xml:"http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd ExternalQuestion"`
- ExternalURL string
- FrameHeight int
-}
-
-// Holds the html content of the HTMLQuestion.
-type HTMLContent struct {
- Content string `xml:",innerxml"`
-}
-
-// Data structure holding the contents of an "html"
-// question. http://goo.gl/hQn5An
-type HTMLQuestion struct {
- XMLName xml.Name `xml:"http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2011-11-11/HTMLQuestion.xsd HTMLQuestion"`
- HTMLContent HTMLContent
-
- FrameHeight int
-}
-
-// The data structure representing a "human interface task" (HIT)
-// Currently only supports "external" questions, because Go
-// structs don't support union types. http://goo.gl/NP8Aa
-// This type is returned, for example, from SearchHITs
-// http://goo.gl/PskcX
-type HIT struct {
- Request xmlRequest
-
- HITId string
- HITTypeId string
- CreationTime string
- Title string
- Description string
- Keywords string
- HITStatus string
- Reward Price
- LifetimeInSeconds uint
- AssignmentDurationInSeconds uint
- MaxAssignments uint
- AutoApprovalDelayInSeconds uint
- QualificationRequirement QualificationRequirement
- Question interface{}
- RequesterAnnotation string
- NumberofSimilarHITs uint
- HITReviewStatus string
- NumberOfAssignmentsPending uint
- NumberOfAssignmentsAvailable uint
- NumberOfAssignmentsCompleted uint
-}
-
-// The main data structure returned by SearchHITs
-// http://goo.gl/PskcX
-type SearchHITsResult struct {
- NumResults uint
- PageNumber uint
- TotalNumResults uint
- HITs []HIT `xml:"HIT"`
-}
-
-// The wrapper data structure returned by SearchHITs
-// http://goo.gl/PskcX
-type SearchHITsResponse struct {
- RequestId string `xml:"OperationRequest>RequestId"`
- SearchHITsResult SearchHITsResult
-}
-
-// The wrapper data structure returned by CreateHIT
-// http://goo.gl/PskcX
-type CreateHITResponse struct {
- RequestId string `xml:"OperationRequest>RequestId"`
- HIT HIT
-}
-
-type Assignment struct {
- AssignmentId string
- WorkerId string
- HITId string
- AssignmentStatus string
- AutoApprovalTime string
- AcceptTime string
- SubmitTime string
- ApprovalTime string
- Answer string
-}
-
-func (a Assignment) Answers() (answers map[string]string) {
- answers = make(map[string]string)
-
- decoder := xml.NewDecoder(strings.NewReader(a.Answer))
-
- for {
- token, _ := decoder.Token()
- if token == nil {
- break
- }
- switch startElement := token.(type) {
- case xml.StartElement:
- if startElement.Name.Local == "Answer" {
- var answer struct {
- QuestionIdentifier string
- FreeText string
- }
-
- decoder.DecodeElement(&answer, &startElement)
- answers[answer.QuestionIdentifier] = answer.FreeText
- }
- }
- }
-
- return
-}
-
-type GetAssignmentsForHITResponse struct {
- RequestId string `xml:"OperationRequest>RequestId"`
- GetAssignmentsForHITResult struct {
- Request xmlRequest
- NumResults uint
- TotalNumResults uint
- PageNumber uint
- Assignment Assignment
- }
-}
-
-/*
-CreateHIT corresponds to the "CreateHIT" operation of the Mechanical Turk
-API. Currently only supports "external" questions (see "HIT" struct above).
-
-Here are the detailed description for the parameters:
-
- title Required. A title should be short and descriptive about the
- kind of task the HIT contains. On the Amazon Mechanical Turk
- web site, the HIT title appears in search results, and
- everywhere the HIT is mentioned.
- description Required. A description includes detailed information about the
- kind of task the HIT contains. On the Amazon Mechanical Turk
- web site, the HIT description appears in the expanded view of
- search results, and in the HIT and assignment screens. A good
- description gives the user enough information to evaluate the
- HIT before accepting it.
- question Required. The data the person completing the HIT uses to produce
- the results. Consstraints: Must be a QuestionForm data structure,
- an ExternalQuestion data structure, or an HTMLQuestion data
- structure. The XML question data must not be larger than 64
- kilobytes (65,535 bytes) in size, including whitespace.
- reward Required. The amount of money the Requester will pay a Worker
- for successfully completing the HIT.
- assignmentDurationInSeconds Required. The amount of time, in seconds, that
- a Worker has to complete the HIT after accepting
- it. If a Worker does not complete the assignment
- within the specified duration, the assignment is
- considered abandoned. If the HIT is still
- active (that is, its lifetime has not elapsed),
- the assignment becomes available for other users
- to find and accept. Valid Values: any integer
- between 30 (30 seconds) and 31536000 (365 days).
- lifetimeInSeconds Required. An amount of time, in seconds, after which the
- HIT is no longer available for users to accept. After
- the lifetime of the HIT elapses, the HIT no longer
- appears in HIT searches, even if not all of the
- assignments for the HIT have been accepted. Valid Values:
- any integer between 30 (30 seconds) and 31536000 (365 days).
- keywords One or more words or phrases that describe the HIT,
- separated by commas. These words are used in searches to
- find HITs. Constraints: cannot be more than 1,000
- characters.
- maxAssignments The number of times the HIT can be accepted and completed
- before the HIT becomes unavailable. Valid Values: any
- integer between 1 and 1000000000 (1 billion). Default: 1
- qualificationRequirement A condition that a Worker's Qualifications must
- meet before the Worker is allowed to accept and
- complete the HIT. Constraints: no more than 10
- QualificationRequirement for each HIT.
- requesterAnnotation An arbitrary data field. The RequesterAnnotation
- parameter lets your application attach arbitrary data to
- the HIT for tracking purposes. For example, the
- RequesterAnnotation parameter could be an identifier
- internal to the Requester's application that corresponds
- with the HIT. Constraints: must not be longer than 255
- characters in length.
-
-Reference:
-http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_CreateHITOperation.html
-*/
-func (mt *MTurk) CreateHIT(
- title, description string,
- question interface{},
- reward Price,
- assignmentDurationInSeconds,
- lifetimeInSeconds uint,
- keywords string,
- maxAssignments uint,
- qualificationRequirement *QualificationRequirement,
- requesterAnnotation string) (h *HIT, err error) {
-
- params := make(map[string]string)
- params["Title"] = title
- params["Description"] = description
- params["Question"], err = xmlEncode(&question)
- if err != nil {
- return
- }
- params["Reward.1.Amount"] = reward.Amount
- params["Reward.1.CurrencyCode"] = reward.CurrencyCode
- params["AssignmentDurationInSeconds"] = strconv.FormatUint(uint64(assignmentDurationInSeconds), 10)
-
- params["LifetimeInSeconds"] = strconv.FormatUint(uint64(lifetimeInSeconds), 10)
- if keywords != "" {
- params["Keywords"] = keywords
- }
- if maxAssignments != 0 {
- params["MaxAssignments"] = strconv.FormatUint(uint64(maxAssignments), 10)
- }
- if qualificationRequirement != nil {
- params["QualificationRequirement"], err = xmlEncode(qualificationRequirement)
- if err != nil {
- return
- }
- }
- if requesterAnnotation != "" {
- params["RequesterAnnotation"] = requesterAnnotation
- }
-
- var response CreateHITResponse
- err = mt.query(params, "CreateHIT", &response)
- if err == nil {
- h = &response.HIT
- }
- return
-}
-
-// Corresponds to the "CreateHIT" operation of the Mechanical Turk
-// API, using an existing "hit type". http://goo.gl/cDBRc Currently only
-// supports "external" questions (see "HIT" struct above). If
-// "maxAssignments" or "requesterAnnotation" are the zero value for
-// their types, they will not be included in the request.
-func (mt *MTurk) CreateHITOfType(hitTypeId string, q ExternalQuestion, lifetimeInSeconds uint, maxAssignments uint, requesterAnnotation string) (h *HIT, err error) {
- params := make(map[string]string)
- params["HITTypeId"] = hitTypeId
- params["Question"], err = xmlEncode(&q)
- if err != nil {
- return
- }
- params["LifetimeInSeconds"] = strconv.FormatUint(uint64(lifetimeInSeconds), 10)
- if maxAssignments != 0 {
- params["MaxAssignments"] = strconv.FormatUint(uint64(maxAssignments), 10)
- }
- if requesterAnnotation != "" {
- params["RequesterAnnotation"] = requesterAnnotation
- }
-
- var response CreateHITResponse
- err = mt.query(params, "CreateHIT", &response)
- if err == nil {
- h = &response.HIT
- }
- return
-}
-
-// Get the Assignments for a HIT.
-func (mt *MTurk) GetAssignmentsForHIT(hitId string) (r *Assignment, err error) {
- params := make(map[string]string)
- params["HITId"] = hitId
- var response GetAssignmentsForHITResponse
- err = mt.query(params, "GetAssignmentsForHIT", &response)
- if err == nil {
- r = &response.GetAssignmentsForHITResult.Assignment
- }
- return
-}
-
-// Corresponds to "SearchHITs" operation of Mechanical Turk. http://goo.gl/PskcX
-// Currenlty supports none of the optional parameters.
-func (mt *MTurk) SearchHITs() (s *SearchHITsResult, err error) {
- params := make(map[string]string)
- var response SearchHITsResponse
- err = mt.query(params, "SearchHITs", &response)
- if err == nil {
- s = &response.SearchHITsResult
- }
- return
-}
-
-// Adds common parameters to the "params" map, signs the request,
-// adds the signature to the "params" map and sends the request
-// to the server. It then unmarshals the response in to the "resp"
-// parameter using xml.Unmarshal()
-func (mt *MTurk) query(params map[string]string, operation string, resp interface{}) error {
- service := "AWSMechanicalTurkRequester"
- timestamp := time.Now().UTC().Format("2006-01-02T15:04:05Z")
-
- params["AWSAccessKeyId"] = mt.Auth.AccessKey
- params["Service"] = service
- params["Timestamp"] = timestamp
- params["Operation"] = operation
-
- // make a copy
- url := *mt.URL
-
- sign(mt.Auth, service, operation, timestamp, params)
- url.RawQuery = multimap(params).Encode()
- r, err := http.Get(url.String())
- if err != nil {
- return err
- }
- //dump, _ := httputil.DumpResponse(r, true)
- //println("DUMP:\n", string(dump))
- if r.StatusCode != 200 {
- return errors.New(fmt.Sprintf("%d: unexpected status code", r.StatusCode))
- }
- dec := xml.NewDecoder(r.Body)
- err = dec.Decode(resp)
- r.Body.Close()
- return err
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-func xmlEncode(i interface{}) (s string, err error) {
- var buf []byte
- buf, err = xml.Marshal(i)
- if err != nil {
- return
- }
- s = string(buf)
- return
-}
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/mturk_test.go b/vendor/github.com/goamz/goamz/exp/mturk/mturk_test.go
deleted file mode 100644
index 0c546571f..000000000
--- a/vendor/github.com/goamz/goamz/exp/mturk/mturk_test.go
+++ /dev/null
@@ -1,170 +0,0 @@
-package mturk_test
-
-import (
- "net/url"
- "testing"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/exp/mturk"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- mturk *mturk.MTurk
-}
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- u, err := url.Parse(testServer.URL)
- if err != nil {
- panic(err.Error())
- }
-
- s.mturk = &mturk.MTurk{
- Auth: auth,
- URL: u,
- }
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestCreateHITExternalQuestion(c *C) {
- testServer.Response(200, nil, BasicHitResponse)
-
- question := mturk.ExternalQuestion{
- ExternalURL: "http://www.amazon.com",
- FrameHeight: 200,
- }
- reward := mturk.Price{
- Amount: "0.01",
- CurrencyCode: "USD",
- }
- hit, err := s.mturk.CreateHIT("title", "description", question, reward, 1, 2, "key1,key2", 3, nil, "annotation")
-
- testServer.WaitRequest()
-
- c.Assert(err, IsNil)
- c.Assert(hit, NotNil)
-
- c.Assert(hit.HITId, Equals, "28J4IXKO2L927XKJTHO34OCDNASCDW")
- c.Assert(hit.HITTypeId, Equals, "2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF")
-}
-
-func (s *S) TestCreateHITHTMLQuestion(c *C) {
- testServer.Response(200, nil, BasicHitResponse)
-
- question := mturk.HTMLQuestion{
- HTMLContent: mturk.HTMLContent{`<![CDATA[
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
- <script type='text/javascript' src='https://s3.amazonaws.com/mturk-public/externalHIT_v1.js'></script>
- </head>
- <body>
- <form name='mturk_form' method='post' id='mturk_form' action='https://www.mturk.com/mturk/externalSubmit'>
- <input type='hidden' value='' name='assignmentId' id='assignmentId'/>
- <h1>What's up?</h1>
- <p><textarea name='comment' cols='80' rows='3'></textarea></p>
- <p><input type='submit' id='submitButton' value='Submit' /></p></form>
- <script language='Javascript'>turkSetAssignmentID();</script>
- </body>
-</html>
-]]>`},
- FrameHeight: 200,
- }
- reward := mturk.Price{
- Amount: "0.01",
- CurrencyCode: "USD",
- }
- hit, err := s.mturk.CreateHIT("title", "description", question, reward, 1, 2, "key1,key2", 3, nil, "annotation")
-
- testServer.WaitRequest()
-
- c.Assert(err, IsNil)
- c.Assert(hit, NotNil)
-
- c.Assert(hit.HITId, Equals, "28J4IXKO2L927XKJTHO34OCDNASCDW")
- c.Assert(hit.HITTypeId, Equals, "2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF")
-}
-
-func (s *S) TestSearchHITs(c *C) {
- testServer.Response(200, nil, SearchHITResponse)
-
- hitResult, err := s.mturk.SearchHITs()
-
- c.Assert(err, IsNil)
- c.Assert(hitResult, NotNil)
-
- c.Assert(hitResult.NumResults, Equals, uint(1))
- c.Assert(hitResult.PageNumber, Equals, uint(1))
- c.Assert(hitResult.TotalNumResults, Equals, uint(1))
-
- c.Assert(len(hitResult.HITs), Equals, 1)
- c.Assert(hitResult.HITs[0].HITId, Equals, "2BU26DG67D1XTE823B3OQ2JF2XWF83")
- c.Assert(hitResult.HITs[0].HITTypeId, Equals, "22OWJ5OPB0YV6IGL5727KP9U38P5XR")
- c.Assert(hitResult.HITs[0].CreationTime, Equals, "2011-12-28T19:56:20Z")
- c.Assert(hitResult.HITs[0].Title, Equals, "test hit")
- c.Assert(hitResult.HITs[0].Description, Equals, "please disregard, testing only")
- c.Assert(hitResult.HITs[0].HITStatus, Equals, "Reviewable")
- c.Assert(hitResult.HITs[0].MaxAssignments, Equals, uint(1))
- c.Assert(hitResult.HITs[0].Reward.Amount, Equals, "0.01")
- c.Assert(hitResult.HITs[0].Reward.CurrencyCode, Equals, "USD")
- c.Assert(hitResult.HITs[0].AutoApprovalDelayInSeconds, Equals, uint(2592000))
- c.Assert(hitResult.HITs[0].AssignmentDurationInSeconds, Equals, uint(30))
- c.Assert(hitResult.HITs[0].NumberOfAssignmentsPending, Equals, uint(0))
- c.Assert(hitResult.HITs[0].NumberOfAssignmentsAvailable, Equals, uint(1))
- c.Assert(hitResult.HITs[0].NumberOfAssignmentsCompleted, Equals, uint(0))
-}
-
-func (s *S) TestGetAssignmentsForHIT_NoAnswer(c *C) {
- testServer.Response(200, nil, GetAssignmentsForHITNoAnswerResponse)
-
- assignment, err := s.mturk.GetAssignmentsForHIT("emptyassignment")
-
- testServer.WaitRequest()
-
- c.Assert(err, IsNil)
- c.Assert(assignment, NotNil)
-
- c.Assert(assignment.HITId, Equals, "")
-}
-
-func (s *S) TestGetAssignmentsForHIT_Answer(c *C) {
- testServer.Response(200, nil, GetAssignmentsForHITAnswerResponse)
-
- assignment, err := s.mturk.GetAssignmentsForHIT("emptyassignment")
-
- testServer.WaitRequest()
-
- c.Assert(err, IsNil)
- c.Assert(assignment, NotNil)
-
- c.Assert(assignment.AssignmentId, Equals, "2QKNTL0XULRGFAQWUWDD05FP94V2O3")
- c.Assert(assignment.WorkerId, Equals, "A1ZUQ2YDM61713")
- c.Assert(assignment.HITId, Equals, "2W36VCPWZ9RN5DX1MBJ7VN3D6WEPAM")
- c.Assert(assignment.AssignmentStatus, Equals, "Submitted")
- c.Assert(assignment.AutoApprovalTime, Equals, "2014-02-26T09:39:48Z")
- c.Assert(assignment.AcceptTime, Equals, "2014-01-27T09:39:38Z")
- c.Assert(assignment.SubmitTime, Equals, "2014-01-27T09:39:48Z")
- c.Assert(assignment.ApprovalTime, Equals, "")
-
- answers := assignment.Answers()
- c.Assert(len(answers), Equals, 4)
- c.Assert(answers["tags"], Equals, "asd")
- c.Assert(answers["text_in_image"], Equals, "asd")
- c.Assert(answers["is_pattern"], Equals, "yes")
- c.Assert(answers["is_map"], Equals, "yes")
-}
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/responses_test.go b/vendor/github.com/goamz/goamz/exp/mturk/responses_test.go
deleted file mode 100644
index abc483945..000000000
--- a/vendor/github.com/goamz/goamz/exp/mturk/responses_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package mturk_test
-
-var BasicHitResponse = `<?xml version="1.0"?>
-<CreateHITResponse><OperationRequest><RequestId>643b794b-66b6-4427-bb8a-4d3df5c9a20e</RequestId></OperationRequest><HIT><Request><IsValid>True</IsValid></Request><HITId>28J4IXKO2L927XKJTHO34OCDNASCDW</HITId><HITTypeId>2XZ7D1X3V0FKQVW7LU51S7PKKGFKDF</HITTypeId></HIT></CreateHITResponse>
-`
-
-var SearchHITResponse = `<?xml version="1.0"?>
-<SearchHITsResponse><OperationRequest><RequestId>38862d9c-f015-4177-a2d3-924110a9d6f2</RequestId></OperationRequest><SearchHITsResult><Request><IsValid>True</IsValid></Request><NumResults>1</NumResults><TotalNumResults>1</TotalNumResults><PageNumber>1</PageNumber><HIT><HITId>2BU26DG67D1XTE823B3OQ2JF2XWF83</HITId><HITTypeId>22OWJ5OPB0YV6IGL5727KP9U38P5XR</HITTypeId><CreationTime>2011-12-28T19:56:20Z</CreationTime><Title>test hit</Title><Description>please disregard, testing only</Description><HITStatus>Reviewable</HITStatus><MaxAssignments>1</MaxAssignments><Reward><Amount>0.01</Amount><CurrencyCode>USD</CurrencyCode><FormattedPrice>$0.01</FormattedPrice></Reward><AutoApprovalDelayInSeconds>2592000</AutoApprovalDelayInSeconds><Expiration>2011-12-28T19:56:50Z</Expiration><AssignmentDurationInSeconds>30</AssignmentDurationInSeconds><NumberOfAssignmentsPending>0</NumberOfAssignmentsPending><NumberOfAssignmentsAvailable>1</NumberOfAssignmentsAvailable><NumberOfAssignmentsCompleted>0</NumberOfAssignmentsCompleted></HIT></SearchHITsResult></SearchHITsResponse>
-`
-
-var GetAssignmentsForHITNoAnswerResponse = `<?xml version="1.0"?>
-<GetAssignmentsForHITResponse><OperationRequest><RequestId>536934be-a35b-4e4e-9822-72fbf36d5862</RequestId></OperationRequest><GetAssignmentsForHITResult><Request><IsValid>True</IsValid></Request><NumResults>0</NumResults><TotalNumResults>0</TotalNumResults><PageNumber>1</PageNumber></GetAssignmentsForHITResult></GetAssignmentsForHITResponse>
-`
-
-var GetAssignmentsForHITAnswerResponse = `<?xml version="1.0"?>
-<GetAssignmentsForHITResponse><OperationRequest><RequestId>2f113bdf-2e3e-4c5a-a396-3ed01384ecb9</RequestId></OperationRequest><GetAssignmentsForHITResult><Request><IsValid>True</IsValid></Request><NumResults>1</NumResults><TotalNumResults>1</TotalNumResults><PageNumber>1</PageNumber><Assignment><AssignmentId>2QKNTL0XULRGFAQWUWDD05FP94V2O3</AssignmentId><WorkerId>A1ZUQ2YDM61713</WorkerId><HITId>2W36VCPWZ9RN5DX1MBJ7VN3D6WEPAM</HITId><AssignmentStatus>Submitted</AssignmentStatus><AutoApprovalTime>2014-02-26T09:39:48Z</AutoApprovalTime><AcceptTime>2014-01-27T09:39:38Z</AcceptTime><SubmitTime>2014-01-27T09:39:48Z</SubmitTime><Answer>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
-&lt;QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd"&gt;
-&lt;Answer&gt;
-&lt;QuestionIdentifier&gt;tags&lt;/QuestionIdentifier&gt;
-&lt;FreeText&gt;asd&lt;/FreeText&gt;
-&lt;/Answer&gt;
-&lt;Answer&gt;
-&lt;QuestionIdentifier&gt;text_in_image&lt;/QuestionIdentifier&gt;
-&lt;FreeText&gt;asd&lt;/FreeText&gt;
-&lt;/Answer&gt;
-&lt;Answer&gt;
-&lt;QuestionIdentifier&gt;is_pattern&lt;/QuestionIdentifier&gt;
-&lt;FreeText&gt;yes&lt;/FreeText&gt;
-&lt;/Answer&gt;
-&lt;Answer&gt;
-&lt;QuestionIdentifier&gt;is_map&lt;/QuestionIdentifier&gt;
-&lt;FreeText&gt;yes&lt;/FreeText&gt;
-&lt;/Answer&gt;
-&lt;/QuestionFormAnswers&gt;
-</Answer></Assignment></GetAssignmentsForHITResult></GetAssignmentsForHITResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/sign.go b/vendor/github.com/goamz/goamz/exp/mturk/sign.go
deleted file mode 100644
index f2ff8cbfe..000000000
--- a/vendor/github.com/goamz/goamz/exp/mturk/sign.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package mturk
-
-import (
- "crypto/hmac"
- "crypto/sha1"
- "encoding/base64"
- "github.com/goamz/goamz/aws"
-)
-
-var b64 = base64.StdEncoding
-
-// ----------------------------------------------------------------------------
-// Mechanical Turk signing (http://goo.gl/wrzfn)
-func sign(auth aws.Auth, service, method, timestamp string, params map[string]string) {
- payload := service + method + timestamp
- hash := hmac.New(sha1.New, []byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- params["Signature"] = string(signature)
-}
diff --git a/vendor/github.com/goamz/goamz/exp/mturk/sign_test.go b/vendor/github.com/goamz/goamz/exp/mturk/sign_test.go
deleted file mode 100644
index 49296eb73..000000000
--- a/vendor/github.com/goamz/goamz/exp/mturk/sign_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package mturk_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/exp/mturk"
- . "gopkg.in/check.v1"
-)
-
-// Mechanical Turk REST authentication docs: http://goo.gl/wrzfn
-
-var testAuth = aws.Auth{AccessKey: "user", SecretKey: "secret"}
-
-// == fIJy9wCApBNL2R4J2WjJGtIBFX4=
-func (s *S) TestBasicSignature(c *C) {
- params := map[string]string{}
- mturk.Sign(testAuth, "AWSMechanicalTurkRequester", "CreateHIT", "2012-02-16T20:30:47Z", params)
- expected := "b/TnvzrdeD/L/EyzdFrznPXhido="
- c.Assert(params["Signature"], Equals, expected)
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sdb/export_test.go b/vendor/github.com/goamz/goamz/exp/sdb/export_test.go
deleted file mode 100644
index 7807a914a..000000000
--- a/vendor/github.com/goamz/goamz/exp/sdb/export_test.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package sdb
-
-import (
- "github.com/goamz/goamz/aws"
-)
-
-func Sign(auth aws.Auth, method, path string, params map[string][]string, headers map[string][]string) {
- sign(auth, method, path, params, headers)
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sdb/responses_test.go b/vendor/github.com/goamz/goamz/exp/sdb/responses_test.go
deleted file mode 100644
index 034c2b31c..000000000
--- a/vendor/github.com/goamz/goamz/exp/sdb/responses_test.go
+++ /dev/null
@@ -1,120 +0,0 @@
-package sdb_test
-
-var TestCreateDomainXmlOK = `
-<?xml version="1.0"?>
-<CreateDomainResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <ResponseMetadata>
- <RequestId>63264005-7a5f-e01a-a224-395c63b89f6d</RequestId>
- <BoxUsage>0.0055590279</BoxUsage>
- </ResponseMetadata>
-</CreateDomainResponse>
-`
-
-var TestListDomainsXmlOK = `
-<?xml version="1.0"?>
-<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <ListDomainsResult>
- <DomainName>Account</DomainName>
- <DomainName>Domain</DomainName>
- <DomainName>Record</DomainName>
- </ListDomainsResult>
- <ResponseMetadata>
- <RequestId>15fcaf55-9914-63c2-21f3-951e31193790</RequestId>
- <BoxUsage>0.0000071759</BoxUsage>
- </ResponseMetadata>
-</ListDomainsResponse>
-`
-
-var TestListDomainsWithNextTokenXmlOK = `
-<?xml version="1.0"?>
-<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <ListDomainsResult>
- <DomainName>Domain1-200706011651</DomainName>
- <DomainName>Domain2-200706011652</DomainName>
- <NextToken>TWV0ZXJpbmdUZXN0RG9tYWluMS0yMDA3MDYwMTE2NTY=</NextToken>
- </ListDomainsResult>
- <ResponseMetadata>
- <RequestId>eb13162f-1b95-4511-8b12-489b86acfd28</RequestId>
- <BoxUsage>0.0000219907</BoxUsage>
- </ResponseMetadata>
-</ListDomainsResponse>
-`
-
-var TestDeleteDomainXmlOK = `
-<?xml version="1.0"?>
-<DeleteDomainResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <ResponseMetadata>
- <RequestId>039e1e25-9a64-2a74-93da-2fda36122a97</RequestId>
- <BoxUsage>0.0055590278</BoxUsage>
- </ResponseMetadata>
-</DeleteDomainResponse>
-`
-
-var TestDomainMetadataXmlNoSuchDomain = `
-<?xml version="1.0"?>
-<Response xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <Errors>
- <Error>
- <Code>NoSuchDomain</Code>
- <Message>The specified domain does not exist.</Message>
- <BoxUsage>0.0000071759</BoxUsage>
- </Error>
- </Errors>
- <RequestID>e050cea2-a772-f90e-2cb0-98ebd42c2898</RequestID>
-</Response>
-`
-
-var TestPutAttrsXmlOK = `
-<?xml version="1.0"?>
-<PutAttributesResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <ResponseMetadata>
- <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId>
- <BoxUsage>0.0000219907</BoxUsage>
- </ResponseMetadata>
-</PutAttributesResponse>
-`
-
-var TestAttrsXmlOK = `
-<?xml version="1.0"?>
-<GetAttributesResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <GetAttributesResult>
- <Attribute><Name>Color</Name><Value>Blue</Value></Attribute>
- <Attribute><Name>Size</Name><Value>Med</Value></Attribute>
- </GetAttributesResult>
- <ResponseMetadata>
- <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId>
- <BoxUsage>0.0000219942</BoxUsage>
- </ResponseMetadata>
-</GetAttributesResponse>
-`
-
-var TestSelectXmlOK = `
-<?xml version="1.0"?>
-<SelectResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
- <SelectResult>
- <Item>
- <Name>Item_03</Name>
- <Attribute><Name>Category</Name><Value>Clothes</Value></Attribute>
- <Attribute><Name>Subcategory</Name><Value>Pants</Value></Attribute>
- <Attribute><Name>Name</Name><Value>Sweatpants</Value></Attribute>
- <Attribute><Name>Color</Name><Value>Blue</Value></Attribute>
- <Attribute><Name>Color</Name><Value>Yellow</Value></Attribute>
- <Attribute><Name>Color</Name><Value>Pink</Value></Attribute>
- <Attribute><Name>Size</Name><Value>Large</Value></Attribute>
- </Item>
- <Item>
- <Name>Item_06</Name>
- <Attribute><Name>Category</Name><Value>Motorcycle Parts</Value></Attribute>
- <Attribute><Name>Subcategory</Name><Value>Bodywork</Value></Attribute>
- <Attribute><Name>Name</Name><Value>Fender Eliminator</Value></Attribute>
- <Attribute><Name>Color</Name><Value>Blue</Value></Attribute>
- <Attribute><Name>Make</Name><Value>Yamaha</Value></Attribute>
- <Attribute><Name>Model</Name><Value>R1</Value></Attribute>
- </Item>
- </SelectResult>
- <ResponseMetadata>
- <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId>
- <BoxUsage>0.0000219907</BoxUsage>
- </ResponseMetadata>
-</SelectResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sdb.go b/vendor/github.com/goamz/goamz/exp/sdb/sdb.go
deleted file mode 100644
index 0d13f4a9e..000000000
--- a/vendor/github.com/goamz/goamz/exp/sdb/sdb.go
+++ /dev/null
@@ -1,413 +0,0 @@
-//
-// goamz - Go packages to interact with the Amazon Web Services.
-//
-// https://wiki.ubuntu.com/goamz
-//
-// Copyright (c) 2011 AppsAttic Ltd.
-//
-// sdb package written by:
-//
-// Andrew Chilton <chilts@appsattic.com>
-// Brad Rydzewski <brad.rydzewski@gmail.com>
-
-// This package is in an experimental state, and does not currently
-// follow conventions and style of the rest of goamz or common
-// Go conventions. It must be polished before it's considered a
-// first-class package in goamz.
-package sdb
-
-// BUG: SelectResp isn't properly organized. It must change.
-
-//
-
-import (
- "encoding/xml"
- "github.com/goamz/goamz/aws"
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "strconv"
- "time"
-)
-
-const debug = false
-
-// The SDB type encapsulates operations with a specific SimpleDB region.
-type SDB struct {
- aws.Auth
- aws.Region
- private byte // Reserve the right of using private data.
-}
-
-// New creates a new SDB.
-func New(auth aws.Auth, region aws.Region) *SDB {
- return &SDB{auth, region, 0}
-}
-
-// The Domain type represents a collection of items that are described
-// by name-value attributes.
-type Domain struct {
- *SDB
- Name string
-}
-
-// Domain returns a Domain with the given name.
-func (sdb *SDB) Domain(name string) *Domain {
- return &Domain{sdb, name}
-}
-
-// The Item type represent individual objects that contain one or more
-// name-value attributes stored within a SDB Domain as rows.
-type Item struct {
- *SDB
- *Domain
- Name string
-}
-
-// Item returns an Item with the given name.
-func (domain *Domain) Item(name string) *Item {
- return &Item{domain.SDB, domain, name}
-}
-
-// The Attr type represent categories of data that can be assigned to items.
-type Attr struct {
- Name string
- Value string
-}
-
-// ----------------------------------------------------------------------------
-// Service-level operations.
-
-// --- ListDomains
-
-// Response to a ListDomains request.
-//
-// See http://goo.gl/3u0Cf for more details.
-type ListDomainsResp struct {
- Domains []string `xml:"ListDomainsResult>DomainName"`
- NextToken string `xml:"ListDomainsResult>NextToken"`
- ResponseMetadata ResponseMetadata
-}
-
-// ListDomains lists all domains in sdb.
-//
-// See http://goo.gl/Dsw15 for more details.
-func (sdb *SDB) ListDomains() (resp *ListDomainsResp, err error) {
- return sdb.ListDomainsN(0, "")
-}
-
-// ListDomainsN lists domains in sdb up to maxDomains.
-// If nextToken is not empty, domains listed will start at the given token.
-//
-// See http://goo.gl/Dsw15 for more details.
-func (sdb *SDB) ListDomainsN(maxDomains int, nextToken string) (resp *ListDomainsResp, err error) {
- params := makeParams("ListDomains")
- if maxDomains != 0 {
- params["MaxNumberOfDomains"] = []string{strconv.Itoa(maxDomains)}
- }
- if nextToken != "" {
- params["NextToken"] = []string{nextToken}
- }
- resp = &ListDomainsResp{}
- err = sdb.query(nil, nil, params, nil, resp)
- return
-}
-
-// --- SelectExpression
-
-// Response to a Select request.
-//
-// See http://goo.gl/GTsSZ for more details.
-type SelectResp struct {
- Items []struct {
- Name string
- Attrs []Attr `xml:"Attribute"`
- } `xml:"SelectResult>Item"`
- ResponseMetadata ResponseMetadata
-}
-
-// Select returns a set of items and attributes that match expr.
-// Select is similar to the standard SQL SELECT statement.
-//
-// See http://goo.gl/GTsSZ for more details.
-func (sdb *SDB) Select(expr string, consistent bool) (resp *SelectResp, err error) {
- resp = &SelectResp{}
- params := makeParams("Select")
- params["SelectExpression"] = []string{expr}
- if consistent {
- params["ConsistentRead"] = []string{"true"}
- }
- err = sdb.query(nil, nil, params, nil, resp)
- return
-}
-
-// ----------------------------------------------------------------------------
-// Domain-level operations.
-
-// --- CreateDomain
-
-// CreateDomain creates a new domain.
-//
-// See http://goo.gl/jDjGH for more details.
-func (domain *Domain) CreateDomain() (resp *SimpleResp, err error) {
- params := makeParams("CreateDomain")
- resp = &SimpleResp{}
- err = domain.SDB.query(domain, nil, params, nil, resp)
- return
-}
-
-// DeleteDomain deletes an existing domain.
-//
-// See http://goo.gl/S0dCL for more details.
-func (domain *Domain) DeleteDomain() (resp *SimpleResp, err error) {
- params := makeParams("DeleteDomain")
- resp = &SimpleResp{}
- err = domain.SDB.query(domain, nil, params, nil, resp)
- return
-}
-
-// ----------------------------------------------------------------------------
-// Item-level operations.
-
-type PutAttrs struct {
- attrs []Attr
- expected []Attr
- replace map[string]bool
- missing map[string]bool
-}
-
-func (pa *PutAttrs) Add(name, value string) {
- pa.attrs = append(pa.attrs, Attr{name, value})
-}
-
-func (pa *PutAttrs) Replace(name, value string) {
- pa.Add(name, value)
- if pa.replace == nil {
- pa.replace = make(map[string]bool)
- }
- pa.replace[name] = true
-}
-
-// The PutAttrs request will only succeed if the existing
-// item in SimpleDB contains a matching name / value pair.
-func (pa *PutAttrs) IfValue(name, value string) {
- pa.expected = append(pa.expected, Attr{name, value})
-}
-
-// Flag to test the existence of an attribute while performing
-// conditional updates. X can be any positive integer or 0.
-//
-// This should set Expected.N.Name=name and Expected.N.Exists=false
-func (pa *PutAttrs) IfMissing(name string) {
- if pa.missing == nil {
- pa.missing = make(map[string]bool)
- }
- pa.missing[name] = true
-}
-
-// PutAttrs adds attrs to item.
-//
-// See http://goo.gl/yTAV4 for more details.
-func (item *Item) PutAttrs(attrs *PutAttrs) (resp *SimpleResp, err error) {
- params := makeParams("PutAttributes")
- resp = &SimpleResp{}
-
- // copy these attrs over to the parameters
- itemNum := 1
- for _, attr := range attrs.attrs {
- itemNumStr := strconv.Itoa(itemNum)
-
- // do the name, value and replace
- params["Attribute."+itemNumStr+".Name"] = []string{attr.Name}
- params["Attribute."+itemNumStr+".Value"] = []string{attr.Value}
-
- if _, ok := attrs.replace[attr.Name]; ok {
- params["Attribute."+itemNumStr+".Replace"] = []string{"true"}
- }
-
- itemNum++
- }
-
- //append expected values to params
- expectedNum := 1
- for _, attr := range attrs.expected {
- expectedNumStr := strconv.Itoa(expectedNum)
- params["Expected."+expectedNumStr+".Name"] = []string{attr.Name}
- params["Expected."+expectedNumStr+".Value"] = []string{attr.Value}
-
- if attrs.missing[attr.Name] {
- params["Expected."+expectedNumStr+".Exists"] = []string{"false"}
- }
- expectedNum++
- }
-
- err = item.query(params, nil, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// Response to an Attrs request.
-//
-// See http://goo.gl/45X1M for more details.
-type AttrsResp struct {
- Attrs []Attr `xml:"GetAttributesResult>Attribute"`
- ResponseMetadata ResponseMetadata
-}
-
-// Attrs returns one or more of the named attributes, or
-// all of item's attributes if names is nil.
-// If consistent is true, previous writes will necessarily
-// be observed.
-//
-// See http://goo.gl/45X1M for more details.
-func (item *Item) Attrs(names []string, consistent bool) (resp *AttrsResp, err error) {
- params := makeParams("GetAttributes")
- params["ItemName"] = []string{item.Name}
- if consistent {
- params["ConsistentRead"] = []string{"true"}
- }
-
- // Copy these attributes over to the parameters
- for i, name := range names {
- params["AttributeName."+strconv.Itoa(i+1)] = []string{name}
- }
-
- resp = &AttrsResp{}
- err = item.query(params, nil, resp)
- if err != nil {
- return nil, err
- }
- return
-}
-
-// ----------------------------------------------------------------------------
-// Generic data structures for all requests/responses.
-
-// Error encapsulates an error returned by SDB.
-type Error struct {
- StatusCode int // HTTP status code (200, 403, ...)
- StatusMsg string // HTTP status message ("Service Unavailable", "Bad Request", ...)
- Code string // SimpleDB error code ("InvalidParameterValue", ...)
- Message string // The human-oriented error message
- RequestId string // A unique ID for this request
- BoxUsage float64 // The measure of machine utilization for this request.
-}
-
-func (err *Error) Error() string {
- return err.Message
-}
-
-// SimpleResp represents a response to an SDB request which on success
-// will return no other information besides ResponseMetadata.
-type SimpleResp struct {
- ResponseMetadata ResponseMetadata
-}
-
-// ResponseMetadata
-type ResponseMetadata struct {
- RequestId string // A unique ID for tracking the request
- BoxUsage float64 // The measure of machine utilization for this request.
-}
-
-func buildError(r *http.Response) error {
- err := Error{}
- err.StatusCode = r.StatusCode
- err.StatusMsg = r.Status
- xml.NewDecoder(r.Body).Decode(&err)
- return &err
-}
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-func (item *Item) query(params url.Values, headers http.Header, resp interface{}) error {
- return item.Domain.SDB.query(item.Domain, item, params, headers, resp)
-}
-
-func (domain *Domain) query(item *Item, params url.Values, headers http.Header, resp interface{}) error {
- return domain.SDB.query(domain, item, params, headers, resp)
-}
-
-func (sdb *SDB) query(domain *Domain, item *Item, params url.Values, headers http.Header, resp interface{}) error {
- // all SimpleDB operations have path="/"
- method := "GET"
- path := "/"
-
- // if we have been given no headers or params, create them
- if headers == nil {
- headers = map[string][]string{}
- }
- if params == nil {
- params = map[string][]string{}
- }
-
- // setup some default parameters
- params["Version"] = []string{"2009-04-15"}
- params["Timestamp"] = []string{time.Now().UTC().Format(time.RFC3339)}
-
- // set the DomainName param (every request must have one)
- if domain != nil {
- params["DomainName"] = []string{domain.Name}
- }
-
- // set the ItemName if we have one
- if item != nil {
- params["ItemName"] = []string{item.Name}
- }
-
- // check the endpoint URL
- u, err := url.Parse(sdb.Region.SDBEndpoint)
- if err != nil {
- return err
- }
- headers["Host"] = []string{u.Host}
- sign(sdb.Auth, method, path, params, headers)
-
- u.Path = path
- if len(params) > 0 {
- u.RawQuery = params.Encode()
- }
- req := http.Request{
- URL: u,
- Method: method,
- ProtoMajor: 1,
- ProtoMinor: 1,
- Close: true,
- Header: headers,
- }
-
- if v, ok := headers["Content-Length"]; ok {
- req.ContentLength, _ = strconv.ParseInt(v[0], 10, 64)
- delete(headers, "Content-Length")
- }
-
- r, err := http.DefaultClient.Do(&req)
- if err != nil {
- return err
- }
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("response:\n")
- log.Printf("%v\n}\n", string(dump))
- }
-
- // status code is always 200 when successful (since we're always doing a GET)
- if r.StatusCode != 200 {
- return buildError(r)
- }
-
- // everything was fine, so unmarshal the XML and return what it's err is (if any)
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-func makeParams(action string) map[string][]string {
- params := make(map[string][]string)
- params["Action"] = []string{action}
- return params
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sdb_test.go b/vendor/github.com/goamz/goamz/exp/sdb/sdb_test.go
deleted file mode 100644
index 83e7f9f86..000000000
--- a/vendor/github.com/goamz/goamz/exp/sdb/sdb_test.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package sdb_test
-
-import (
- "testing"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/exp/sdb"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- sdb *sdb.SDB
-}
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.sdb = sdb.New(auth, aws.Region{SDBEndpoint: testServer.URL})
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestCreateDomainOK(c *C) {
- testServer.Response(200, nil, TestCreateDomainXmlOK)
-
- domain := s.sdb.Domain("domain")
- resp, err := domain.CreateDomain()
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "63264005-7a5f-e01a-a224-395c63b89f6d")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0055590279)
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestListDomainsOK(c *C) {
- testServer.Response(200, nil, TestListDomainsXmlOK)
-
- resp, err := s.sdb.ListDomains()
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "15fcaf55-9914-63c2-21f3-951e31193790")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000071759)
- c.Assert(resp.Domains, DeepEquals, []string{"Account", "Domain", "Record"})
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestListDomainsWithNextTokenXmlOK(c *C) {
- testServer.Response(200, nil, TestListDomainsWithNextTokenXmlOK)
-
- resp, err := s.sdb.ListDomains()
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "eb13162f-1b95-4511-8b12-489b86acfd28")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907)
- c.Assert(resp.Domains, DeepEquals, []string{"Domain1-200706011651", "Domain2-200706011652"})
- c.Assert(resp.NextToken, Equals, "TWV0ZXJpbmdUZXN0RG9tYWluMS0yMDA3MDYwMTE2NTY=")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestDeleteDomainOK(c *C) {
- testServer.Response(200, nil, TestDeleteDomainXmlOK)
-
- domain := s.sdb.Domain("domain")
- resp, err := domain.DeleteDomain()
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "039e1e25-9a64-2a74-93da-2fda36122a97")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0055590278)
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestPutAttrsOK(c *C) {
- testServer.Response(200, nil, TestPutAttrsXmlOK)
-
- domain := s.sdb.Domain("MyDomain")
- item := domain.Item("Item123")
-
- putAttrs := new(sdb.PutAttrs)
- putAttrs.Add("FirstName", "john")
- putAttrs.Add("LastName", "smith")
- putAttrs.Replace("MiddleName", "jacob")
-
- putAttrs.IfValue("FirstName", "john")
- putAttrs.IfMissing("FirstName")
-
- resp, err := item.PutAttrs(putAttrs)
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Form["Action"], DeepEquals, []string{"PutAttributes"})
- c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"})
- c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"})
- c.Assert(req.Form["Attribute.1.Name"], DeepEquals, []string{"FirstName"})
- c.Assert(req.Form["Attribute.1.Value"], DeepEquals, []string{"john"})
- c.Assert(req.Form["Attribute.2.Name"], DeepEquals, []string{"LastName"})
- c.Assert(req.Form["Attribute.2.Value"], DeepEquals, []string{"smith"})
- c.Assert(req.Form["Attribute.3.Name"], DeepEquals, []string{"MiddleName"})
- c.Assert(req.Form["Attribute.3.Value"], DeepEquals, []string{"jacob"})
- c.Assert(req.Form["Attribute.3.Replace"], DeepEquals, []string{"true"})
-
- c.Assert(req.Form["Expected.1.Name"], DeepEquals, []string{"FirstName"})
- c.Assert(req.Form["Expected.1.Value"], DeepEquals, []string{"john"})
- c.Assert(req.Form["Expected.1.Exists"], DeepEquals, []string{"false"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "490206ce-8292-456c-a00f-61b335eb202b")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907)
-
-}
-
-func (s *S) TestAttrsOK(c *C) {
- testServer.Response(200, nil, TestAttrsXmlOK)
-
- domain := s.sdb.Domain("MyDomain")
- item := domain.Item("Item123")
-
- resp, err := item.Attrs(nil, true)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
- c.Assert(req.Form["Action"], DeepEquals, []string{"GetAttributes"})
- c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"})
- c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"})
- c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"})
-
- c.Assert(resp.Attrs[0].Name, Equals, "Color")
- c.Assert(resp.Attrs[0].Value, Equals, "Blue")
- c.Assert(resp.Attrs[1].Name, Equals, "Size")
- c.Assert(resp.Attrs[1].Value, Equals, "Med")
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219942)
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestAttrsSelectOK(c *C) {
- testServer.Response(200, nil, TestAttrsXmlOK)
-
- domain := s.sdb.Domain("MyDomain")
- item := domain.Item("Item123")
-
- resp, err := item.Attrs([]string{"Color", "Size"}, true)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
- c.Assert(req.Form["Action"], DeepEquals, []string{"GetAttributes"})
- c.Assert(req.Form["ItemName"], DeepEquals, []string{"Item123"})
- c.Assert(req.Form["DomainName"], DeepEquals, []string{"MyDomain"})
- c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"})
- c.Assert(req.Form["AttributeName.1"], DeepEquals, []string{"Color"})
- c.Assert(req.Form["AttributeName.2"], DeepEquals, []string{"Size"})
-
- c.Assert(resp.Attrs[0].Name, Equals, "Color")
- c.Assert(resp.Attrs[0].Value, Equals, "Blue")
- c.Assert(resp.Attrs[1].Name, Equals, "Size")
- c.Assert(resp.Attrs[1].Value, Equals, "Med")
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219942)
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSelectOK(c *C) {
- testServer.Response(200, nil, TestSelectXmlOK)
-
- resp, err := s.sdb.Select("select Color from MyDomain where Color like 'Blue%'", true)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
- c.Assert(req.Form["Action"], DeepEquals, []string{"Select"})
- c.Assert(req.Form["ConsistentRead"], DeepEquals, []string{"true"})
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "b1e8f1f7-42e9-494c-ad09-2674e557526d")
- c.Assert(resp.ResponseMetadata.BoxUsage, Equals, 0.0000219907)
- c.Assert(len(resp.Items), Equals, 2)
- c.Assert(resp.Items[0].Name, Equals, "Item_03")
- c.Assert(resp.Items[1].Name, Equals, "Item_06")
- c.Assert(resp.Items[0].Attrs[0].Name, Equals, "Category")
- c.Assert(resp.Items[0].Attrs[0].Value, Equals, "Clothes")
-
- c.Assert(err, IsNil)
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sign.go b/vendor/github.com/goamz/goamz/exp/sdb/sign.go
deleted file mode 100644
index 040ed5385..000000000
--- a/vendor/github.com/goamz/goamz/exp/sdb/sign.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package sdb
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "github.com/goamz/goamz/aws"
- "net/http"
- "net/url"
- "sort"
- "strings"
-)
-
-var b64 = base64.StdEncoding
-
-// ----------------------------------------------------------------------------
-// SimpleDB signing (http://goo.gl/CaY81)
-
-func sign(auth aws.Auth, method, path string, params url.Values, headers http.Header) {
- var host string
- for k, v := range headers {
- k = strings.ToLower(k)
- switch k {
- case "host":
- host = v[0]
- }
- }
-
- // set up some defaults used for signing the request
- params["AWSAccessKeyId"] = []string{auth.AccessKey}
- params["SignatureVersion"] = []string{"2"}
- params["SignatureMethod"] = []string{"HmacSHA256"}
- if auth.Token() != "" {
- params["SecurityToken"] = []string{auth.Token()}
- }
-
- // join up all the incoming params
- var sarray []string
- for k, v := range params {
- sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v[0]))
- }
- sort.StringSlice(sarray).Sort()
- joined := strings.Join(sarray, "&")
-
- // create the payload, sign it and create the signature
- payload := strings.Join([]string{method, host, "/", joined}, "\n")
- hash := hmac.New(sha256.New, []byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- // add the signature to the outgoing params
- params["Signature"] = []string{string(signature)}
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sdb/sign_test.go b/vendor/github.com/goamz/goamz/exp/sdb/sign_test.go
deleted file mode 100644
index f45ad15e1..000000000
--- a/vendor/github.com/goamz/goamz/exp/sdb/sign_test.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package sdb_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/exp/sdb"
- . "gopkg.in/check.v1"
-)
-
-// SimpleDB ReST authentication docs: http://goo.gl/CaY81
-
-var testAuth = aws.Auth{AccessKey: "access-key-id-s8eBOWuU", SecretKey: "secret-access-key-UkQjTLd9"}
-
-func (s *S) TestSignExampleDomainCreate(c *C) {
- method := "GET"
- params := map[string][]string{
- "Action": {"CreateDomain"},
- "DomainName": {"MyDomain"},
- "Timestamp": {"2011-08-20T07:23:57+12:00"},
- "Version": {"2009-04-15"},
- }
- headers := map[string][]string{
- "Host": {"sdb.amazonaws.com"},
- }
- sdb.Sign(testAuth, method, "", params, headers)
- expected := "ot2JaeeqMRJqgAqW67hkzUlffgxdOz4RykbrECB+tDU="
- c.Assert(params["Signature"], DeepEquals, []string{expected})
-}
-
-// Do a few test methods which takes combinations of params
diff --git a/vendor/github.com/goamz/goamz/exp/ses/ses.go b/vendor/github.com/goamz/goamz/exp/ses/ses.go
deleted file mode 100644
index 3896c5253..000000000
--- a/vendor/github.com/goamz/goamz/exp/ses/ses.go
+++ /dev/null
@@ -1,149 +0,0 @@
-// ses.go
-package ses
-
-import (
- "encoding/xml"
- "github.com/goamz/goamz/aws"
- "io/ioutil"
- "net/http"
- "net/url"
- "strconv"
- "strings"
-)
-
-type SES struct {
- auth aws.Auth
- region aws.Region
- client *http.Client
-}
-
-// Initializes a pointer to an SES struct which can be used
-// to perform SES API calls.
-func NewSES(auth aws.Auth, region aws.Region) *SES {
- ses := SES{auth, region, nil}
- return &ses
-}
-
-// Sends an email to the specifications stored in the Email struct.
-func (ses *SES) SendEmail(email *Email) error {
- data := make(url.Values)
-
- index := 0
- for i := range email.destination.bccAddresses {
- if len(email.destination.bccAddresses[i]) > 0 {
- index += 1
- key := "Destination.BccAddresses.member." + strconv.Itoa(index)
- data.Add(key, email.destination.bccAddresses[i])
- }
- }
-
- index = 0
- for i := range email.destination.ccAddresses {
- if len(email.destination.ccAddresses[i]) > 0 {
- index += 1
- key := "Destination.CcAddresses.member." + strconv.Itoa(index)
- data.Add(key, email.destination.ccAddresses[i])
- }
- }
-
- index = 0
- for i := range email.destination.toAddresses {
- if len(email.destination.toAddresses[i]) > 0 {
- index += 1
- key := "Destination.ToAddresses.member." + strconv.Itoa(index)
- data.Add(key, email.destination.toAddresses[i])
- }
- }
-
- index = 0
- for i := range email.replyTo {
- if len(email.replyTo[i]) > 0 {
- index += 1
- key := "ReplyToAddresses.member." + strconv.Itoa(index)
- data.Add(key, email.replyTo[i])
- }
- }
-
- if len(email.message.Subject.Data) > 0 {
- if len(email.message.Subject.Charset) > 0 {
- data.Add("Message.Subject.Charset", email.message.Subject.Charset)
- }
- data.Add("Message.Subject.Data", email.message.Subject.Data)
- }
-
- if len(email.message.Body.Html.Data) > 0 {
- if len(email.message.Body.Html.Charset) > 0 {
- data.Add("Message.Body.Html.Charset", email.message.Body.Html.Charset)
- }
- data.Add("Message.Body.Html.Data", email.message.Body.Html.Data)
- }
-
- if len(email.message.Body.Text.Data) > 0 {
- if len(email.message.Body.Text.Charset) > 0 {
- data.Add("Message.Body.Text.Charset", email.message.Body.Text.Charset)
- }
- data.Add("Message.Body.Text.Data", email.message.Body.Text.Data)
- }
-
- if len(email.returnPath) > 0 {
- data.Add("ReturnPath", email.returnPath)
- }
-
- if len(email.source) > 0 {
- data.Add("Source", email.source)
- }
-
- return ses.doPost("SendEmail", data)
-}
-
-// Do an SES POST action.
-func (ses *SES) doPost(action string, data url.Values) error {
- req := http.Request{
- Method: "POST",
- ProtoMajor: 1,
- ProtoMinor: 1,
- Close: true,
- Header: http.Header{}}
-
- URL, err := url.Parse(ses.region.SESEndpoint)
- if err != nil {
- return err
- }
- URL.Path = "/"
-
- req.URL = URL
- req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
- token := ses.auth.Token()
- if token != "" {
- req.Header.Set("X-Amz-Security-Token", token)
- }
- sign(ses.auth, "POST", req.Header)
-
- data.Add("AWSAccessKeyId", ses.auth.AccessKey)
- data.Add("Action", action)
-
- body := data.Encode()
- req.Header.Add("Content-Length", strconv.Itoa(len(body)))
- req.Body = ioutil.NopCloser(strings.NewReader(body))
-
- if ses.client == nil {
- ses.client = &http.Client{}
- }
-
- resp, err := ses.client.Do(&req)
- if err != nil {
- return err
- }
- if resp.StatusCode > 204 {
- defer resp.Body.Close()
- return buildError(resp)
- }
-
- return nil
-}
-
-func buildError(r *http.Response) *SESError {
- rootElem := errorResponse{}
- xml.NewDecoder(r.Body).Decode(&rootElem)
- return &rootElem.Error
-}
diff --git a/vendor/github.com/goamz/goamz/exp/ses/ses_test.go b/vendor/github.com/goamz/goamz/exp/ses/ses_test.go
deleted file mode 100644
index ae93215ed..000000000
--- a/vendor/github.com/goamz/goamz/exp/ses/ses_test.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// ses_test
-package ses_test
-
-import (
- "bytes"
- "net/url"
- "testing"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/exp/ses"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-type S struct {
- ses *ses.SES
-}
-
-var _ = Suite(&S{})
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.ses = ses.NewSES(auth, aws.Region{Name: "faux-region-1", S3Endpoint: testServer.URL})
-}
-
-func (s *S) TearDownStrategy(c *C) {
-
-}
-
-func (s *S) SetUpTest(c *C) {
-
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestSendEmail(c *C) {
- testServer.Response(200, nil, "")
-
- email := ses.NewEmail()
- email.AddTo("test@test.com")
- email.AddSource("test@test.com")
- email.SetSubject("test")
- email.SetBodyHtml("test")
-
- s.ses.SendEmail(email)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- buf := new(bytes.Buffer)
- buf.ReadFrom(req.Body)
- body, _ := url.ParseQuery(buf.String())
-
- c.Assert(body, Not(IsNil))
- c.Assert(body["Destination.ToAddresses.member.1"], Equals, "test@test.com")
- c.Assert(body["Source"], Equals, "test@test.com")
- c.Assert(body["Message.Subject.Data"], Equals, "test")
- c.Assert(body["Message.Body.Html.Data"], Equals, "test")
-}
diff --git a/vendor/github.com/goamz/goamz/exp/ses/ses_types.go b/vendor/github.com/goamz/goamz/exp/ses/ses_types.go
deleted file mode 100644
index d26e83740..000000000
--- a/vendor/github.com/goamz/goamz/exp/ses/ses_types.go
+++ /dev/null
@@ -1,160 +0,0 @@
-// ses_types
-package ses
-
-// Private internal representation of message body.
-type Body struct {
- Html Content
- Text Content
-}
-
-// Content data structure with charset and payload (Data).
-type Content struct {
- Charset string
- Data string
-}
-
-// Email data structure. Should be main data structure used
-// for sending emails using SES.
-type Email struct {
- destination *destination
- message Message
- replyTo []string
- returnPath string
- source string
-}
-
-// Private internal representation for email destinations.
-type destination struct {
- bccAddresses []string
- ccAddresses []string
- toAddresses []string
-}
-
-// Message data structure.
-type Message struct {
- Body Body
- Subject Content
-}
-
-// SES Error structure.
-type SESError struct {
- Type string
- Code string
- Message string
- Detail string
- RequestId string
-}
-
-type errorResponse struct {
- Error SESError
-}
-
-func (err *SESError) Error() string {
- return err.Message
-}
-
-// Returns a pointer to an empty but initialized Email.
-func NewEmail() *Email {
- return &Email{
- destination: newDestination(),
- replyTo: make([]string, 5)}
-}
-
-// Private function to return an initialized destination.
-func newDestination() *destination {
- return &destination{
- bccAddresses: make([]string, 5),
- ccAddresses: make([]string, 5),
- toAddresses: make([]string, 5)}
-}
-
-// Add a BCC destination to Email.
-func (em *Email) AddBCC(address string) {
- em.destination.bccAddresses = append(em.destination.bccAddresses, address)
-}
-
-// Add multiple BCC destinations to Email.
-func (em *Email) AddBCCs(addresses []string) {
- em.destination.bccAddresses = append(em.destination.bccAddresses, addresses...)
-}
-
-// Add a CC destination to Email.
-func (em *Email) AddCC(address string) {
- em.destination.ccAddresses = append(em.destination.ccAddresses, address)
-}
-
-// Add multiple CC destinations to Email.
-func (em *Email) AddCCs(addresses []string) {
- em.destination.ccAddresses = append(em.destination.ccAddresses, addresses...)
-}
-
-// Add a To destination to Email.
-func (em *Email) AddTo(address string) {
- em.destination.toAddresses = append(em.destination.toAddresses, address)
-}
-
-// Add multiple To destinations to Email.
-func (em *Email) AddTos(addresses []string) {
- em.destination.toAddresses = append(em.destination.toAddresses, addresses...)
-}
-
-// Add a reply-to address to Email.
-func (em *Email) AddReplyTo(address string) {
- em.replyTo = append(em.replyTo, address)
-}
-
-// Add multiple reply-to addresses to Email.
-func (em *Email) AddReplyTos(addresses []string) {
- em.replyTo = append(em.replyTo, addresses...)
-}
-
-// Set the return path for Email.
-func (em *Email) SetReturnPath(path string) {
- em.returnPath = path
-}
-
-// Set the source address for Email.
-func (em *Email) SetSource(source string) {
- em.source = source
-}
-
-// Set the Email message.
-func (em *Email) SetMessage(message Message) {
- em.message = message
-}
-
-// Set the subject for the Email message.
-// Uses ASCII as charset.
-func (em *Email) SetSubject(subject string) {
- em.message.Subject = Content{Data: subject}
-}
-
-// Set the subject for the Email message.
-// Uses the charset (or ASCII if none) of Content.
-func (em *Email) SetSubjectAsContent(subject Content) {
- em.message.Subject = subject
-}
-
-// Sets the HTML body of the Email message.
-// Uses ASCII as charset.
-func (em *Email) SetBodyHtml(html string) {
- em.message.Body.Html = Content{Data: html}
-}
-
-// Sets the HTML body of the Email message.
-// Uses the charset (or ASCII if none) of Content.
-func (em *Email) SetBodyHtmlAsContent(html Content) {
- em.message.Body.Html = html
-}
-
-// Sets the raw text body of the Email message.
-// Uses ASCII as charset.
-func (em *Email) SetBodyRawText(text string) {
- em.message.Body.Text = Content{Data: text}
-}
-
-// Sets the raw test body of the Email message.
-// Uses the charset (or ASCII if none) of Content.
-func (em *Email) SetBodyRawTextAsContent(text Content) {
- em.message.Body.Text = text
-}
diff --git a/vendor/github.com/goamz/goamz/exp/ses/sign.go b/vendor/github.com/goamz/goamz/exp/ses/sign.go
deleted file mode 100644
index 5c9c840c8..000000000
--- a/vendor/github.com/goamz/goamz/exp/ses/sign.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// sign
-package ses
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "fmt"
- "github.com/goamz/goamz/aws"
- "time"
-)
-
-const (
- AMZ_DATE_STYLE = "Mon, 02 Jan 2006 15:04:05 -0700"
-)
-
-// Sign SES request as dictated by Amazon's Version 3 signature method.
-func sign(auth aws.Auth, method string, headers map[string][]string) {
- date := time.Now().UTC().Format(AMZ_DATE_STYLE)
- h := hmac.New(sha256.New, []byte(auth.SecretKey))
- h.Write([]byte(date))
- signature := base64.StdEncoding.EncodeToString(h.Sum(nil))
- authHeader := fmt.Sprintf("AWS3-HTTPS AWSAccessKeyId=%s, Algorithm=HmacSHA256, Signature=%s", auth.AccessKey, signature)
- headers["Date"] = []string{date}
- headers["X-Amzn-Authorization"] = []string{authHeader}
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/Makefile b/vendor/github.com/goamz/goamz/exp/sns/Makefile
deleted file mode 100644
index 1e5b9da3b..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-include $(GOROOT)/src/Make.inc
-
-TARG=launchpad.net/goamz/sns
-
-GOFILES=\
- sns.go\
- sign.go\
-
-include $(GOROOT)/src/Make.pkg
-
-GOFMT=gofmt
-BADFMT=$(shell $(GOFMT) -l $(GOFILES) 2> /dev/null)
-
-gofmt: $(BADFMT)
- @for F in $(BADFMT); do $(GOFMT) -w $$F && echo $$F; done
-
-ifneq ($(BADFMT),)
-ifneq ($(MAKECMDGOALS), gofmt)
-#$(warning WARNING: make gofmt: $(BADFMT))
-endif
-endif
diff --git a/vendor/github.com/goamz/goamz/exp/sns/README b/vendor/github.com/goamz/goamz/exp/sns/README
deleted file mode 100644
index 87770adb5..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/README
+++ /dev/null
@@ -1 +0,0 @@
-Amazon Simple Notification Service API for Golang.
diff --git a/vendor/github.com/goamz/goamz/exp/sns/endpoint.go b/vendor/github.com/goamz/goamz/exp/sns/endpoint.go
deleted file mode 100644
index c6e6e4433..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/endpoint.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package sns
-
-import (
- "fmt"
- "strconv"
-)
-
-type DeleteEndpointResponse struct {
- ResponseMetadata
-}
-
-type GetEndpointAttributesResponse struct {
- Attributes []AttributeEntry `xml:"GetEndpointAttributesResult>Attributes>entry"`
- ResponseMetadata
-}
-
-type PlatformEndpointOpt struct {
- Attributes []AttributeEntry
- PlatformApplicationArn string
- CustomUserData string
- Token string
-}
-
-type CreatePlatformEndpointResponse struct {
- EndpointArn string `xml:"CreatePlatformEndpointResult>EndpointArn"`
- ResponseMetadata
-}
-
-type PlatformEndpoints struct {
- EndpointArn string `xml:"EndpointArn"`
- Attributes []AttributeEntry `xml:"Attributes>entry"`
-}
-
-type ListEndpointsByPlatformApplicationResponse struct {
- Endpoints []PlatformEndpoints `xml:"ListEndpointsByPlatformApplicationResult>Endpoints>member"`
- ResponseMetadata
-}
-
-type SetEndpointAttributesOpt struct {
- Attributes []AttributeEntry
- EndpointArn string
-}
-
-type SetEndpointAttributesResponse struct {
- ResponseMetadata
-}
-
-// DeleteEndpoint
-//
-// See http://goo.gl/9SlUD9 for more details.
-func (sns *SNS) DeleteEndpoint(endpointArn string) (resp *DeleteEndpointResponse, err error) {
- resp = &DeleteEndpointResponse{}
- params := makeParams("DeleteEndpoint")
-
- params["EndpointArn"] = endpointArn
-
- err = sns.query(params, resp)
-
- return
-}
-
-// GetEndpointAttributes
-//
-// See http://goo.gl/c8E5X1 for more details.
-func (sns *SNS) GetEndpointAttributes(endpointArn string) (resp *GetEndpointAttributesResponse, err error) {
- resp = &GetEndpointAttributesResponse{}
-
- params := makeParams("GetEndpointAttributes")
-
- params["EndpointArn"] = endpointArn
-
- err = sns.query(params, resp)
-
- return
-}
-
-// CreatePlatformEndpoint
-//
-// See http://goo.gl/4tnngi for more details.
-func (sns *SNS) CreatePlatformEndpoint(options *PlatformEndpointOpt) (resp *CreatePlatformEndpointResponse, err error) {
-
- resp = &CreatePlatformEndpointResponse{}
- params := makeParams("CreatePlatformEndpoint")
-
- params["PlatformApplicationArn"] = options.PlatformApplicationArn
- params["Token"] = options.Token
-
- if options.CustomUserData != "" {
- params["CustomUserData"] = options.CustomUserData
- }
-
- err = sns.query(params, resp)
-
- return
-}
-
-// ListEndpointsByPlatformApplication
-//
-// See http://goo.gl/L7ioyR for more detail.
-func (sns *SNS) ListEndpointsByPlatformApplication(platformApplicationArn, nextToken string) (resp *ListEndpointsByPlatformApplicationResponse, err error) {
- resp = &ListEndpointsByPlatformApplicationResponse{}
-
- params := makeParams("ListEndpointsByPlatformApplication")
-
- params["PlatformApplicationArn"] = platformApplicationArn
-
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- err = sns.query(params, resp)
- return
-
-}
-
-// SetEndpointAttributes
-//
-// See http://goo.gl/GTktCj for more detail.
-func (sns *SNS) SetEndpointAttributes(options *SetEndpointAttributesOpt) (resp *SetEndpointAttributesResponse, err error) {
- resp = &SetEndpointAttributesResponse{}
- params := makeParams("SetEndpointAttributes")
-
- params["EndpointArn"] = options.EndpointArn
-
- for i, attr := range options.Attributes {
- params[fmt.Sprintf("Attributes.entry.%s.key", strconv.Itoa(i+1))] = attr.Key
- params[fmt.Sprintf("Attributes.entry.%s.value", strconv.Itoa(i+1))] = attr.Value
- }
-
- err = sns.query(params, resp)
- return
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/permissions.go b/vendor/github.com/goamz/goamz/exp/sns/permissions.go
deleted file mode 100644
index e7c73629f..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/permissions.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package sns
-
-import (
- "strconv"
-)
-
-type Permission struct {
- ActionName string
- AccountId string
-}
-
-type AddPermissionResponse struct {
- ResponseMetadata
-}
-
-// AddPermission
-//
-// See http://goo.gl/mbY4a for more details.
-func (sns *SNS) AddPermission(permissions []Permission, Label, TopicArn string) (resp *AddPermissionResponse, err error) {
- resp = &AddPermissionResponse{}
- params := makeParams("AddPermission")
-
- for i, p := range permissions {
- params["AWSAccountId.member."+strconv.Itoa(i+1)] = p.AccountId
- params["ActionName.member."+strconv.Itoa(i+1)] = p.ActionName
- }
-
- params["Label"] = Label
- params["TopicArn"] = TopicArn
-
- err = sns.query(params, resp)
- return
-}
-
-type RemovePermissionResponse struct {
- ResponseMetadata
-}
-
-// RemovePermission
-//
-// See http://goo.gl/wGl5j for more details.
-func (sns *SNS) RemovePermission(Label, TopicArn string) (resp *RemovePermissionResponse, err error) {
- resp = &RemovePermissionResponse{}
- params := makeParams("RemovePermission")
-
- params["Label"] = Label
- params["TopicArn"] = TopicArn
-
- err = sns.query(params, resp)
- return
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/platform.go b/vendor/github.com/goamz/goamz/exp/sns/platform.go
deleted file mode 100644
index b650cdda7..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/platform.go
+++ /dev/null
@@ -1,135 +0,0 @@
-package sns
-
-import (
- "fmt"
- "strconv"
-)
-
-type CreatePlatformApplicationResponse struct {
- PlatformApplicationArn string `xml:"CreatePlatformApplicationResult>PlatformApplicationArn"`
- ResponseMetadata
-}
-
-type PlatformApplicationOpt struct {
- Attributes []AttributeEntry
- Name string
- Platform string
-}
-
-type DeletePlatformApplicationResponse struct {
- ResponseMetadata
-}
-
-type GetPlatformApplicationAttributesResponse struct {
- Attributes []AttributeEntry `xml:"GetPlatformApplicationAttributesResult>Attributes>entry"`
- ResponseMetadata
-}
-
-type SetPlatformApplicationAttributesOpt struct {
- Attributes []AttributeEntry
- PlatformApplicationArn string
-}
-
-type SetPlatformApplicationAttributesResponse struct {
- ResponseMetadata
-}
-
-type PlatformApplication struct {
- Attributes []AttributeEntry `xml:"Attributes>entry"`
- PlatformApplicationArn string
-}
-
-type ListPlatformApplicationsResponse struct {
- NextToken string
- PlatformApplications []PlatformApplication `xml:"ListPlatformApplicationsResult>PlatformApplications>member"`
- ResponseMetadata
-}
-
-// CreatePlatformApplication
-//
-// See http://goo.gl/Mbbl6Z for more details.
-
-func (sns *SNS) CreatePlatformApplication(options *PlatformApplicationOpt) (resp *CreatePlatformApplicationResponse, err error) {
- resp = &CreatePlatformApplicationResponse{}
- params := makeParams("CreatePlatformApplication")
-
- params["Platform"] = options.Platform
- params["Name"] = options.Name
-
- for i, attr := range options.Attributes {
- params[fmt.Sprintf("Attributes.entry.%s.key", strconv.Itoa(i+1))] = attr.Key
- params[fmt.Sprintf("Attributes.entry.%s.value", strconv.Itoa(i+1))] = attr.Value
- }
-
- err = sns.query(params, resp)
-
- return
-
-}
-
-// DeletePlatformApplication
-//
-// See http://goo.gl/6GB3DN for more details.
-func (sns *SNS) DeletePlatformApplication(platformApplicationArn string) (resp *DeletePlatformApplicationResponse, err error) {
- resp = &DeletePlatformApplicationResponse{}
-
- params := makeParams("DeletePlatformApplication")
-
- params["PlatformApplicationArn"] = platformApplicationArn
-
- err = sns.query(params, resp)
-
- return
-}
-
-// GetPlatformApplicationAttributes
-//
-// See http://goo.gl/GswJ8I for more details.
-func (sns *SNS) GetPlatformApplicationAttributes(platformApplicationArn, nextToken string) (resp *GetPlatformApplicationAttributesResponse, err error) {
- resp = &GetPlatformApplicationAttributesResponse{}
-
- params := makeParams("GetPlatformApplicationAttributes")
-
- params["PlatformApplicationArn"] = platformApplicationArn
-
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- err = sns.query(params, resp)
-
- return
-}
-
-// ListPlatformApplications
-//
-// See http://goo.gl/vQ3ooV for more detail.
-func (sns *SNS) ListPlatformApplications(nextToken string) (resp *ListPlatformApplicationsResponse, err error) {
- resp = &ListPlatformApplicationsResponse{}
- params := makeParams("ListPlatformApplications")
-
- if nextToken != "" {
- params["NextToken"] = nextToken
- }
-
- err = sns.query(params, resp)
- return
-}
-
-// SetPlatformApplicationAttributes
-//
-// See http://goo.gl/RWnzzb for more detail.
-func (sns *SNS) SetPlatformApplicationAttributes(options *SetPlatformApplicationAttributesOpt) (resp *SetPlatformApplicationAttributesResponse, err error) {
- resp = &SetPlatformApplicationAttributesResponse{}
- params := makeParams("SetPlatformApplicationAttributes")
-
- params["PlatformApplicationArn"] = options.PlatformApplicationArn
-
- for i, attr := range options.Attributes {
- params[fmt.Sprintf("Attributes.entry.%s.key", strconv.Itoa(i+1))] = attr.Key
- params[fmt.Sprintf("Attributes.entry.%s.value", strconv.Itoa(i+1))] = attr.Value
- }
-
- err = sns.query(params, resp)
- return
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/responses_test.go b/vendor/github.com/goamz/goamz/exp/sns/responses_test.go
deleted file mode 100644
index 53a06429d..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/responses_test.go
+++ /dev/null
@@ -1,317 +0,0 @@
-package sns_test
-
-var TestListTopicsXmlOK = `
-<?xml version="1.0"?>
-<ListTopicsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ListTopicsResult>
- <Topics>
- <member>
- <TopicArn>arn:aws:sns:us-west-1:331995417492:Transcoding</TopicArn>
- </member>
- </Topics>
- </ListTopicsResult>
- <ResponseMetadata>
- <RequestId>bd10b26c-e30e-11e0-ba29-93c3aca2f103</RequestId>
- </ResponseMetadata>
-</ListTopicsResponse>
-`
-
-var TestCreateTopicXmlOK = `
-<?xml version="1.0"?>
-<CreateTopicResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <CreateTopicResult>
- <TopicArn>arn:aws:sns:us-east-1:123456789012:My-Topic</TopicArn>
- </CreateTopicResult>
- <ResponseMetadata>
- <RequestId>a8dec8b3-33a4-11df-8963-01868b7c937a</RequestId>
- </ResponseMetadata>
-</CreateTopicResponse>
-`
-
-var TestDeleteTopicXmlOK = `
-<DeleteTopicResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>f3aa9ac9-3c3d-11df-8235-9dab105e9c32</RequestId>
- </ResponseMetadata>
-</DeleteTopicResponse>
-`
-
-var TestListSubscriptionsXmlOK = `
-<ListSubscriptionsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ListSubscriptionsResult>
- <Subscriptions>
- <member>
- <TopicArn>arn:aws:sns:us-east-1:698519295917:My-Topic</TopicArn>
- <Protocol>email</Protocol>
- <SubscriptionArn>arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca</SubscriptionArn>
- <Owner>123456789012</Owner>
- <Endpoint>example@amazon.com</Endpoint>
- </member>
- </Subscriptions>
- </ListSubscriptionsResult>
- <ResponseMetadata>
- <RequestId>384ac68d-3775-11df-8963-01868b7c937a</RequestId>
- </ResponseMetadata>
-</ListSubscriptionsResponse>
-`
-
-var TestGetTopicAttributesXmlOK = `
-<GetTopicAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <GetTopicAttributesResult>
- <Attributes>
- <entry>
- <key>Owner</key>
- <value>123456789012</value>
- </entry>
- <entry>
- <key>Policy</key>
- <value>{"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}</value>
- </entry>
- <entry>
- <key>TopicArn</key>
- <value>arn:aws:sns:us-east-1:123456789012:My-Topic</value>
- </entry>
- </Attributes>
- </GetTopicAttributesResult>
- <ResponseMetadata>
- <RequestId>057f074c-33a7-11df-9540-99d0768312d3</RequestId>
- </ResponseMetadata>
-</GetTopicAttributesResponse>
-`
-
-var TestPublishXmlOK = `
-<PublishResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <PublishResult>
- <MessageId>94f20ce6-13c5-43a0-9a9e-ca52d816e90b</MessageId>
- </PublishResult>
- <ResponseMetadata>
- <RequestId>f187a3c1-376f-11df-8963-01868b7c937a</RequestId>
- </ResponseMetadata>
-</PublishResponse>
-`
-
-var TestSetTopicAttributesXmlOK = `
-<SetTopicAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>a8763b99-33a7-11df-a9b7-05d48da6f042</RequestId>
- </ResponseMetadata>
-</SetTopicAttributesResponse>
-`
-
-var TestSubscribeXmlOK = `
-<SubscribeResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <SubscribeResult>
- <SubscriptionArn>pending confirmation</SubscriptionArn>
- </SubscribeResult>
- <ResponseMetadata>
- <RequestId>a169c740-3766-11df-8963-01868b7c937a</RequestId>
- </ResponseMetadata>
-</SubscribeResponse>
-`
-
-var TestUnsubscribeXmlOK = `
-<UnsubscribeResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>18e0ac39-3776-11df-84c0-b93cc1666b84</RequestId>
- </ResponseMetadata>
-</UnsubscribeResponse>
-`
-
-var TestConfirmSubscriptionXmlOK = `
-<ConfirmSubscriptionResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ConfirmSubscriptionResult>
- <SubscriptionArn>arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca</SubscriptionArn>
- </ConfirmSubscriptionResult>
- <ResponseMetadata>
- <RequestId>7a50221f-3774-11df-a9b7-05d48da6f042</RequestId>
- </ResponseMetadata>
-</ConfirmSubscriptionResponse>
-`
-
-var TestAddPermissionXmlOK = `
-<AddPermissionResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>6a213e4e-33a8-11df-9540-99d0768312d3</RequestId>
- </ResponseMetadata>
-</AddPermissionResponse>
-`
-
-var TestRemovePermissionXmlOK = `
-<RemovePermissionResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>d170b150-33a8-11df-995a-2d6fbe836cc1</RequestId>
- </ResponseMetadata>
-</RemovePermissionResponse>
-`
-
-var TestListSubscriptionsByTopicXmlOK = `
-<ListSubscriptionsByTopicResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ListSubscriptionsByTopicResult>
- <Subscriptions>
- <member>
- <TopicArn>arn:aws:sns:us-east-1:123456789012:My-Topic</TopicArn>
- <Protocol>email</Protocol>
- <SubscriptionArn>arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca</SubscriptionArn>
- <Owner>123456789012</Owner>
- <Endpoint>example@amazon.com</Endpoint>
- </member>
- </Subscriptions>
- </ListSubscriptionsByTopicResult>
- <ResponseMetadata>
- <RequestId>b9275252-3774-11df-9540-99d0768312d3</RequestId>
- </ResponseMetadata>
-</ListSubscriptionsByTopicResponse>
-`
-
-var TestCreatePlatformApplicationXmlOK = `
-<CreatePlatformApplicationResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <CreatePlatformApplicationResult>
- <PlatformApplicationArn>arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp</PlatformApplicationArn>
- </CreatePlatformApplicationResult>
- <ResponseMetadata>
- <RequestId>b6f0e78b-e9d4-5a0e-b973-adc04e8a4ff9</RequestId>
- </ResponseMetadata>
-</CreatePlatformApplicationResponse>
-`
-
-var TestCreatePlatformEndpointXmlOK = `
-<CreatePlatformEndpointResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <CreatePlatformEndpointResult>
- <EndpointArn>arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3</EndpointArn>
- </CreatePlatformEndpointResult>
- <ResponseMetadata>
- <RequestId>6613341d-3e15-53f7-bf3c-7e56994ba278</RequestId>
- </ResponseMetadata>
-</CreatePlatformEndpointResponse>
-`
-
-var DeleteEndpointXmlOK = `
-<DeleteEndpointResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>c1d2b191-353c-5a5f-8969-fbdd3900afa8</RequestId>
- </ResponseMetadata>
-</DeleteEndpointResponse>
-`
-
-var TestDeletePlatformApplicationXmlOK = `
-<DeletePlatformApplicationResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>097dac18-7a77-5823-a8dd-e65476dcb037</RequestId>
- </ResponseMetadata>
-</DeletePlatformApplicationResponse>
-`
-
-var TestGetEndpointAttributesXmlOK = `
-<GetEndpointAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <GetEndpointAttributesResult>
- <Attributes>
- <entry>
- <key>Enabled</key>
- <value>true</value>
- </entry>
- <entry>
- <key>CustomUserData</key>
- <value>UserId=01234567</value>
- </entry>
- <entry>
- <key>Token</key>
- <value>APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE</value>
- </entry>
- </Attributes>
- </GetEndpointAttributesResult>
- <ResponseMetadata>
- <RequestId>6c725a19-a142-5b77-94f9-1055a9ea04e7</RequestId>
- </ResponseMetadata>
-</GetEndpointAttributesResponse>
-`
-
-var TestGetPlatformApplicationAttributesXmlOK = `
-<GetPlatformApplicationAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <GetPlatformApplicationAttributesResult>
- <Attributes>
- <entry>
- <key>AllowEndpointPolicies</key>
- <value>false</value>
- </entry>
- </Attributes>
- </GetPlatformApplicationAttributesResult>
- <ResponseMetadata>
- <RequestId>74848df2-87f6-55ed-890c-c7be80442462</RequestId>
- </ResponseMetadata>
-</GetPlatformApplicationAttributesResponse>
-`
-
-var TestListEndpointsByPlatformApplicationXmlOK = `
-<ListEndpointsByPlatformApplicationResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ListEndpointsByPlatformApplicationResult>
- <Endpoints>
- <member>
- <EndpointArn>arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3</EndpointArn>
- <Attributes>
- <entry>
- <key>Enabled</key>
- <value>true</value>
- </entry>
- <entry>
- <key>CustomUserData</key>
- <value>UserId=27576823</value>
- </entry>
- <entry>
- <key>Token</key>
- <value>APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE</value>
- </entry>
- </Attributes>
- </member>
- </Endpoints>
- </ListEndpointsByPlatformApplicationResult>
- <ResponseMetadata>
- <RequestId>9a48768c-dac8-5a60-aec0-3cc27ea08d96</RequestId>
- </ResponseMetadata>
-</ListEndpointsByPlatformApplicationResponse>
-`
-
-var TestListPlatformApplicationsXmlOK = `
-<ListPlatformApplicationsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ListPlatformApplicationsResult>
- <PlatformApplications>
- <member>
- <PlatformApplicationArn>arn:aws:sns:us-west-2:123456789012:app/APNS_SANDBOX/apnspushapp</PlatformApplicationArn>
- <Attributes>
- <entry>
- <key>AllowEndpointPolicies</key>
- <value>false</value>
- </entry>
- </Attributes>
- </member>
- <member>
- <PlatformApplicationArn>arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp</PlatformApplicationArn>
- <Attributes>
- <entry>
- <key>AllowEndpointPolicies</key>
- <value>false</value>
- </entry>
- </Attributes>
- </member>
- </PlatformApplications>
- </ListPlatformApplicationsResult>
- <ResponseMetadata>
- <RequestId>315a335e-85d8-52df-9349-791283cbb529</RequestId>
- </ResponseMetadata>
-</ListPlatformApplicationsResponse>
-`
-
-var TestSetEndpointAttributesXmlOK = `
-<SetEndpointAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>2fe0bfc7-3e85-5ee5-a9e2-f58b35e85f6a</RequestId>
- </ResponseMetadata>
-</SetEndpointAttributesResponse>
-`
-
-var TestSetPlatformApplicationAttributesXmlOK = `
-<SetPlatformApplicationAttributesResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
- <ResponseMetadata>
- <RequestId>cf577bcc-b3dc-5463-88f1-3180b9412395</RequestId>
- </ResponseMetadata>
-</SetPlatformApplicationAttributesResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/exp/sns/sign.go b/vendor/github.com/goamz/goamz/exp/sns/sign.go
deleted file mode 100644
index 0c35f05ae..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/sign.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package sns
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "github.com/goamz/goamz/aws"
- "sort"
- "strings"
-)
-
-var b64 = base64.StdEncoding
-
-/*
-func sign(auth aws.Auth, method, path string, params url.Values, headers http.Header) {
- var host string
- for k, v := range headers {
- k = strings.ToLower(k)
- switch k {
- case "host":
- host = v[0]
- }
- }
-
- params["AWSAccessKeyId"] = []string{auth.AccessKey}
- params["SignatureVersion"] = []string{"2"}
- params["SignatureMethod"] = []string{"HmacSHA256"}
- if auth.Token() != "" {
- params["SecurityToken"] = auth.Token()
- }
-
- var sarry []string
- for k, v := range params {
- sarry = append(sarry, aws.Encode(k) + "=" + aws.Encode(v[0]))
- }
-
- sort.StringSlice(sarry).Sort()
- joined := strings.Join(sarry, "&")
-
- payload := strings.Join([]string{method, host, "/", joined}, "\n")
- hash := hmac.NewSHA256([]byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum())
-
- params["Signature"] = []string{"AWS " + string(signature)}
- println("Payload:", payload)
- println("Signature:", strings.Join(params["Signature"], "|"))
-}*/
-
-func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
- params["AWSAccessKeyId"] = auth.AccessKey
- if auth.Token() != "" {
- params["SecurityToken"] = auth.Token()
- }
- params["SignatureVersion"] = "2"
- params["SignatureMethod"] = "HmacSHA256"
-
- var sarray []string
- for k, v := range params {
- sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
- }
- sort.StringSlice(sarray).Sort()
- joined := strings.Join(sarray, "&")
- payload := method + "\n" + host + "\n" + path + "\n" + joined
- hash := hmac.New(sha256.New, []byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- params["Signature"] = string(signature)
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/sns.go b/vendor/github.com/goamz/goamz/exp/sns/sns.go
deleted file mode 100644
index 4d4622211..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/sns.go
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// goamz - Go packages to interact with the Amazon Web Services.
-//
-// https://wiki.ubuntu.com/goamz
-//
-// Copyright (c) 2011 Memeo Inc.
-//
-// Written by Prudhvi Krishna Surapaneni <me@prudhvi.net>
-
-// This package is in an experimental state, and does not currently
-// follow conventions and style of the rest of goamz or common
-// Go conventions. It must be polished before it's considered a
-// first-class package in goamz.
-package sns
-
-// BUG(niemeyer): Package needs documentation.
-
-import (
- "encoding/xml"
- "net/http"
- "net/url"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-// The SNS type encapsulates operation with an SNS region.
-type SNS struct {
- aws.Auth
- aws.Region
- private byte // Reserve the right of using private data.
-}
-
-type AttributeEntry struct {
- Key string `xml:"key"`
- Value string `xml:"value"`
-}
-
-type ResponseMetadata struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
- BoxUsage float64 `xml:"ResponseMetadata>BoxUsage"`
-}
-
-func New(auth aws.Auth, region aws.Region) *SNS {
- return &SNS{auth, region, 0}
-}
-
-func makeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-type Error struct {
- StatusCode int
- Code string
- Message string
- RequestId string
-}
-
-func (err *Error) Error() string {
- return err.Message
-}
-
-type xmlErrors struct {
- RequestId string
- Errors []Error `xml:"Errors>Error"`
-}
-
-func (sns *SNS) query(params map[string]string, resp interface{}) error {
- params["Timestamp"] = time.Now().UTC().Format(time.RFC3339)
- u, err := url.Parse(sns.Region.SNSEndpoint)
- if err != nil {
- return err
- }
-
- sign(sns.Auth, "GET", "/", params, u.Host)
- u.RawQuery = multimap(params).Encode()
- r, err := http.Get(u.String())
- if err != nil {
- return err
- }
- defer r.Body.Close()
-
- if r.StatusCode != 200 {
- return buildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-func buildError(r *http.Response) error {
- errors := xmlErrors{}
- xml.NewDecoder(r.Body).Decode(&errors)
- var err Error
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/sns_test.go b/vendor/github.com/goamz/goamz/exp/sns/sns_test.go
deleted file mode 100644
index 054db13d3..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/sns_test.go
+++ /dev/null
@@ -1,455 +0,0 @@
-package sns_test
-
-import (
- "testing"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/exp/sns"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- sns *sns.SNS
-}
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.sns = sns.New(auth, aws.Region{SNSEndpoint: testServer.URL})
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestListTopicsOK(c *C) {
- testServer.Response(200, nil, TestListTopicsXmlOK)
-
- resp, err := s.sns.ListTopics(nil)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.Topics[0].SNS, Equals, s.sns)
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "bd10b26c-e30e-11e0-ba29-93c3aca2f103")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestCreateTopic(c *C) {
- testServer.Response(200, nil, TestCreateTopicXmlOK)
-
- resp, err := s.sns.CreateTopic("My-Topic")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.Topic.SNS, Equals, s.sns)
- c.Assert(resp.Topic.TopicArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic")
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "a8dec8b3-33a4-11df-8963-01868b7c937a")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestDeleteTopic(c *C) {
- testServer.Response(200, nil, TestDeleteTopicXmlOK)
-
- t := sns.Topic{s.sns, "arn:aws:sns:us-east-1:123456789012:My-Topic"}
- resp, err := t.Delete()
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "f3aa9ac9-3c3d-11df-8235-9dab105e9c32")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestListSubscriptions(c *C) {
- testServer.Response(200, nil, TestListSubscriptionsXmlOK)
-
- resp, err := s.sns.ListSubscriptions(nil)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.Subscriptions), Not(Equals), 0)
- c.Assert(resp.Subscriptions[0].Protocol, Equals, "email")
- c.Assert(resp.Subscriptions[0].Endpoint, Equals, "example@amazon.com")
- c.Assert(resp.Subscriptions[0].SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca")
- c.Assert(resp.Subscriptions[0].TopicArn, Equals, "arn:aws:sns:us-east-1:698519295917:My-Topic")
- c.Assert(resp.Subscriptions[0].Owner, Equals, "123456789012")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestGetTopicAttributes(c *C) {
- testServer.Response(200, nil, TestGetTopicAttributesXmlOK)
-
- resp, err := s.sns.GetTopicAttributes("arn:aws:sns:us-east-1:123456789012:My-Topic")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.Attributes), Not(Equals), 0)
- c.Assert(resp.Attributes[0].Key, Equals, "Owner")
- c.Assert(resp.Attributes[0].Value, Equals, "123456789012")
- c.Assert(resp.Attributes[1].Key, Equals, "Policy")
- c.Assert(resp.Attributes[1].Value, Equals, `{"Version":"2008-10-17","Id":"us-east-1/698519295917/test__default_policy_ID","Statement" : [{"Effect":"Allow","Sid":"us-east-1/698519295917/test__default_statement_ID","Principal" : {"AWS": "*"},"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],"Resource":"arn:aws:sns:us-east-1:698519295917:test","Condition" : {"StringLike" : {"AWS:SourceArn": "arn:aws:*:*:698519295917:*"}}}]}`)
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "057f074c-33a7-11df-9540-99d0768312d3")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestPublish(c *C) {
- testServer.Response(200, nil, TestPublishXmlOK)
-
- pubOpt := &sns.PublishOpt{"foobar", "", "subject", "arn:aws:sns:us-east-1:123456789012:My-Topic"}
- resp, err := s.sns.Publish(pubOpt)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.MessageId, Equals, "94f20ce6-13c5-43a0-9a9e-ca52d816e90b")
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "f187a3c1-376f-11df-8963-01868b7c937a")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSetTopicAttributes(c *C) {
- testServer.Response(200, nil, TestSetTopicAttributesXmlOK)
-
- resp, err := s.sns.SetTopicAttributes("DisplayName", "MyTopicName", "arn:aws:sns:us-east-1:123456789012:My-Topic")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "a8763b99-33a7-11df-a9b7-05d48da6f042")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSubscribe(c *C) {
- testServer.Response(200, nil, TestSubscribeXmlOK)
-
- resp, err := s.sns.Subscribe("example@amazon.com", "email", "arn:aws:sns:us-east-1:123456789012:My-Topic")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.SubscriptionArn, Equals, "pending confirmation")
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "a169c740-3766-11df-8963-01868b7c937a")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestUnsubscribe(c *C) {
- testServer.Response(200, nil, TestUnsubscribeXmlOK)
-
- resp, err := s.sns.Unsubscribe("arn:aws:sns:us-east-1:123456789012:My-Topic:a169c740-3766-11df-8963-01868b7c937a")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "18e0ac39-3776-11df-84c0-b93cc1666b84")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestConfirmSubscription(c *C) {
- testServer.Response(200, nil, TestConfirmSubscriptionXmlOK)
-
- opt := &sns.ConfirmSubscriptionOpt{"", "51b2ff3edb475b7d91550e0ab6edf0c1de2a34e6ebaf6", "arn:aws:sns:us-east-1:123456789012:My-Topic"}
- resp, err := s.sns.ConfirmSubscription(opt)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca")
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "7a50221f-3774-11df-a9b7-05d48da6f042")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestAddPermission(c *C) {
- testServer.Response(200, nil, TestAddPermissionXmlOK)
- perm := make([]sns.Permission, 2)
- perm[0].ActionName = "Publish"
- perm[1].ActionName = "GetTopicAttributes"
- perm[0].AccountId = "987654321000"
- perm[1].AccountId = "876543210000"
-
- resp, err := s.sns.AddPermission(perm, "NewPermission", "arn:aws:sns:us-east-1:123456789012:My-Topic")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.RequestId, Equals, "6a213e4e-33a8-11df-9540-99d0768312d3")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestRemovePermission(c *C) {
- testServer.Response(200, nil, TestRemovePermissionXmlOK)
-
- resp, err := s.sns.RemovePermission("NewPermission", "arn:aws:sns:us-east-1:123456789012:My-Topic")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.RequestId, Equals, "d170b150-33a8-11df-995a-2d6fbe836cc1")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestListSubscriptionByTopic(c *C) {
- testServer.Response(200, nil, TestListSubscriptionsByTopicXmlOK)
-
- opt := &sns.ListSubscriptionByTopicOpt{"", "arn:aws:sns:us-east-1:123456789012:My-Topic"}
- resp, err := s.sns.ListSubscriptionByTopic(opt)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.Subscriptions), Not(Equals), 0)
- c.Assert(resp.Subscriptions[0].TopicArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic")
- c.Assert(resp.Subscriptions[0].SubscriptionArn, Equals, "arn:aws:sns:us-east-1:123456789012:My-Topic:80289ba6-0fd4-4079-afb4-ce8c8260f0ca")
- c.Assert(resp.Subscriptions[0].Owner, Equals, "123456789012")
- c.Assert(resp.Subscriptions[0].Endpoint, Equals, "example@amazon.com")
- c.Assert(resp.Subscriptions[0].Protocol, Equals, "email")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestCreatePlatformApplication(c *C) {
- testServer.Response(200, nil, TestCreatePlatformApplicationXmlOK)
-
- attrs := []sns.AttributeEntry{
- sns.AttributeEntry{Key: "PlatformCredential", Value: "AIzaSyClE2lcV2zEKTLYYo645zfk2jhQPFeyxDo"},
- sns.AttributeEntry{Key: "PlatformPrincipal", Value: "There is no principal for GCM"},
- }
- opt := &sns.PlatformApplicationOpt{Name: "gcmpushapp", Platform: "GCM", Attributes: attrs}
- resp, err := s.sns.CreatePlatformApplication(opt)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.PlatformApplicationArn, Equals, "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp")
- c.Assert(resp.RequestId, Equals, "b6f0e78b-e9d4-5a0e-b973-adc04e8a4ff9")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestCreatePlatformEndpoint(c *C) {
- testServer.Response(200, nil, TestCreatePlatformEndpointXmlOK)
-
- opt := &sns.PlatformEndpointOpt{PlatformApplicationArn: "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp",
- CustomUserData: "UserId=27576823", Token: "APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE"}
-
- resp, err := s.sns.CreatePlatformEndpoint(opt)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.EndpointArn, Equals, "arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3")
- c.Assert(resp.RequestId, Equals, "6613341d-3e15-53f7-bf3c-7e56994ba278")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestDeleteEndpoint(c *C) {
- testServer.Response(200, nil, DeleteEndpointXmlOK)
-
- resp, err := s.sns.DeleteEndpoint("arn:aws:sns:us-west-2:123456789012:endpoint/GCM%/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.RequestId, Equals, "c1d2b191-353c-5a5f-8969-fbdd3900afa8")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestDeletePlatformApplication(c *C) {
- testServer.Response(200, nil, TestDeletePlatformApplicationXmlOK)
-
- resp, err := s.sns.DeletePlatformApplication("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.RequestId, Equals, "097dac18-7a77-5823-a8dd-e65476dcb037")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestGetEndpointAttributes(c *C) {
- testServer.Response(200, nil, TestGetEndpointAttributesXmlOK)
-
- resp, err := s.sns.GetEndpointAttributes("arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.Attributes), Equals, 3)
- c.Assert(resp.Attributes[0].Key, Equals, "Enabled")
- c.Assert(resp.Attributes[0].Value, Equals, "true")
-
- c.Assert(resp.Attributes[1].Key, Equals, "CustomUserData")
- c.Assert(resp.Attributes[1].Value, Equals, "UserId=01234567")
-
- c.Assert(resp.Attributes[2].Key, Equals, "Token")
- c.Assert(resp.Attributes[2].Value, Equals, "APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE")
-
- c.Assert(resp.RequestId, Equals, "6c725a19-a142-5b77-94f9-1055a9ea04e7")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestGetPlatformApplicationAttributes(c *C) {
- testServer.Response(200, nil, TestGetPlatformApplicationAttributesXmlOK)
-
- resp, err := s.sns.GetPlatformApplicationAttributes("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp", "")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.Attributes), Not(Equals), 0)
- c.Assert(resp.Attributes[0].Key, Equals, "AllowEndpointPolicies")
- c.Assert(resp.Attributes[0].Value, Equals, "false")
- c.Assert(resp.RequestId, Equals, "74848df2-87f6-55ed-890c-c7be80442462")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestListEndpointsByPlatformApplication(c *C) {
- testServer.Response(200, nil, TestListEndpointsByPlatformApplicationXmlOK)
-
- resp, err := s.sns.ListEndpointsByPlatformApplication("arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp", "")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.Endpoints), Not(Equals), 0)
- c.Assert(resp.Endpoints[0].EndpointArn, Equals, "arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3")
- c.Assert(len(resp.Endpoints[0].Attributes), Equals, 3)
- c.Assert(resp.Endpoints[0].Attributes[0].Key, Equals, "Enabled")
- c.Assert(resp.Endpoints[0].Attributes[0].Value, Equals, "true")
- c.Assert(resp.Endpoints[0].Attributes[1].Key, Equals, "CustomUserData")
- c.Assert(resp.Endpoints[0].Attributes[1].Value, Equals, "UserId=27576823")
- c.Assert(resp.Endpoints[0].Attributes[2].Key, Equals, "Token")
- c.Assert(resp.Endpoints[0].Attributes[2].Value, Equals, "APA91bGi7fFachkC1xjlqT66VYEucGHochmf1VQAr9k...jsM0PKPxKhddCzx6paEsyay9Zn3D4wNUJb8m6HZrBEXAMPLE")
-
- c.Assert(resp.RequestId, Equals, "9a48768c-dac8-5a60-aec0-3cc27ea08d96")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestListPlatformApplications(c *C) {
- testServer.Response(200, nil, TestListPlatformApplicationsXmlOK)
-
- resp, err := s.sns.ListPlatformApplications("")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.PlatformApplications), Not(Equals), 0)
-
- c.Assert(resp.PlatformApplications[0].PlatformApplicationArn, Equals, "arn:aws:sns:us-west-2:123456789012:app/APNS_SANDBOX/apnspushapp")
- c.Assert(len(resp.PlatformApplications[0].Attributes), Equals, 1)
- c.Assert(resp.PlatformApplications[0].Attributes[0].Key, Equals, "AllowEndpointPolicies")
- c.Assert(resp.PlatformApplications[0].Attributes[0].Value, Equals, "false")
-
- c.Assert(resp.PlatformApplications[1].PlatformApplicationArn, Equals, "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp")
- c.Assert(len(resp.PlatformApplications[1].Attributes), Equals, 1)
- c.Assert(resp.PlatformApplications[1].Attributes[0].Key, Equals, "AllowEndpointPolicies")
- c.Assert(resp.PlatformApplications[1].Attributes[0].Value, Equals, "false")
-
- c.Assert(resp.RequestId, Equals, "315a335e-85d8-52df-9349-791283cbb529")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSetEndpointAttributes(c *C) {
- testServer.Response(200, nil, TestSetEndpointAttributesXmlOK)
-
- attrs := []sns.AttributeEntry{
- sns.AttributeEntry{Key: "CustomUserData", Value: "My custom userdata"},
- }
-
- opts := &sns.SetEndpointAttributesOpt{
- EndpointArn: "arn:aws:sns:us-west-2:123456789012:endpoint/GCM/gcmpushapp/5e3e9847-3183-3f18-a7e8-671c3a57d4b3",
- Attributes: attrs}
-
- resp, err := s.sns.SetEndpointAttributes(opts)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.RequestId, Equals, "2fe0bfc7-3e85-5ee5-a9e2-f58b35e85f6a")
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSetPlatformApplicationAttributes(c *C) {
- testServer.Response(200, nil, TestSetPlatformApplicationAttributesXmlOK)
-
- attrs := []sns.AttributeEntry{
- sns.AttributeEntry{Key: "EventEndpointCreated", Value: "arn:aws:sns:us-west-2:123456789012:topicarn"},
- }
-
- opts := &sns.SetPlatformApplicationAttributesOpt{
- PlatformApplicationArn: "arn:aws:sns:us-west-2:123456789012:app/GCM/gcmpushapp",
- Attributes: attrs}
-
- resp, err := s.sns.SetPlatformApplicationAttributes(opts)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.RequestId, Equals, "cf577bcc-b3dc-5463-88f1-3180b9412395")
-
- c.Assert(err, IsNil)
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/subscription.go b/vendor/github.com/goamz/goamz/exp/sns/subscription.go
deleted file mode 100644
index cbfef8b2c..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/subscription.go
+++ /dev/null
@@ -1,165 +0,0 @@
-package sns
-
-type Subscription struct {
- Endpoint string
- Owner string
- Protocol string
- SubscriptionArn string
- TopicArn string
-}
-
-type ListSubscriptionsResp struct {
- Subscriptions []Subscription `xml:"ListSubscriptionsResult>Subscriptions>member"`
- NextToken string
- ResponseMetadata
-}
-
-type PublishOpt struct {
- Message string
- MessageStructure string
- Subject string
- TopicArn string
- TargetArn string
-}
-
-type PublishResp struct {
- MessageId string `xml:"PublishResult>MessageId"`
- ResponseMetadata
-}
-
-type SubscribeResponse struct {
- SubscriptionArn string `xml:"SubscribeResult>SubscriptionArn"`
- ResponseMetadata
-}
-
-type UnsubscribeResponse struct {
- ResponseMetadata
-}
-
-type ConfirmSubscriptionResponse struct {
- SubscriptionArn string `xml:"ConfirmSubscriptionResult>SubscriptionArn"`
- ResponseMetadata
-}
-
-type ConfirmSubscriptionOpt struct {
- AuthenticateOnUnsubscribe string
- Token string
- TopicArn string
-}
-
-type ListSubscriptionByTopicResponse struct {
- Subscriptions []Subscription `xml:"ListSubscriptionsByTopicResult>Subscriptions>member"`
- ResponseMetadata
-}
-
-type ListSubscriptionByTopicOpt struct {
- NextToken string
- TopicArn string
-}
-
-// Publish
-//
-// See http://goo.gl/AY2D8 for more details.
-func (sns *SNS) Publish(options *PublishOpt) (resp *PublishResp, err error) {
- resp = &PublishResp{}
- params := makeParams("Publish")
-
- if options.Subject != "" {
- params["Subject"] = options.Subject
- }
-
- if options.MessageStructure != "" {
- params["MessageStructure"] = options.MessageStructure
- }
-
- if options.Message != "" {
- params["Message"] = options.Message
- }
-
- if options.TopicArn != "" {
- params["TopicArn"] = options.TopicArn
- }
-
- if options.TargetArn != "" {
- params["TargetArn"] = options.TargetArn
- }
-
- err = sns.query(params, resp)
- return
-}
-
-// Subscribe
-//
-// See http://goo.gl/c3iGS for more details.
-func (sns *SNS) Subscribe(Endpoint, Protocol, TopicArn string) (resp *SubscribeResponse, err error) {
- resp = &SubscribeResponse{}
- params := makeParams("Subscribe")
-
- params["Endpoint"] = Endpoint
- params["Protocol"] = Protocol
- params["TopicArn"] = TopicArn
-
- err = sns.query(params, resp)
- return
-}
-
-// Unsubscribe
-//
-// See http://goo.gl/4l5Ge for more details.
-func (sns *SNS) Unsubscribe(SubscriptionArn string) (resp *UnsubscribeResponse, err error) {
- resp = &UnsubscribeResponse{}
- params := makeParams("Unsubscribe")
-
- params["SubscriptionArn"] = SubscriptionArn
-
- err = sns.query(params, resp)
- return
-}
-
-// ConfirmSubscription
-//
-// See http://goo.gl/3hXzH for more details.
-func (sns *SNS) ConfirmSubscription(options *ConfirmSubscriptionOpt) (resp *ConfirmSubscriptionResponse, err error) {
- resp = &ConfirmSubscriptionResponse{}
- params := makeParams("ConfirmSubscription")
-
- if options.AuthenticateOnUnsubscribe != "" {
- params["AuthenticateOnUnsubscribe"] = options.AuthenticateOnUnsubscribe
- }
-
- params["Token"] = options.Token
- params["TopicArn"] = options.TopicArn
-
- err = sns.query(params, resp)
- return
-}
-
-// ListSubscriptions
-//
-// See http://goo.gl/k3aGn for more details.
-func (sns *SNS) ListSubscriptions(NextToken *string) (resp *ListSubscriptionsResp, err error) {
- resp = &ListSubscriptionsResp{}
- params := makeParams("ListSubscriptions")
- if NextToken != nil {
- params["NextToken"] = *NextToken
- }
- err = sns.query(params, resp)
- return
-}
-
-// ListSubscriptionByTopic
-//
-// See http://goo.gl/LaVcC for more details.
-func (sns *SNS) ListSubscriptionByTopic(options *ListSubscriptionByTopicOpt) (resp *ListSubscriptionByTopicResponse, err error) {
- resp = &ListSubscriptionByTopicResponse{}
- params := makeParams("ListSbubscriptionByTopic")
-
- if options.NextToken != "" {
- params["NextToken"] = options.NextToken
- }
-
- params["TopicArn"] = options.TopicArn
-
- err = sns.query(params, resp)
- return
-}
diff --git a/vendor/github.com/goamz/goamz/exp/sns/topic.go b/vendor/github.com/goamz/goamz/exp/sns/topic.go
deleted file mode 100644
index 601325ec9..000000000
--- a/vendor/github.com/goamz/goamz/exp/sns/topic.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package sns
-
-import (
- "errors"
-)
-
-type Topic struct {
- SNS *SNS
- TopicArn string
-}
-
-type ListTopicsResp struct {
- Topics []Topic `xml:"ListTopicsResult>Topics>member"`
- NextToken string
- ResponseMetadata
-}
-
-type CreateTopicResp struct {
- Topic Topic `xml:"CreateTopicResult"`
- ResponseMetadata
-}
-
-type DeleteTopicResp struct {
- ResponseMetadata
-}
-
-type GetTopicAttributesResp struct {
- Attributes []AttributeEntry `xml:"GetTopicAttributesResult>Attributes>entry"`
- ResponseMetadata
-}
-
-type SetTopicAttributesResponse struct {
- ResponseMetadata
-}
-
-// ListTopics
-//
-// See http://goo.gl/lfrMK for more details.
-func (sns *SNS) ListTopics(NextToken *string) (resp *ListTopicsResp, err error) {
- resp = &ListTopicsResp{}
- params := makeParams("ListTopics")
- if NextToken != nil {
- params["NextToken"] = *NextToken
- }
-
- err = sns.query(params, resp)
- for i, _ := range resp.Topics {
- resp.Topics[i].SNS = sns
- }
- return
-}
-
-// CreateTopic
-//
-// See http://goo.gl/m9aAt for more details.
-func (sns *SNS) CreateTopic(Name string) (resp *CreateTopicResp, err error) {
- resp = &CreateTopicResp{}
- params := makeParams("CreateTopic")
- params["Name"] = Name
- err = sns.query(params, resp)
- resp.Topic.SNS = sns
- return
-}
-
-// Delete
-//
-// Helper function for deleting a topic
-func (topic *Topic) Delete() (resp *DeleteTopicResp, err error) {
- resp = &DeleteTopicResp{}
- params := makeParams("DeleteTopic")
- params["TopicArn"] = topic.TopicArn
- err = topic.SNS.query(params, resp)
- return
-}
-
-// GetTopicAttributes
-//
-// See http://goo.gl/WXRoX for more details.
-func (sns *SNS) GetTopicAttributes(TopicArn string) (resp *GetTopicAttributesResp, err error) {
- resp = &GetTopicAttributesResp{}
- params := makeParams("GetTopicAttributes")
- params["TopicArn"] = TopicArn
- err = sns.query(params, resp)
- return
-}
-
-// SetTopicAttributes
-//
-// See http://goo.gl/oVYW7 for more details.
-func (sns *SNS) SetTopicAttributes(AttributeName, AttributeValue, TopicArn string) (resp *SetTopicAttributesResponse, err error) {
- resp = &SetTopicAttributesResponse{}
- params := makeParams("SetTopicAttributes")
-
- if AttributeName == "" || TopicArn == "" {
- return nil, errors.New("Invalid Attribute Name or TopicArn")
- }
-
- params["AttributeName"] = AttributeName
- params["AttributeValue"] = AttributeValue
- params["TopicArn"] = TopicArn
-
- err = sns.query(params, resp)
- return
-}
diff --git a/vendor/github.com/goamz/goamz/iam/iam.go b/vendor/github.com/goamz/goamz/iam/iam.go
deleted file mode 100644
index 7271f1bf6..000000000
--- a/vendor/github.com/goamz/goamz/iam/iam.go
+++ /dev/null
@@ -1,643 +0,0 @@
-// The iam package provides types and functions for interaction with the AWS
-// Identity and Access Management (IAM) service.
-package iam
-
-import (
- "encoding/xml"
- "net/http"
- "net/url"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-// The IAM type encapsulates operations operations with the IAM endpoint.
-type IAM struct {
- aws.Auth
- aws.Region
- httpClient *http.Client
-}
-
-// New creates a new IAM instance.
-func New(auth aws.Auth, region aws.Region) *IAM {
- return NewWithClient(auth, region, aws.RetryingClient)
-}
-
-func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *IAM {
- return &IAM{auth, region, httpClient}
-}
-
-func (iam *IAM) query(params map[string]string, resp interface{}) error {
- params["Version"] = "2010-05-08"
- params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
- endpoint, err := url.Parse(iam.IAMEndpoint)
- if err != nil {
- return err
- }
- sign(iam.Auth, "GET", "/", params, endpoint.Host)
- endpoint.RawQuery = multimap(params).Encode()
- r, err := iam.httpClient.Get(endpoint.String())
- if err != nil {
- return err
- }
- defer r.Body.Close()
- if r.StatusCode > 200 {
- return buildError(r)
- }
-
- return xml.NewDecoder(r.Body).Decode(resp)
-}
-
-func (iam *IAM) postQuery(params map[string]string, resp interface{}) error {
- endpoint, err := url.Parse(iam.IAMEndpoint)
- if err != nil {
- return err
- }
- params["Version"] = "2010-05-08"
- params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
- sign(iam.Auth, "POST", "/", params, endpoint.Host)
- encoded := multimap(params).Encode()
- body := strings.NewReader(encoded)
- req, err := http.NewRequest("POST", endpoint.String(), body)
- if err != nil {
- return err
- }
- req.Header.Set("Host", endpoint.Host)
- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
- req.Header.Set("Content-Length", strconv.Itoa(len(encoded)))
- r, err := http.DefaultClient.Do(req)
- if err != nil {
- return err
- }
- defer r.Body.Close()
- if r.StatusCode > 200 {
- return buildError(r)
- }
- return xml.NewDecoder(r.Body).Decode(resp)
-}
-
-func buildError(r *http.Response) error {
- var (
- err Error
- errors xmlErrors
- )
- xml.NewDecoder(r.Body).Decode(&errors)
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-// Response to a CreateUser request.
-//
-// See http://goo.gl/JS9Gz for more details.
-type CreateUserResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
- User User `xml:"CreateUserResult>User"`
-}
-
-// User encapsulates a user managed by IAM.
-//
-// See http://goo.gl/BwIQ3 for more details.
-type User struct {
- Arn string
- Path string
- Id string `xml:"UserId"`
- Name string `xml:"UserName"`
-}
-
-// CreateUser creates a new user in IAM.
-//
-// See http://goo.gl/JS9Gz for more details.
-func (iam *IAM) CreateUser(name, path string) (*CreateUserResp, error) {
- params := map[string]string{
- "Action": "CreateUser",
- "Path": path,
- "UserName": name,
- }
- resp := new(CreateUserResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response for GetUser requests.
-//
-// See http://goo.gl/ZnzRN for more details.
-type GetUserResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
- User User `xml:"GetUserResult>User"`
-}
-
-// GetUser gets a user from IAM.
-//
-// See http://goo.gl/ZnzRN for more details.
-func (iam *IAM) GetUser(name string) (*GetUserResp, error) {
- params := map[string]string{
- "Action": "GetUser",
- "UserName": name,
- }
- resp := new(GetUserResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteUser deletes a user from IAM.
-//
-// See http://goo.gl/jBuCG for more details.
-func (iam *IAM) DeleteUser(name string) (*SimpleResp, error) {
- params := map[string]string{
- "Action": "DeleteUser",
- "UserName": name,
- }
- resp := new(SimpleResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to a CreateGroup request.
-//
-// See http://goo.gl/n7NNQ for more details.
-type CreateGroupResp struct {
- Group Group `xml:"CreateGroupResult>Group"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// Group encapsulates a group managed by IAM.
-//
-// See http://goo.gl/ae7Vs for more details.
-type Group struct {
- Arn string
- Id string `xml:"GroupId"`
- Name string `xml:"GroupName"`
- Path string
-}
-
-// CreateGroup creates a new group in IAM.
-//
-// The path parameter can be used to identify which division or part of the
-// organization the user belongs to.
-//
-// If path is unset ("") it defaults to "/".
-//
-// See http://goo.gl/n7NNQ for more details.
-func (iam *IAM) CreateGroup(name string, path string) (*CreateGroupResp, error) {
- params := map[string]string{
- "Action": "CreateGroup",
- "GroupName": name,
- }
- if path != "" {
- params["Path"] = path
- }
- resp := new(CreateGroupResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to a ListGroups request.
-//
-// See http://goo.gl/W2TRj for more details.
-type GroupsResp struct {
- Groups []Group `xml:"ListGroupsResult>Groups>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// Groups list the groups that have the specified path prefix.
-//
-// The parameter pathPrefix is optional. If pathPrefix is "", all groups are
-// returned.
-//
-// See http://goo.gl/W2TRj for more details.
-func (iam *IAM) Groups(pathPrefix string) (*GroupsResp, error) {
- params := map[string]string{
- "Action": "ListGroups",
- }
- if pathPrefix != "" {
- params["PathPrefix"] = pathPrefix
- }
- resp := new(GroupsResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteGroup deletes a group from IAM.
-//
-// See http://goo.gl/d5i2i for more details.
-func (iam *IAM) DeleteGroup(name string) (*SimpleResp, error) {
- params := map[string]string{
- "Action": "DeleteGroup",
- "GroupName": name,
- }
- resp := new(SimpleResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to a CreateAccessKey request.
-//
-// See http://goo.gl/L46Py for more details.
-type CreateAccessKeyResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
- AccessKey AccessKey `xml:"CreateAccessKeyResult>AccessKey"`
-}
-
-// AccessKey encapsulates an access key generated for a user.
-//
-// See http://goo.gl/LHgZR for more details.
-type AccessKey struct {
- UserName string
- Id string `xml:"AccessKeyId"`
- Secret string `xml:"SecretAccessKey,omitempty"`
- Status string
-}
-
-// CreateAccessKey creates a new access key in IAM.
-//
-// See http://goo.gl/L46Py for more details.
-func (iam *IAM) CreateAccessKey(userName string) (*CreateAccessKeyResp, error) {
- params := map[string]string{
- "Action": "CreateAccessKey",
- "UserName": userName,
- }
- resp := new(CreateAccessKeyResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to AccessKeys request.
-//
-// See http://goo.gl/Vjozx for more details.
-type AccessKeysResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
- AccessKeys []AccessKey `xml:"ListAccessKeysResult>AccessKeyMetadata>member"`
-}
-
-// AccessKeys lists all acccess keys associated with a user.
-//
-// The userName parameter is optional. If set to "", the userName is determined
-// implicitly based on the AWS Access Key ID used to sign the request.
-//
-// See http://goo.gl/Vjozx for more details.
-func (iam *IAM) AccessKeys(userName string) (*AccessKeysResp, error) {
- params := map[string]string{
- "Action": "ListAccessKeys",
- }
- if userName != "" {
- params["UserName"] = userName
- }
- resp := new(AccessKeysResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteAccessKey deletes an access key from IAM.
-//
-// The userName parameter is optional. If set to "", the userName is determined
-// implicitly based on the AWS Access Key ID used to sign the request.
-//
-// See http://goo.gl/hPGhw for more details.
-func (iam *IAM) DeleteAccessKey(id, userName string) (*SimpleResp, error) {
- params := map[string]string{
- "Action": "DeleteAccessKey",
- "AccessKeyId": id,
- }
- if userName != "" {
- params["UserName"] = userName
- }
- resp := new(SimpleResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response to a GetUserPolicy request.
-//
-// See http://goo.gl/BH04O for more details.
-type GetUserPolicyResp struct {
- Policy UserPolicy `xml:"GetUserPolicyResult"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// UserPolicy encapsulates an IAM group policy.
-//
-// See http://goo.gl/C7hgS for more details.
-type UserPolicy struct {
- Name string `xml:"PolicyName"`
- UserName string `xml:"UserName"`
- Document string `xml:"PolicyDocument"`
-}
-
-// GetUserPolicy gets a user policy in IAM.
-//
-// See http://goo.gl/BH04O for more details.
-func (iam *IAM) GetUserPolicy(userName, policyName string) (*GetUserPolicyResp, error) {
- params := map[string]string{
- "Action": "GetUserPolicy",
- "UserName": userName,
- "PolicyName": policyName,
- }
- resp := new(GetUserPolicyResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
- return nil, nil
-}
-
-// PutUserPolicy creates a user policy in IAM.
-//
-// See http://goo.gl/ldCO8 for more details.
-func (iam *IAM) PutUserPolicy(userName, policyName, policyDocument string) (*SimpleResp, error) {
- params := map[string]string{
- "Action": "PutUserPolicy",
- "UserName": userName,
- "PolicyName": policyName,
- "PolicyDocument": policyDocument,
- }
- resp := new(SimpleResp)
- if err := iam.postQuery(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteUserPolicy deletes a user policy from IAM.
-//
-// See http://goo.gl/7Jncn for more details.
-func (iam *IAM) DeleteUserPolicy(userName, policyName string) (*SimpleResp, error) {
- params := map[string]string{
- "Action": "DeleteUserPolicy",
- "PolicyName": policyName,
- "UserName": userName,
- }
- resp := new(SimpleResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response for AddUserToGroup requests.
-//
-// See http://goo.gl/ZnzRN for more details.
-type AddUserToGroupResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// AddUserToGroup adds a user to a specific group
-//
-// See http://goo.gl/ZnzRN for more details.
-func (iam *IAM) AddUserToGroup(name, group string) (*AddUserToGroupResp, error) {
-
- params := map[string]string{
- "Action": "AddUserToGroup",
- "GroupName": group,
- "UserName": name}
- resp := new(AddUserToGroupResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response for a ListAccountAliases request.
-//
-// See http://goo.gl/MMN79v for more details.
-type ListAccountAliasesResp struct {
- AccountAliases []string `xml:"ListAccountAliasesResult>AccountAliases>member"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// ListAccountAliases lists the account aliases associated with the account
-//
-// See http://goo.gl/MMN79v for more details.
-func (iam *IAM) ListAccountAliases() (*ListAccountAliasesResp, error) {
- params := map[string]string{
- "Action": "ListAccountAliases",
- }
- resp := new(ListAccountAliasesResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response for a CreateAccountAlias request.
-//
-// See http://goo.gl/oU5C4H for more details.
-type CreateAccountAliasResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// CreateAccountAlias creates an alias for your AWS account.
-//
-// See http://goo.gl/oU5C4H for more details.
-func (iam *IAM) CreateAccountAlias(alias string) (*CreateAccountAliasResp, error) {
- params := map[string]string{
- "Action": "CreateAccountAlias",
- "AccountAlias": alias,
- }
- resp := new(CreateAccountAliasResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Response for a DeleteAccountAlias request.
-//
-// See http://goo.gl/hKalgg for more details.
-type DeleteAccountAliasResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DeleteAccountAlias deletes the specified AWS account alias.
-//
-// See http://goo.gl/hKalgg for more details.
-func (iam *IAM) DeleteAccountAlias(alias string) (*DeleteAccountAliasResp, error) {
- params := map[string]string{
- "Action": "DeleteAccountAlias",
- "AccountAlias": alias,
- }
- resp := new(DeleteAccountAliasResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-type SimpleResp struct {
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-type xmlErrors struct {
- Errors []Error `xml:"Error"`
-}
-
-// ServerCertificateMetadata represents a ServerCertificateMetadata object
-//
-// See http://goo.gl/Rfu7LD for more details.
-type ServerCertificateMetadata struct {
- Arn string `xml:"Arn"`
- Expiration time.Time `xml:"Expiration"`
- Path string `xml:"Path"`
- ServerCertificateId string `xml:"ServerCertificateId"`
- ServerCertificateName string `xml:"ServerCertificateName"`
- UploadDate time.Time `xml:"UploadDate"`
-}
-
-// UploadServerCertificateResponse wraps up for UploadServerCertificate request.
-//
-// See http://goo.gl/bomzce for more details.
-type UploadServerCertificateResponse struct {
- ServerCertificateMetadata ServerCertificateMetadata `xml:"UploadServerCertificateResult>ServerCertificateMetadata"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// UploadServerCertificateParams wraps up the params to be passed for the UploadServerCertificate request
-//
-// See http://goo.gl/bomzce for more details.
-type UploadServerCertificateParams struct {
- ServerCertificateName string
- PrivateKey string
- CertificateBody string
- CertificateChain string
- Path string
-}
-
-// UploadServerCertificate uploads a server certificate entity for the AWS account.
-//
-// Required Params: ServerCertificateName, PrivateKey, CertificateBody
-//
-// See http://goo.gl/bomzce for more details.
-func (iam *IAM) UploadServerCertificate(options *UploadServerCertificateParams) (
- *UploadServerCertificateResponse, error) {
- params := map[string]string{
- "Action": "UploadServerCertificate",
- "ServerCertificateName": options.ServerCertificateName,
- "PrivateKey": options.PrivateKey,
- "CertificateBody": options.CertificateBody,
- }
- if options.CertificateChain != "" {
- params["CertificateChain"] = options.CertificateChain
- }
- if options.Path != "" {
- params["Path"] = options.Path
- }
-
- resp := new(UploadServerCertificateResponse)
- if err := iam.postQuery(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ListServerCertificates lists all available certificates for the AWS account specified
-//
-// Required Params: None
-//
-// Optional Params: Marker, and, PathPrefix
-//
-// See http://goo.gl/bwn0Nb for specifics
-
-type ListServerCertificatesParams struct {
- Marker string
- PathPrefix string
-}
-
-type ListServerCertificatesResp struct {
- ServerCertificates []ServerCertificateMetadata `xml:"ListServerCertificatesResult>ServerCertificateMetadataList>member>ServerCertificateMetadata"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
- IsTruncated bool `xml:"ListServerCertificatesResult>IsTruncated"`
-}
-
-func (iam *IAM) ListServerCertificates(options *ListServerCertificatesParams) (
- *ListServerCertificatesResp, error) {
- params := map[string]string{
- "Action": "ListServerCertificates",
- }
-
- if options.Marker != "" {
- params["Marker"] = options.Marker
- }
-
- if options.PathPrefix != "" {
- params["PathPrefix"] = options.PathPrefix
- }
-
- resp := new(ListServerCertificatesResp)
- if err := iam.query(params, resp); err != nil {
- return nil, err
- }
-
- return resp, nil
-}
-
-// DeleteServerCertificate deletes the specified server certificate.
-//
-// See http://goo.gl/W4nmxQ for more details.
-func (iam *IAM) DeleteServerCertificate(serverCertificateName string) (*SimpleResp, error) {
- params := map[string]string{
- "Action": "DeleteServerCertificate",
- "ServerCertificateName": serverCertificateName,
- }
-
- resp := new(SimpleResp)
- if err := iam.postQuery(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// Error encapsulates an IAM error.
-type Error struct {
- // HTTP status code of the error.
- StatusCode int
-
- // AWS code of the error.
- Code string
-
- // Message explaining the error.
- Message string
-}
-
-func (e *Error) Error() string {
- var prefix string
- if e.Code != "" {
- prefix = e.Code + ": "
- }
- if prefix == "" && e.StatusCode > 0 {
- prefix = strconv.Itoa(e.StatusCode) + ": "
- }
- return prefix + e.Message
-}
diff --git a/vendor/github.com/goamz/goamz/iam/iam_test.go b/vendor/github.com/goamz/goamz/iam/iam_test.go
deleted file mode 100644
index e73935670..000000000
--- a/vendor/github.com/goamz/goamz/iam/iam_test.go
+++ /dev/null
@@ -1,450 +0,0 @@
-package iam_test
-
-import (
- "strings"
- "testing"
- "time"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/iam"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-type S struct {
- iam *iam.IAM
-}
-
-var _ = Suite(&S{})
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.iam = iam.NewWithClient(auth, aws.Region{IAMEndpoint: testServer.URL}, testutil.DefaultClient)
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestCreateUser(c *C) {
- testServer.Response(200, nil, CreateUserExample)
- resp, err := s.iam.CreateUser("Bob", "/division_abc/subdivision_xyz/")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "CreateUser")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(values.Get("Path"), Equals, "/division_abc/subdivision_xyz/")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
- expected := iam.User{
- Path: "/division_abc/subdivision_xyz/",
- Name: "Bob",
- Id: "AIDACKCEVSQ6C2EXAMPLE",
- Arn: "arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob",
- }
- c.Assert(resp.User, DeepEquals, expected)
-}
-
-func (s *S) TestCreateUserConflict(c *C) {
- testServer.Response(409, nil, DuplicateUserExample)
- resp, err := s.iam.CreateUser("Bob", "/division_abc/subdivision_xyz/")
- testServer.WaitRequest()
- c.Assert(resp, IsNil)
- c.Assert(err, NotNil)
- e, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(e.Message, Equals, "User with name Bob already exists.")
- c.Assert(e.Code, Equals, "EntityAlreadyExists")
-}
-
-func (s *S) TestGetUser(c *C) {
- testServer.Response(200, nil, GetUserExample)
- resp, err := s.iam.GetUser("Bob")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "GetUser")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
- expected := iam.User{
- Path: "/division_abc/subdivision_xyz/",
- Name: "Bob",
- Id: "AIDACKCEVSQ6C2EXAMPLE",
- Arn: "arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob",
- }
- c.Assert(resp.User, DeepEquals, expected)
-}
-
-func (s *S) TestDeleteUser(c *C) {
- testServer.Response(200, nil, RequestIdExample)
- resp, err := s.iam.DeleteUser("Bob")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "DeleteUser")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestCreateGroup(c *C) {
- testServer.Response(200, nil, CreateGroupExample)
- resp, err := s.iam.CreateGroup("Admins", "/admins/")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "CreateGroup")
- c.Assert(values.Get("GroupName"), Equals, "Admins")
- c.Assert(values.Get("Path"), Equals, "/admins/")
- c.Assert(err, IsNil)
- c.Assert(resp.Group.Path, Equals, "/admins/")
- c.Assert(resp.Group.Name, Equals, "Admins")
- c.Assert(resp.Group.Id, Equals, "AGPACKCEVSQ6C2EXAMPLE")
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestCreateGroupWithoutPath(c *C) {
- testServer.Response(200, nil, CreateGroupExample)
- _, err := s.iam.CreateGroup("Managers", "")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "CreateGroup")
- c.Assert(err, IsNil)
- _, ok := map[string][]string(values)["Path"]
- c.Assert(ok, Equals, false)
-}
-
-func (s *S) TestDeleteGroup(c *C) {
- testServer.Response(200, nil, RequestIdExample)
- resp, err := s.iam.DeleteGroup("Admins")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "DeleteGroup")
- c.Assert(values.Get("GroupName"), Equals, "Admins")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestListGroups(c *C) {
- testServer.Response(200, nil, ListGroupsExample)
- resp, err := s.iam.Groups("/division_abc/")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "ListGroups")
- c.Assert(values.Get("PathPrefix"), Equals, "/division_abc/")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
- expected := []iam.Group{
- {
- Path: "/division_abc/subdivision_xyz/",
- Name: "Admins",
- Id: "AGPACKCEVSQ6C2EXAMPLE",
- Arn: "arn:aws:iam::123456789012:group/Admins",
- },
- {
- Path: "/division_abc/subdivision_xyz/product_1234/engineering/",
- Name: "Test",
- Id: "AGP2MAB8DPLSRHEXAMPLE",
- Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test",
- },
- {
- Path: "/division_abc/subdivision_xyz/product_1234/",
- Name: "Managers",
- Id: "AGPIODR4TAW7CSEXAMPLE",
- Arn: "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers",
- },
- }
- c.Assert(resp.Groups, DeepEquals, expected)
-}
-
-func (s *S) TestListGroupsWithoutPathPrefix(c *C) {
- testServer.Response(200, nil, ListGroupsExample)
- _, err := s.iam.Groups("")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "ListGroups")
- c.Assert(err, IsNil)
- _, ok := map[string][]string(values)["PathPrefix"]
- c.Assert(ok, Equals, false)
-}
-
-func (s *S) TestCreateAccessKey(c *C) {
- testServer.Response(200, nil, CreateAccessKeyExample)
- resp, err := s.iam.CreateAccessKey("Bob")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "CreateAccessKey")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(err, IsNil)
- c.Assert(resp.AccessKey.UserName, Equals, "Bob")
- c.Assert(resp.AccessKey.Id, Equals, "AKIAIOSFODNN7EXAMPLE")
- c.Assert(resp.AccessKey.Secret, Equals, "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY")
- c.Assert(resp.AccessKey.Status, Equals, "Active")
-}
-
-func (s *S) TestDeleteAccessKey(c *C) {
- testServer.Response(200, nil, RequestIdExample)
- resp, err := s.iam.DeleteAccessKey("ysa8hasdhasdsi", "Bob")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "DeleteAccessKey")
- c.Assert(values.Get("AccessKeyId"), Equals, "ysa8hasdhasdsi")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestDeleteAccessKeyBlankUserName(c *C) {
- testServer.Response(200, nil, RequestIdExample)
- _, err := s.iam.DeleteAccessKey("ysa8hasdhasdsi", "")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "DeleteAccessKey")
- c.Assert(values.Get("AccessKeyId"), Equals, "ysa8hasdhasdsi")
- _, ok := map[string][]string(values)["UserName"]
- c.Assert(ok, Equals, false)
-}
-
-func (s *S) TestAccessKeys(c *C) {
- testServer.Response(200, nil, ListAccessKeyExample)
- resp, err := s.iam.AccessKeys("Bob")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "ListAccessKeys")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
- c.Assert(resp.AccessKeys, HasLen, 2)
- c.Assert(resp.AccessKeys[0].Id, Equals, "AKIAIOSFODNN7EXAMPLE")
- c.Assert(resp.AccessKeys[0].UserName, Equals, "Bob")
- c.Assert(resp.AccessKeys[0].Status, Equals, "Active")
- c.Assert(resp.AccessKeys[1].Id, Equals, "AKIAI44QH8DHBEXAMPLE")
- c.Assert(resp.AccessKeys[1].UserName, Equals, "Bob")
- c.Assert(resp.AccessKeys[1].Status, Equals, "Inactive")
-}
-
-func (s *S) TestAccessKeysBlankUserName(c *C) {
- testServer.Response(200, nil, ListAccessKeyExample)
- _, err := s.iam.AccessKeys("")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "ListAccessKeys")
- _, ok := map[string][]string(values)["UserName"]
- c.Assert(ok, Equals, false)
-}
-
-func (s *S) TestGetUserPolicy(c *C) {
- testServer.Response(200, nil, GetUserPolicyExample)
- resp, err := s.iam.GetUserPolicy("Bob", "AllAccessPolicy")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "GetUserPolicy")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(values.Get("PolicyName"), Equals, "AllAccessPolicy")
- c.Assert(err, IsNil)
- c.Assert(resp.Policy.UserName, Equals, "Bob")
- c.Assert(resp.Policy.Name, Equals, "AllAccessPolicy")
- c.Assert(strings.TrimSpace(resp.Policy.Document), Equals, `{"Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}`)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestPutUserPolicy(c *C) {
- document := `{
- "Statement": [
- {
- "Action": [
- "s3:*"
- ],
- "Effect": "Allow",
- "Resource": [
- "arn:aws:s3:::8shsns19s90ajahadsj/*",
- "arn:aws:s3:::8shsns19s90ajahadsj"
- ]
- }]
- }`
- testServer.Response(200, nil, RequestIdExample)
- resp, err := s.iam.PutUserPolicy("Bob", "AllAccessPolicy", document)
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.FormValue("Action"), Equals, "PutUserPolicy")
- c.Assert(req.FormValue("PolicyName"), Equals, "AllAccessPolicy")
- c.Assert(req.FormValue("UserName"), Equals, "Bob")
- c.Assert(req.FormValue("PolicyDocument"), Equals, document)
- c.Assert(req.FormValue("Version"), Equals, "2010-05-08")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestDeleteUserPolicy(c *C) {
- testServer.Response(200, nil, RequestIdExample)
- resp, err := s.iam.DeleteUserPolicy("Bob", "AllAccessPolicy")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "DeleteUserPolicy")
- c.Assert(values.Get("PolicyName"), Equals, "AllAccessPolicy")
- c.Assert(values.Get("UserName"), Equals, "Bob")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestAddUserToGroup(c *C) {
- testServer.Response(200, nil, AddUserToGroupExample)
- resp, err := s.iam.AddUserToGroup("admin1", "Admins")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "AddUserToGroup")
- c.Assert(values.Get("GroupName"), Equals, "Admins")
- c.Assert(values.Get("UserName"), Equals, "admin1")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestListAccountAliases(c *C) {
- testServer.Response(200, nil, ListAccountAliasesExample)
- resp, err := s.iam.ListAccountAliases()
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "ListAccountAliases")
- c.Assert(err, IsNil)
- c.Assert(resp.AccountAliases[0], Equals, "foocorporation")
- c.Assert(resp.RequestId, Equals, "c5a076e9-f1b0-11df-8fbe-45274EXAMPLE")
-}
-
-func (s *S) TestCreateAccountAlias(c *C) {
- testServer.Response(200, nil, CreateAccountAliasExample)
- resp, err := s.iam.CreateAccountAlias("foobaz")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "CreateAccountAlias")
- c.Assert(values.Get("AccountAlias"), Equals, "foobaz")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "36b5db08-f1b0-11df-8fbe-45274EXAMPLE")
-}
-
-func (s *S) TestDeleteAccountAlias(c *C) {
- testServer.Response(200, nil, DeleteAccountAliasExample)
- resp, err := s.iam.DeleteAccountAlias("foobaz")
- values := testServer.WaitRequest().URL.Query()
- c.Assert(values.Get("Action"), Equals, "DeleteAccountAlias")
- c.Assert(values.Get("AccountAlias"), Equals, "foobaz")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestUploadServerCertificate(c *C) {
- testServer.Response(200, nil, UploadServerCertificateExample)
-
- certificateBody := `
------BEGIN CERTIFICATE-----
-MIICdzCCAeCgAwIBAgIGANc+Ha2wMA0GCSqGSIb3DQEBBQUAMFMxCzAJBgNVBAYT
-AlVTMRMwEQYDVQQKEwpBbWF6b24uY29tMQwwCgYDVQQLEwNBV1MxITAfBgNVBAMT
-GEFXUyBMaW1pdGVkLUFzc3VyYW5jZSBDQTAeFw0wOTAyMDQxNzE5MjdaFw0xMDAy
-MDQxNzE5MjdaMFIxCzAJBgNVBAYTAlVTMRMwEQYDVQQKEwpBbWF6b24uY29tMRcw
-FQYDVQQLEw5BV1MtRGV2ZWxvcGVyczEVMBMGA1UEAxMMNTdxNDl0c3ZwYjRtMIGf
-MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpB/vsOwmT/O0td1RqzKjttSBaPjbr
-dqwNe9BrOyB08fw2+Ch5oonZYXfGUrT6mkYXH5fQot9HvASrzAKHO596FdJA6DmL
-ywdWe1Oggk7zFSXO1Xv+3vPrJtaYxYo3eRIp7w80PMkiOv6M0XK8ubcTouODeJbf
-suDqcLnLDxwsvwIDAQABo1cwVTAOBgNVHQ8BAf8EBAMCBaAwFgYDVR0lAQH/BAww
-CgYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQULGNaBphBumaKbDRK
-CAi0mH8B3mowDQYJKoZIhvcNAQEFBQADgYEAuKxhkXaCLGcqDuweKtO/AEw9ZePH
-wr0XqsaIK2HZboqruebXEGsojK4Ks0WzwgrEynuHJwTn760xe39rSqXWIOGrOBaX
-wFpWHVjTFMKk+tSDG1lssLHyYWWdFFU4AnejRGORJYNaRHgVTKjHphc5jEhHm0BX
-AEaHzTpmEXAMPLE=
------END CERTIFICATE-----
-`
- privateKey := `
------BEGIN DSA PRIVATE KEY-----
-MIIBugIBTTKBgQD33xToSXPJ6hr37L3+KNi3/7DgywlBcvlFPPSHIw3ORuO/22mT
-8Cy5fT89WwNvZ3BPKWU6OZ38TQv3eWjNc/3U3+oqVNG2poX5nCPOtO1b96HYX2mR
-3FTdH6FRKbQEhpDzZ6tRrjTHjMX6sT3JRWkBd2c4bGu+HUHO1H7QvrCTeQIVTKMs
-TCKCyrLiGhUWuUGNJUMU6y6zToGTHl84Tz7TPwDGDXuy/Dk5s4jTVr+xibROC/gS
-Qrs4Dzz3T1ze6lvU8S1KT9UsOB5FUJNTTPCPey+Lo4mmK6b23XdTyCIT8e2fsm2j
-jHHC1pIPiTkdLS3j6ZYjF8LY6TENFng+LDY/xwPOl7TJVoD3J/WXC2J9CEYq9o34
-kq6WWn3CgYTuo54nXUgnoCb3xdG8COFrg+oTbIkHTSzs3w5o/GGgKK7TDF3UlJjq
-vHNyJQ6kWBrQRR1Xp5KYQ4c/Dm5kef+62mH53HpcCELguWVcffuVQpmq3EWL9Zp9
-jobTJQ2VHjb5IVxiO6HRSd27di3njyrzUuJCyHSDTqwLJmTThpd6OTIUTL3Tc4m2
-62TITdw53KWJEXAMPLE=
------END DSA PRIVATE KEY-----
-`
- params := &iam.UploadServerCertificateParams{
- ServerCertificateName: "ProdServerCert",
- Path: "/company/servercerts/",
- PrivateKey: privateKey,
- CertificateBody: certificateBody,
- }
-
- resp, err := s.iam.UploadServerCertificate(params)
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.FormValue("Action"), Equals, "UploadServerCertificate")
- c.Assert(req.FormValue("CertificateBody"), Equals, certificateBody)
- c.Assert(req.FormValue("PrivateKey"), Equals, privateKey)
- c.Assert(req.FormValue("ServerCertificateName"), Equals, "ProdServerCert")
- c.Assert(req.FormValue("CertificateChain"), Equals, "")
- c.Assert(req.FormValue("Path"), Equals, "/company/servercerts/")
- c.Assert(req.FormValue("Version"), Equals, "2010-05-08")
- c.Assert(err, IsNil)
-
- ud, _ := time.Parse(time.RFC3339, "2010-05-08T01:02:03.004Z")
- exp, _ := time.Parse(time.RFC3339, "2012-05-08T01:02:03.004Z")
- expected := iam.ServerCertificateMetadata{
- Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert",
- ServerCertificateName: "ProdServerCert",
- ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE",
- Path: "/company/servercerts/",
- UploadDate: ud,
- Expiration: exp,
- }
- c.Assert(resp.ServerCertificateMetadata, DeepEquals, expected)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
-
-func (s *S) TestListServerCertificates(c *C) {
- testServer.Response(200, nil, ListServerCertificatesExample)
- params := &iam.ListServerCertificatesParams{
- Marker: "my-fake-marker",
- PathPrefix: "/some/fake/path",
- }
-
- resp, err := s.iam.ListServerCertificates(params)
- req := testServer.WaitRequest()
-
- c.Assert(err, IsNil)
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.FormValue("Action"), Equals, "ListServerCertificates")
- c.Assert(req.FormValue("Marker"), Equals, "my-fake-marker")
- c.Assert(req.FormValue("PathPrefix"), Equals, "/some/fake/path")
- c.Assert(req.FormValue("Version"), Equals, "2010-05-08")
-
- uploadDate, _ := time.Parse(time.RFC3339, "2010-05-08T01:02:03.004Z")
- expirationDate, _ := time.Parse(time.RFC3339, "2012-05-08T01:02:03.004Z")
- expected := []iam.ServerCertificateMetadata{
- {
- Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert",
- ServerCertificateName: "ProdServerCert",
- ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE1",
- Path: "/some/fake/path",
- UploadDate: uploadDate,
- Expiration: expirationDate,
- },
- {
- Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/BetaServerCert",
- ServerCertificateName: "BetaServerCert",
- ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE2",
- Path: "/some/fake/path",
- UploadDate: uploadDate,
- Expiration: expirationDate,
- },
- {
- Arn: "arn:aws:iam::123456789012:server-certificate/company/servercerts/TestServerCert",
- ServerCertificateName: "TestServerCert",
- ServerCertificateId: "ASCACKCEVSQ6C2EXAMPLE3",
- Path: "/some/fake/path",
- UploadDate: uploadDate,
- Expiration: expirationDate,
- },
- }
-
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eTHISDIFFERENTTEST")
- c.Assert(resp.IsTruncated, Equals, false)
- c.Assert(resp.ServerCertificates, DeepEquals, expected)
-}
-
-func (s *S) TestDeleteServerCertificate(c *C) {
- testServer.Response(200, nil, DeleteServerCertificateExample)
- resp, err := s.iam.DeleteServerCertificate("ProdServerCert")
- req := testServer.WaitRequest()
- c.Assert(req.FormValue("Action"), Equals, "DeleteServerCertificate")
- c.Assert(req.FormValue("ServerCertificateName"), Equals, "ProdServerCert")
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE")
-}
diff --git a/vendor/github.com/goamz/goamz/iam/iami_test.go b/vendor/github.com/goamz/goamz/iam/iami_test.go
deleted file mode 100644
index 26f32386f..000000000
--- a/vendor/github.com/goamz/goamz/iam/iami_test.go
+++ /dev/null
@@ -1,209 +0,0 @@
-package iam_test
-
-import (
- "net/url"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/iam"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-// AmazonServer represents an Amazon AWS server.
-type AmazonServer struct {
- auth aws.Auth
-}
-
-func (s *AmazonServer) SetUp(c *C) {
- auth, err := aws.EnvAuth()
- if err != nil {
- c.Fatal(err)
- }
- s.auth = auth
-}
-
-var _ = Suite(&AmazonClientSuite{})
-
-// AmazonClientSuite tests the client against a live AWS server.
-type AmazonClientSuite struct {
- srv AmazonServer
- ClientTests
-}
-
-func (s *AmazonClientSuite) SetUpSuite(c *C) {
- if !testutil.Amazon {
- c.Skip("AmazonClientSuite tests not enabled")
- }
- s.srv.SetUp(c)
- s.iam = iam.New(s.srv.auth, aws.USEast)
-}
-
-// ClientTests defines integration tests designed to test the client.
-// It is not used as a test suite in itself, but embedded within
-// another type.
-type ClientTests struct {
- iam *iam.IAM
-}
-
-func (s *ClientTests) TestCreateAndDeleteUser(c *C) {
- createResp, err := s.iam.CreateUser("gopher", "/gopher/")
- c.Assert(err, IsNil)
- getResp, err := s.iam.GetUser("gopher")
- c.Assert(err, IsNil)
- c.Assert(createResp.User, DeepEquals, getResp.User)
- _, err = s.iam.DeleteUser("gopher")
- c.Assert(err, IsNil)
-}
-
-func (s *ClientTests) TestCreateUserError(c *C) {
- _, err := s.iam.CreateUser("gopher", "/gopher/")
- c.Assert(err, IsNil)
- defer s.iam.DeleteUser("gopher")
- _, err = s.iam.CreateUser("gopher", "/")
- iamErr, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(iamErr.StatusCode, Equals, 409)
- c.Assert(iamErr.Code, Equals, "EntityAlreadyExists")
- c.Assert(iamErr.Message, Equals, "User with name gopher already exists.")
-}
-
-func (s *ClientTests) TestDeleteUserError(c *C) {
- _, err := s.iam.DeleteUser("gopher")
- iamErr, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(iamErr.StatusCode, Equals, 404)
- c.Assert(iamErr.Code, Equals, "NoSuchEntity")
- c.Assert(iamErr.Message, Equals, "The user with name gopher cannot be found.")
-}
-
-func (s *ClientTests) TestGetUserError(c *C) {
- _, err := s.iam.GetUser("gopher")
- iamErr, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(iamErr.StatusCode, Equals, 404)
- c.Assert(iamErr.Code, Equals, "NoSuchEntity")
- c.Assert(iamErr.Message, Equals, "The user with name gopher cannot be found.")
-}
-
-func (s *ClientTests) TestCreateListAndDeleteAccessKey(c *C) {
- createUserResp, err := s.iam.CreateUser("gopher", "/gopher/")
- c.Assert(err, IsNil)
- defer s.iam.DeleteUser(createUserResp.User.Name)
- createKeyResp, err := s.iam.CreateAccessKey(createUserResp.User.Name)
- c.Assert(err, IsNil)
- listKeyResp, err := s.iam.AccessKeys(createUserResp.User.Name)
- c.Assert(err, IsNil)
- c.Assert(listKeyResp.AccessKeys, HasLen, 1)
- createKeyResp.AccessKey.Secret = ""
- c.Assert(listKeyResp.AccessKeys[0], DeepEquals, createKeyResp.AccessKey)
- _, err = s.iam.DeleteAccessKey(createKeyResp.AccessKey.Id, createUserResp.User.Name)
- c.Assert(err, IsNil)
-}
-
-func (s *ClientTests) TestCreateAccessKeyError(c *C) {
- _, err := s.iam.CreateAccessKey("unknowngopher")
- c.Assert(err, NotNil)
- iamErr, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(iamErr.StatusCode, Equals, 404)
- c.Assert(iamErr.Code, Equals, "NoSuchEntity")
- c.Assert(iamErr.Message, Equals, "The user with name unknowngopher cannot be found.")
-}
-
-func (s *ClientTests) TestListAccessKeysUserNotFound(c *C) {
- _, err := s.iam.AccessKeys("unknowngopher")
- c.Assert(err, NotNil)
- iamErr, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(iamErr.StatusCode, Equals, 404)
- c.Assert(iamErr.Code, Equals, "NoSuchEntity")
- c.Assert(iamErr.Message, Equals, "The user with name unknowngopher cannot be found.")
-}
-
-func (s *ClientTests) TestListAccessKeysUserWithoutKeys(c *C) {
- createUserResp, err := s.iam.CreateUser("gopher", "/")
- c.Assert(err, IsNil)
- defer s.iam.DeleteUser(createUserResp.User.Name)
- resp, err := s.iam.AccessKeys(createUserResp.User.Name)
- c.Assert(err, IsNil)
- c.Assert(resp.AccessKeys, HasLen, 0)
-}
-
-func (s *ClientTests) TestCreateListAndDeleteGroup(c *C) {
- cResp1, err := s.iam.CreateGroup("Finances", "/finances/")
- c.Assert(err, IsNil)
- cResp2, err := s.iam.CreateGroup("DevelopmentManagers", "/development/managers/")
- c.Assert(err, IsNil)
- lResp, err := s.iam.Groups("/development/")
- c.Assert(err, IsNil)
- c.Assert(lResp.Groups, HasLen, 1)
- c.Assert(cResp2.Group, DeepEquals, lResp.Groups[0])
- lResp, err = s.iam.Groups("")
- c.Assert(err, IsNil)
- c.Assert(lResp.Groups, HasLen, 2)
- if lResp.Groups[0].Name == cResp1.Group.Name {
- c.Assert([]iam.Group{cResp1.Group, cResp2.Group}, DeepEquals, lResp.Groups)
- } else {
- c.Assert([]iam.Group{cResp2.Group, cResp1.Group}, DeepEquals, lResp.Groups)
- }
- _, err = s.iam.DeleteGroup("DevelopmentManagers")
- c.Assert(err, IsNil)
- lResp, err = s.iam.Groups("/development/")
- c.Assert(err, IsNil)
- c.Assert(lResp.Groups, HasLen, 0)
- _, err = s.iam.DeleteGroup("Finances")
- c.Assert(err, IsNil)
-}
-
-func (s *ClientTests) TestCreateGroupError(c *C) {
- _, err := s.iam.CreateGroup("Finances", "/finances/")
- c.Assert(err, IsNil)
- defer s.iam.DeleteGroup("Finances")
- _, err = s.iam.CreateGroup("Finances", "/something-else/")
- iamErr, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(iamErr.StatusCode, Equals, 409)
- c.Assert(iamErr.Code, Equals, "EntityAlreadyExists")
- c.Assert(iamErr.Message, Equals, "Group with name Finances already exists.")
-}
-
-func (s *ClientTests) TestDeleteGroupError(c *C) {
- _, err := s.iam.DeleteGroup("Finances")
- iamErr, ok := err.(*iam.Error)
- c.Assert(ok, Equals, true)
- c.Assert(iamErr.StatusCode, Equals, 404)
- c.Assert(iamErr.Code, Equals, "NoSuchEntity")
- c.Assert(iamErr.Message, Equals, "The group with name Finances cannot be found.")
-}
-
-func (s *ClientTests) TestPutGetAndDeleteUserPolicy(c *C) {
- userResp, err := s.iam.CreateUser("gopher", "/gopher/")
- c.Assert(err, IsNil)
- defer s.iam.DeleteUser(userResp.User.Name)
- document := `{
- "Statement": [
- {
- "Action": [
- "s3:*"
- ],
- "Effect": "Allow",
- "Resource": [
- "arn:aws:s3:::8shsns19s90ajahadsj/*",
- "arn:aws:s3:::8shsns19s90ajahadsj"
- ]
- }]
- }`
- _, err = s.iam.PutUserPolicy(userResp.User.Name, "EverythingS3", document)
- c.Assert(err, IsNil)
- resp, err := s.iam.GetUserPolicy(userResp.User.Name, "EverythingS3")
- c.Assert(err, IsNil)
- c.Assert(resp.Policy.Name, Equals, "EverythingS3")
- c.Assert(resp.Policy.UserName, Equals, userResp.User.Name)
- gotDocument, err := url.QueryUnescape(resp.Policy.Document)
- c.Assert(err, IsNil)
- c.Assert(gotDocument, Equals, document)
- _, err = s.iam.DeleteUserPolicy(userResp.User.Name, "EverythingS3")
- c.Assert(err, IsNil)
- _, err = s.iam.GetUserPolicy(userResp.User.Name, "EverythingS3")
- c.Assert(err, NotNil)
-}
diff --git a/vendor/github.com/goamz/goamz/iam/iamt_test.go b/vendor/github.com/goamz/goamz/iam/iamt_test.go
deleted file mode 100644
index 9d89f43e3..000000000
--- a/vendor/github.com/goamz/goamz/iam/iamt_test.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package iam_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/iam"
- "github.com/goamz/goamz/iam/iamtest"
- . "gopkg.in/check.v1"
-)
-
-// LocalServer represents a local ec2test fake server.
-type LocalServer struct {
- auth aws.Auth
- region aws.Region
- srv *iamtest.Server
-}
-
-func (s *LocalServer) SetUp(c *C) {
- srv, err := iamtest.NewServer()
- c.Assert(err, IsNil)
- c.Assert(srv, NotNil)
-
- s.srv = srv
- s.region = aws.Region{IAMEndpoint: srv.URL()}
-}
-
-// LocalServerSuite defines tests that will run
-// against the local iamtest server. It includes
-// tests from ClientTests.
-type LocalServerSuite struct {
- srv LocalServer
- ClientTests
-}
-
-var _ = Suite(&LocalServerSuite{})
-
-func (s *LocalServerSuite) SetUpSuite(c *C) {
- s.srv.SetUp(c)
- s.ClientTests.iam = iam.New(s.srv.auth, s.srv.region)
-}
diff --git a/vendor/github.com/goamz/goamz/iam/iamtest/server.go b/vendor/github.com/goamz/goamz/iam/iamtest/server.go
deleted file mode 100644
index 08991d2f8..000000000
--- a/vendor/github.com/goamz/goamz/iam/iamtest/server.go
+++ /dev/null
@@ -1,432 +0,0 @@
-// Package iamtest implements a fake IAM provider with the capability of
-// inducing errors on any given operation, and retrospectively determining what
-// operations have been carried out.
-package iamtest
-
-import (
- "encoding/json"
- "encoding/xml"
- "fmt"
- "github.com/goamz/goamz/iam"
- "net"
- "net/http"
- "strings"
- "sync"
-)
-
-type action struct {
- srv *Server
- w http.ResponseWriter
- req *http.Request
- reqId string
-}
-
-// Server implements an IAM simulator for use in tests.
-type Server struct {
- reqId int
- url string
- listener net.Listener
- users []iam.User
- groups []iam.Group
- accessKeys []iam.AccessKey
- userPolicies []iam.UserPolicy
- mutex sync.Mutex
-}
-
-func NewServer() (*Server, error) {
- l, err := net.Listen("tcp", "localhost:0")
- if err != nil {
- return nil, fmt.Errorf("cannot listen on localhost: %v", err)
- }
- srv := &Server{
- listener: l,
- url: "http://" + l.Addr().String(),
- }
- go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
- srv.serveHTTP(w, req)
- }))
- return srv, nil
-}
-
-// Quit closes down the server.
-func (srv *Server) Quit() error {
- return srv.listener.Close()
-}
-
-// URL returns a URL for the server.
-func (srv *Server) URL() string {
- return srv.url
-}
-
-type xmlErrors struct {
- XMLName string `xml:"ErrorResponse"`
- Error iam.Error
-}
-
-func (srv *Server) error(w http.ResponseWriter, err *iam.Error) {
- w.WriteHeader(err.StatusCode)
- xmlErr := xmlErrors{Error: *err}
- if e := xml.NewEncoder(w).Encode(xmlErr); e != nil {
- panic(e)
- }
-}
-
-func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
- req.ParseForm()
- srv.mutex.Lock()
- defer srv.mutex.Unlock()
- action := req.FormValue("Action")
- if action == "" {
- srv.error(w, &iam.Error{
- StatusCode: 400,
- Code: "MissingAction",
- Message: "Missing action",
- })
- }
- if a, ok := actions[action]; ok {
- reqId := fmt.Sprintf("req%0X", srv.reqId)
- srv.reqId++
- if resp, err := a(srv, w, req, reqId); err == nil {
- if err := xml.NewEncoder(w).Encode(resp); err != nil {
- panic(err)
- }
- } else {
- switch err.(type) {
- case *iam.Error:
- srv.error(w, err.(*iam.Error))
- default:
- panic(err)
- }
- }
- } else {
- srv.error(w, &iam.Error{
- StatusCode: 400,
- Code: "InvalidAction",
- Message: "Invalid action: " + action,
- })
- }
-}
-
-func (srv *Server) createUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName"}); err != nil {
- return nil, err
- }
- path := req.FormValue("Path")
- if path == "" {
- path = "/"
- }
- name := req.FormValue("UserName")
- for _, user := range srv.users {
- if user.Name == name {
- return nil, &iam.Error{
- StatusCode: 409,
- Code: "EntityAlreadyExists",
- Message: fmt.Sprintf("User with name %s already exists.", name),
- }
- }
- }
- user := iam.User{
- Id: "USER" + reqId + "EXAMPLE",
- Arn: fmt.Sprintf("arn:aws:iam:::123456789012:user%s%s", path, name),
- Name: name,
- Path: path,
- }
- srv.users = append(srv.users, user)
- return iam.CreateUserResp{
- RequestId: reqId,
- User: user,
- }, nil
-}
-
-func (srv *Server) getUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName"}); err != nil {
- return nil, err
- }
- name := req.FormValue("UserName")
- index, err := srv.findUser(name)
- if err != nil {
- return nil, err
- }
- return iam.GetUserResp{RequestId: reqId, User: srv.users[index]}, nil
-}
-
-func (srv *Server) deleteUser(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName"}); err != nil {
- return nil, err
- }
- name := req.FormValue("UserName")
- index, err := srv.findUser(name)
- if err != nil {
- return nil, err
- }
- copy(srv.users[index:], srv.users[index+1:])
- srv.users = srv.users[:len(srv.users)-1]
- return iam.SimpleResp{RequestId: reqId}, nil
-}
-
-func (srv *Server) createAccessKey(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName"}); err != nil {
- return nil, err
- }
- userName := req.FormValue("UserName")
- if _, err := srv.findUser(userName); err != nil {
- return nil, err
- }
- key := iam.AccessKey{
- Id: fmt.Sprintf("%s%d", userName, len(srv.accessKeys)),
- Secret: "",
- UserName: userName,
- Status: "Active",
- }
- srv.accessKeys = append(srv.accessKeys, key)
- return iam.CreateAccessKeyResp{RequestId: reqId, AccessKey: key}, nil
-}
-
-func (srv *Server) deleteAccessKey(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"AccessKeyId", "UserName"}); err != nil {
- return nil, err
- }
- key := req.FormValue("AccessKeyId")
- index := -1
- for i, ak := range srv.accessKeys {
- if ak.Id == key {
- index = i
- break
- }
- }
- if index < 0 {
- return nil, &iam.Error{
- StatusCode: 404,
- Code: "NoSuchEntity",
- Message: "No such key.",
- }
- }
- copy(srv.accessKeys[index:], srv.accessKeys[index+1:])
- srv.accessKeys = srv.accessKeys[:len(srv.accessKeys)-1]
- return iam.SimpleResp{RequestId: reqId}, nil
-}
-
-func (srv *Server) listAccessKeys(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName"}); err != nil {
- return nil, err
- }
- userName := req.FormValue("UserName")
- if _, err := srv.findUser(userName); err != nil {
- return nil, err
- }
- var keys []iam.AccessKey
- for _, k := range srv.accessKeys {
- if k.UserName == userName {
- keys = append(keys, k)
- }
- }
- return iam.AccessKeysResp{
- RequestId: reqId,
- AccessKeys: keys,
- }, nil
-}
-
-func (srv *Server) createGroup(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"GroupName"}); err != nil {
- return nil, err
- }
- name := req.FormValue("GroupName")
- path := req.FormValue("Path")
- for _, group := range srv.groups {
- if group.Name == name {
- return nil, &iam.Error{
- StatusCode: 409,
- Code: "EntityAlreadyExists",
- Message: fmt.Sprintf("Group with name %s already exists.", name),
- }
- }
- }
- group := iam.Group{
- Id: "GROUP " + reqId + "EXAMPLE",
- Arn: fmt.Sprintf("arn:aws:iam:::123456789012:group%s%s", path, name),
- Name: name,
- Path: path,
- }
- srv.groups = append(srv.groups, group)
- return iam.CreateGroupResp{
- RequestId: reqId,
- Group: group,
- }, nil
-}
-
-func (srv *Server) listGroups(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- pathPrefix := req.FormValue("PathPrefix")
- if pathPrefix == "" {
- return iam.GroupsResp{
- RequestId: reqId,
- Groups: srv.groups,
- }, nil
- }
- var groups []iam.Group
- for _, group := range srv.groups {
- if strings.HasPrefix(group.Path, pathPrefix) {
- groups = append(groups, group)
- }
- }
- return iam.GroupsResp{
- RequestId: reqId,
- Groups: groups,
- }, nil
-}
-
-func (srv *Server) deleteGroup(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"GroupName"}); err != nil {
- return nil, err
- }
- name := req.FormValue("GroupName")
- index := -1
- for i, group := range srv.groups {
- if group.Name == name {
- index = i
- break
- }
- }
- if index == -1 {
- return nil, &iam.Error{
- StatusCode: 404,
- Code: "NoSuchEntity",
- Message: fmt.Sprintf("The group with name %s cannot be found.", name),
- }
- }
- copy(srv.groups[index:], srv.groups[index+1:])
- srv.groups = srv.groups[:len(srv.groups)-1]
- return iam.SimpleResp{RequestId: reqId}, nil
-}
-
-func (srv *Server) putUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName", "PolicyDocument", "PolicyName"}); err != nil {
- return nil, err
- }
- var exists bool
- policyName := req.FormValue("PolicyName")
- userName := req.FormValue("UserName")
- for _, policy := range srv.userPolicies {
- if policyName == policy.Name && userName == policy.UserName {
- exists = true
- break
- }
- }
- if !exists {
- policy := iam.UserPolicy{
- Name: policyName,
- UserName: userName,
- Document: req.FormValue("PolicyDocument"),
- }
- var dumb interface{}
- if err := json.Unmarshal([]byte(policy.Document), &dumb); err != nil {
- return nil, &iam.Error{
- StatusCode: 400,
- Code: "MalformedPolicyDocument",
- Message: "Malformed policy document",
- }
- }
- srv.userPolicies = append(srv.userPolicies, policy)
- }
- return iam.SimpleResp{RequestId: reqId}, nil
-}
-
-func (srv *Server) deleteUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName", "PolicyName"}); err != nil {
- return nil, err
- }
- policyName := req.FormValue("PolicyName")
- userName := req.FormValue("UserName")
- index := -1
- for i, policy := range srv.userPolicies {
- if policyName == policy.Name && userName == policy.UserName {
- index = i
- break
- }
- }
- if index < 0 {
- return nil, &iam.Error{
- StatusCode: 404,
- Code: "NoSuchEntity",
- Message: "No such user policy",
- }
- }
- copy(srv.userPolicies[index:], srv.userPolicies[index+1:])
- srv.userPolicies = srv.userPolicies[:len(srv.userPolicies)-1]
- return iam.SimpleResp{RequestId: reqId}, nil
-}
-
-func (srv *Server) getUserPolicy(w http.ResponseWriter, req *http.Request, reqId string) (interface{}, error) {
- if err := srv.validate(req, []string{"UserName", "PolicyName"}); err != nil {
- return nil, err
- }
- policyName := req.FormValue("PolicyName")
- userName := req.FormValue("UserName")
- index := -1
- for i, policy := range srv.userPolicies {
- if policyName == policy.Name && userName == policy.UserName {
- index = i
- break
- }
- }
- if index < 0 {
- return nil, &iam.Error{
- StatusCode: 404,
- Code: "NoSuchEntity",
- Message: "No such user policy",
- }
- }
- return iam.GetUserPolicyResp{
- Policy: srv.userPolicies[index],
- RequestId: reqId,
- }, nil
-}
-
-func (srv *Server) findUser(userName string) (int, error) {
- var (
- err error
- index = -1
- )
- for i, user := range srv.users {
- if user.Name == userName {
- index = i
- break
- }
- }
- if index < 0 {
- err = &iam.Error{
- StatusCode: 404,
- Code: "NoSuchEntity",
- Message: fmt.Sprintf("The user with name %s cannot be found.", userName),
- }
- }
- return index, err
-}
-
-// Validates the presence of required request parameters.
-func (srv *Server) validate(req *http.Request, required []string) error {
- for _, r := range required {
- if req.FormValue(r) == "" {
- return &iam.Error{
- StatusCode: 400,
- Code: "InvalidParameterCombination",
- Message: fmt.Sprintf("%s is required.", r),
- }
- }
- }
- return nil
-}
-
-var actions = map[string]func(*Server, http.ResponseWriter, *http.Request, string) (interface{}, error){
- "CreateUser": (*Server).createUser,
- "DeleteUser": (*Server).deleteUser,
- "GetUser": (*Server).getUser,
- "CreateAccessKey": (*Server).createAccessKey,
- "DeleteAccessKey": (*Server).deleteAccessKey,
- "ListAccessKeys": (*Server).listAccessKeys,
- "PutUserPolicy": (*Server).putUserPolicy,
- "DeleteUserPolicy": (*Server).deleteUserPolicy,
- "GetUserPolicy": (*Server).getUserPolicy,
- "CreateGroup": (*Server).createGroup,
- "DeleteGroup": (*Server).deleteGroup,
- "ListGroups": (*Server).listGroups,
-}
diff --git a/vendor/github.com/goamz/goamz/iam/responses_test.go b/vendor/github.com/goamz/goamz/iam/responses_test.go
deleted file mode 100644
index d8a0b2c4c..000000000
--- a/vendor/github.com/goamz/goamz/iam/responses_test.go
+++ /dev/null
@@ -1,261 +0,0 @@
-package iam_test
-
-// http://goo.gl/EUIvl
-var CreateUserExample = `
-<CreateUserResponse>
- <CreateUserResult>
- <User>
- <Path>/division_abc/subdivision_xyz/</Path>
- <UserName>Bob</UserName>
- <UserId>AIDACKCEVSQ6C2EXAMPLE</UserId>
- <Arn>arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob</Arn>
- </User>
- </CreateUserResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateUserResponse>
-`
-
-var DuplicateUserExample = `
-<ErrorResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
- <Error>
- <Type>Sender</Type>
- <Code>EntityAlreadyExists</Code>
- <Message>User with name Bob already exists.</Message>
- </Error>
- <RequestId>1d5f5000-1316-11e2-a60f-91a8e6fb6d21</RequestId>
-</ErrorResponse>
-`
-
-var GetUserExample = `
-<GetUserResponse>
- <GetUserResult>
- <User>
- <Path>/division_abc/subdivision_xyz/</Path>
- <UserName>Bob</UserName>
- <UserId>AIDACKCEVSQ6C2EXAMPLE</UserId>
- <Arn>arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob</Arn>
- </User>
- </GetUserResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</GetUserResponse>
-`
-
-var CreateGroupExample = `
-<CreateGroupResponse>
- <CreateGroupResult>
- <Group>
- <Path>/admins/</Path>
- <GroupName>Admins</GroupName>
- <GroupId>AGPACKCEVSQ6C2EXAMPLE</GroupId>
- <Arn>arn:aws:iam::123456789012:group/Admins</Arn>
- </Group>
- </CreateGroupResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateGroupResponse>
-`
-
-var ListGroupsExample = `
-<ListGroupsResponse>
- <ListGroupsResult>
- <Groups>
- <member>
- <Path>/division_abc/subdivision_xyz/</Path>
- <GroupName>Admins</GroupName>
- <GroupId>AGPACKCEVSQ6C2EXAMPLE</GroupId>
- <Arn>arn:aws:iam::123456789012:group/Admins</Arn>
- </member>
- <member>
- <Path>/division_abc/subdivision_xyz/product_1234/engineering/</Path>
- <GroupName>Test</GroupName>
- <GroupId>AGP2MAB8DPLSRHEXAMPLE</GroupId>
- <Arn>arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test</Arn>
- </member>
- <member>
- <Path>/division_abc/subdivision_xyz/product_1234/</Path>
- <GroupName>Managers</GroupName>
- <GroupId>AGPIODR4TAW7CSEXAMPLE</GroupId>
- <Arn>arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers</Arn>
- </member>
- </Groups>
- <IsTruncated>false</IsTruncated>
- </ListGroupsResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</ListGroupsResponse>
-`
-
-var RequestIdExample = `
-<AddUserToGroupResponse>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</AddUserToGroupResponse>
-`
-
-var CreateAccessKeyExample = `
-<CreateAccessKeyResponse>
- <CreateAccessKeyResult>
- <AccessKey>
- <UserName>Bob</UserName>
- <AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId>
- <Status>Active</Status>
- <SecretAccessKey>wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY</SecretAccessKey>
- </AccessKey>
- </CreateAccessKeyResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateAccessKeyResponse>
-`
-
-var ListAccessKeyExample = `
-<ListAccessKeysResponse>
- <ListAccessKeysResult>
- <UserName>Bob</UserName>
- <AccessKeyMetadata>
- <member>
- <UserName>Bob</UserName>
- <AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId>
- <Status>Active</Status>
- </member>
- <member>
- <UserName>Bob</UserName>
- <AccessKeyId>AKIAI44QH8DHBEXAMPLE</AccessKeyId>
- <Status>Inactive</Status>
- </member>
- </AccessKeyMetadata>
- <IsTruncated>false</IsTruncated>
- </ListAccessKeysResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</ListAccessKeysResponse>
-`
-
-var GetUserPolicyExample = `
-<GetUserPolicyResponse>
- <GetUserPolicyResult>
- <UserName>Bob</UserName>
- <PolicyName>AllAccessPolicy</PolicyName>
- <PolicyDocument>
- {"Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}
- </PolicyDocument>
- </GetUserPolicyResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</GetUserPolicyResponse>
-`
-
-var AddUserToGroupExample = `
-<AddUserToGroupResponse>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</AddUserToGroupResponse>
-`
-
-var ListAccountAliasesExample = `
-<ListAccountAliasesResponse>
- <ListAccountAliasesResult>
- <IsTruncated>false</IsTruncated>
- <AccountAliases>
- <member>foocorporation</member>
- </AccountAliases>
- </ListAccountAliasesResult>
- <ResponseMetadata>
- <RequestId>c5a076e9-f1b0-11df-8fbe-45274EXAMPLE</RequestId>
- </ResponseMetadata>
-</ListAccountAliasesResponse>
-`
-
-var CreateAccountAliasExample = `
-<CreateAccountAliasResponse>
- <ResponseMetadata>
- <RequestId>36b5db08-f1b0-11df-8fbe-45274EXAMPLE</RequestId>
- </ResponseMetadata>
-</CreateAccountAliasResponse>
-`
-
-var DeleteAccountAliasExample = `
-<DeleteAccountAliasResponse>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
- </ResponseMetadata>
-</DeleteAccountAliasResponse>
-`
-
-var UploadServerCertificateExample = `
-<UploadServerCertificateResponse>
-<UploadServerCertificateResult>
- <ServerCertificateMetadata>
- <ServerCertificateName>ProdServerCert</ServerCertificateName>
- <Path>/company/servercerts/</Path>
- <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert</Arn>
- <UploadDate>2010-05-08T01:02:03.004Z</UploadDate>
- <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE</ServerCertificateId>
- <Expiration>2012-05-08T01:02:03.004Z</Expiration>
- </ServerCertificateMetadata>
-</UploadServerCertificateResult>
-<ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
-</ResponseMetadata>
-</UploadServerCertificateResponse>
-`
-var ListServerCertificatesExample = `
-<ListServerCertificatesResponse>
-<ListServerCertificatesResult>
- <IsTruncated>false</IsTruncated>
- <ServerCertificateMetadataList>
- <member>
- <ServerCertificateMetadata>
- <ServerCertificateName>ProdServerCert</ServerCertificateName>
- <Path>/some/fake/path</Path>
- <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/ProdServerCert</Arn>
- <UploadDate>2010-05-08T01:02:03.004Z</UploadDate>
- <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE1</ServerCertificateId>
- <Expiration>2012-05-08T01:02:03.004Z</Expiration>
- </ServerCertificateMetadata>
- </member>
- <member>
- <ServerCertificateMetadata>
- <ServerCertificateName>BetaServerCert</ServerCertificateName>
- <Path>/some/fake/path</Path>
- <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/BetaServerCert</Arn>
- <UploadDate>2010-05-08T01:02:03.004Z</UploadDate>
- <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE2</ServerCertificateId>
- <Expiration>2012-05-08T01:02:03.004Z</Expiration>
- </ServerCertificateMetadata>
- </member>
- <member>
- <ServerCertificateMetadata>
- <ServerCertificateName>TestServerCert</ServerCertificateName>
- <Path>/some/fake/path</Path>
- <Arn>arn:aws:iam::123456789012:server-certificate/company/servercerts/TestServerCert</Arn>
- <UploadDate>2010-05-08T01:02:03.004Z</UploadDate>
- <ServerCertificateId>ASCACKCEVSQ6C2EXAMPLE3</ServerCertificateId>
- <Expiration>2012-05-08T01:02:03.004Z</Expiration>
- </ServerCertificateMetadata>
- </member>
- </ServerCertificateMetadataList>
-</ListServerCertificatesResult>
-<ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8eTHISDIFFERENTTEST</RequestId>
-</ResponseMetadata>
-</ListServerCertificatesResponse>
-`
-
-var DeleteServerCertificateExample = `
-<DeleteServerCertificateResponse>
-<ResponseMetadata>
-<RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
-</ResponseMetadata>
-</DeleteServerCertificateResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/iam/sign.go b/vendor/github.com/goamz/goamz/iam/sign.go
deleted file mode 100644
index b704fd8d6..000000000
--- a/vendor/github.com/goamz/goamz/iam/sign.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package iam
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "github.com/goamz/goamz/aws"
- "sort"
- "strings"
-)
-
-// ----------------------------------------------------------------------------
-// Version 2 signing (http://goo.gl/RSRp5)
-
-var b64 = base64.StdEncoding
-
-func sign(auth aws.Auth, method, path string, params map[string]string, host string) {
- params["AWSAccessKeyId"] = auth.AccessKey
- params["SignatureVersion"] = "2"
- params["SignatureMethod"] = "HmacSHA256"
- if auth.Token() != "" {
- params["SecurityToken"] = auth.Token()
- }
-
- var sarray []string
- for k, v := range params {
- sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
- }
- sort.StringSlice(sarray).Sort()
- joined := strings.Join(sarray, "&")
- payload := method + "\n" + host + "\n" + path + "\n" + joined
- hash := hmac.New(sha256.New, []byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- params["Signature"] = string(signature)
-}
diff --git a/vendor/github.com/goamz/goamz/rds/rds.go b/vendor/github.com/goamz/goamz/rds/rds.go
deleted file mode 100644
index f00b52c64..000000000
--- a/vendor/github.com/goamz/goamz/rds/rds.go
+++ /dev/null
@@ -1,96 +0,0 @@
-package rds
-
-import (
- "encoding/xml"
- "github.com/goamz/goamz/aws"
- "log"
- "net/http/httputil"
- "strconv"
-)
-
-const debug = false
-
-const (
- ServiceName = "rds"
- ApiVersion = "2013-09-09"
-)
-
-// The RDS type encapsulates operations within a specific EC2 region.
-type RDS struct {
- Service aws.AWSService
-}
-
-// New creates a new RDS Client.
-func New(auth aws.Auth, region aws.Region) (*RDS, error) {
- service, err := aws.NewService(auth, region.RDSEndpoint)
- if err != nil {
- return nil, err
- }
- return &RDS{
- Service: service,
- }, nil
-}
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-// query dispatches a request to the RDS API signed with a version 2 signature
-func (rds *RDS) query(method, path string, params map[string]string, resp interface{}) error {
- // Add basic RDS param
- params["Version"] = ApiVersion
-
- r, err := rds.Service.Query(method, path, params)
- if err != nil {
- return err
- }
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("response:\n")
- log.Printf("%v\n}\n", string(dump))
- }
-
- if r.StatusCode != 200 {
- return rds.Service.BuildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-// ----------------------------------------------------------------------------
-// API methods and corresponding response types.
-
-// Response to a DescribeDBInstances request
-//
-// See http://goo.gl/KSPlAl for more details.
-type DescribeDBInstancesResponse struct {
- DBInstances []DBInstance `xml:"DescribeDBInstancesResult>DBInstances>DBInstance"` // The list of database instances
- Marker string `xml:"DescribeDBInstancesResult>Marker"` // An optional pagination token provided by a previous request
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// DescribeDBInstances - Returns a description of each Database Instance
-// Supports pagination by using the "Marker" parameter, and "maxRecords" for subsequent calls
-// Unfortunately RDS does not currently support filtering
-//
-// See http://goo.gl/lzZMyz for more details.
-func (rds *RDS) DescribeDBInstances(id string, maxRecords int, marker string) (*DescribeDBInstancesResponse, error) {
-
- params := aws.MakeParams("DescribeDBInstances")
-
- if id != "" {
- params["DBInstanceIdentifier"] = id
- }
-
- if maxRecords != 0 {
- params["MaxRecords"] = strconv.Itoa(maxRecords)
- }
- if marker != "" {
- params["Marker"] = marker
- }
-
- resp := &DescribeDBInstancesResponse{}
- err := rds.query("POST", "/", params, resp)
- return resp, err
-}
diff --git a/vendor/github.com/goamz/goamz/rds/rds_test.go b/vendor/github.com/goamz/goamz/rds/rds_test.go
deleted file mode 100644
index ac277d4d7..000000000
--- a/vendor/github.com/goamz/goamz/rds/rds_test.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package rds_test
-
-import (
- "testing"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/rds"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- rds *rds.RDS
-}
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- var err error
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.rds, err = rds.New(auth, aws.Region{RDSEndpoint: aws.ServiceInfo{testServer.URL, aws.V2Signature}})
- c.Assert(err, IsNil)
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestDescribeDBInstancesExample1(c *C) {
- testServer.Response(200, nil, DescribeDBInstancesExample1)
-
- resp, err := s.rds.DescribeDBInstances("simcoprod01", 0, "")
-
- req := testServer.WaitRequest()
- c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeDBInstances"})
- c.Assert(req.Form["DBInstanceIdentifier"], DeepEquals, []string{"simcoprod01"})
-
- c.Assert(err, IsNil)
- c.Assert(resp.RequestId, Equals, "9135fff3-8509-11e0-bd9b-a7b1ece36d51")
- c.Assert(resp.DBInstances, HasLen, 1)
-
- db0 := resp.DBInstances[0]
- c.Assert(db0.AllocatedStorage, Equals, 10)
- c.Assert(db0.AutoMinorVersionUpgrade, Equals, true)
- c.Assert(db0.AvailabilityZone, Equals, "us-east-1a")
- c.Assert(db0.BackupRetentionPeriod, Equals, 1)
-
- c.Assert(db0.DBInstanceClass, Equals, "db.m1.large")
- c.Assert(db0.DBInstanceIdentifier, Equals, "simcoprod01")
- c.Assert(db0.DBInstanceStatus, Equals, "available")
- c.Assert(db0.DBName, Equals, "simcoprod")
-
- c.Assert(db0.Endpoint.Address, Equals, "simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com")
- c.Assert(db0.Endpoint.Port, Equals, 3306)
- c.Assert(db0.Engine, Equals, "mysql")
- c.Assert(db0.EngineVersion, Equals, "5.1.50")
- c.Assert(db0.InstanceCreateTime, Equals, "2011-05-23T06:06:43.110Z")
-
- c.Assert(db0.LatestRestorableTime, Equals, "2011-05-23T06:50:00Z")
- c.Assert(db0.LicenseModel, Equals, "general-public-license")
- c.Assert(db0.MasterUsername, Equals, "master")
- c.Assert(db0.MultiAZ, Equals, false)
- c.Assert(db0.OptionGroupMemberships, HasLen, 1)
- c.Assert(db0.OptionGroupMemberships[0].Name, Equals, "default.mysql5.1")
- c.Assert(db0.OptionGroupMemberships[0].Status, Equals, "in-sync")
-
- c.Assert(db0.PreferredBackupWindow, Equals, "00:00-00:30")
- c.Assert(db0.PreferredMaintenanceWindow, Equals, "sat:07:30-sat:08:00")
- c.Assert(db0.PubliclyAccessible, Equals, false)
-}
diff --git a/vendor/github.com/goamz/goamz/rds/responses_test.go b/vendor/github.com/goamz/goamz/rds/responses_test.go
deleted file mode 100644
index b7912f84b..000000000
--- a/vendor/github.com/goamz/goamz/rds/responses_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package rds_test
-
-var DescribeDBInstancesExample1 = `
-<DescribeDBInstancesResponse xmlns="http://rds.amazonaws.com/doc/2013-09-09/">
- <DescribeDBInstancesResult>
- <DBInstances>
- <DBInstance>
- <ReadReplicaDBInstanceIdentifiers/>
- <LatestRestorableTime>2011-05-23T06:50:00Z</LatestRestorableTime>
- <Engine>mysql</Engine>
- <PendingModifiedValues/>
- <BackupRetentionPeriod>1</BackupRetentionPeriod>
- <MultiAZ>false</MultiAZ>
- <LicenseModel>general-public-license</LicenseModel>
- <DBInstanceStatus>available</DBInstanceStatus>
- <EngineVersion>5.1.50</EngineVersion>
- <Endpoint>
- <Port>3306</Port>
- <Address>simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com</Address>
- </Endpoint>
- <DBInstanceIdentifier>simcoprod01</DBInstanceIdentifier>
- <DBName>simcoprod</DBName>
- <DBParameterGroups>
- <DBParameterGroup>
- <ParameterApplyStatus>in-sync</ParameterApplyStatus>
- <DBParameterGroupName>default.mysql5.1</DBParameterGroupName>
- </DBParameterGroup>
- </DBParameterGroups>
- <DBSecurityGroups>
- <DBSecurityGroup>
- <Status>active</Status>
- <DBSecurityGroupName>default</DBSecurityGroupName>
- </DBSecurityGroup>
- </DBSecurityGroups>
- <PreferredBackupWindow>00:00-00:30</PreferredBackupWindow>
- <AutoMinorVersionUpgrade>true</AutoMinorVersionUpgrade>
- <PreferredMaintenanceWindow>sat:07:30-sat:08:00</PreferredMaintenanceWindow>
- <AvailabilityZone>us-east-1a</AvailabilityZone>
- <InstanceCreateTime>2011-05-23T06:06:43.110Z</InstanceCreateTime>
- <AllocatedStorage>10</AllocatedStorage>
- <OptionGroupMemberships>
- <OptionGroupMembership>
- <OptionGroupName>default.mysql5.1</OptionGroupName>
- <Status>in-sync</Status>
- </OptionGroupMembership>
- </OptionGroupMemberships>
- <DBInstanceClass>db.m1.large</DBInstanceClass>
- <MasterUsername>master</MasterUsername>
- <PubliclyAccessible>false</PubliclyAccessible>
- </DBInstance>
- </DBInstances>
- </DescribeDBInstancesResult>
- <ResponseMetadata>
- <RequestId>9135fff3-8509-11e0-bd9b-a7b1ece36d51</RequestId>
- </ResponseMetadata>
-</DescribeDBInstancesResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/rds/types.go b/vendor/github.com/goamz/goamz/rds/types.go
deleted file mode 100644
index aa9c4024f..000000000
--- a/vendor/github.com/goamz/goamz/rds/types.go
+++ /dev/null
@@ -1,388 +0,0 @@
-package rds
-
-// AvailabilityZone contains Availability Zone information
-// See http://goo.gl/GWF4zF for more details.
-type AvailabilityZone struct {
- Name string `xml:"Name"`
- ProvisionedIopsCapable bool `xml:"ProvisionedIopsCapable"`
-}
-
-// CharacterSet represents a character set used by a Database Engine
-// See http://goo.gl/0BXwFp for more details.
-type CharacterSet struct {
- Name string `xml:"CharacterSetName"`
- Description string `xml:"CharacterSetDescription"`
-}
-
-// DBEngineVersion describes a version of a Database Engine
-// See http://goo.gl/a5l6cv for more details.
-type DBEngineVersion struct {
- DBEngineDescription string `xml:"DBEngineDescription"` // The description of the database engine
- DBEngineVersionDescription string `xml:"DBEngineVersionDescription"` // The description of the database engine version
- DBParameterGroupFamily string `xml:"DBParameterGroupFamily"` // The name of the DB parameter group family for the database engine
- DefaultCharacterSet CharacterSet `xml:"DefaultCharacterSet"` // The default character set for new instances of this engine version, if the CharacterSetName parameter of the CreateDBInstance API is not specified
- Engine string `xml:"Engine"` // The name of the database engine
- EngineVersion string `xml:"EngineVersion"` // The version number of the database engine
- SupportedCharacterSets []CharacterSet `xml:"SupportedCharacterSets"` // A list of the character sets supported by this engine for the CharacterSetName parameter of the CreateDBInstance API
-}
-
-// DBInstance encapsulates an instance of a Database
-// See http://goo.gl/rQFpAe for more details.
-type DBInstance struct {
- AllocatedStorage int `xml:"AllocatedStorage"` // Specifies the allocated storage size specified in gigabytes.
- AutoMinorVersionUpgrade bool `xml:"AutoMinorVersionUpgrade"` // Indicates that minor version patches are applied automatically.
- AvailabilityZone string `xml:"AvailabilityZone"` // Specifies the name of the Availability Zone the DB instance is located in.
- BackupRetentionPeriod int `xml:"BackupRetentionPeriod"` // Specifies the number of days for which automatic DB snapshots are retained.
- CharacterSetName string `xml:"CharacterSetName"` // If present, specifies the name of the character set that this instance is associated with.
- DBInstanceClass string `xml:"DBInstanceClass"` // Contains the name of the compute and memory capacity class of the DB instance.
- DBInstanceIdentifier string `xml:"DBInstanceIdentifier"` // Contains a user-supplied database identifier. This is the unique key that identifies a DB instance.
- DBInstanceStatus string `xml:"DBInstanceStatus"` // Specifies the current state of this database.
- DBName string `xml:"DBName"` // The meaning of this parameter differs according to the database engine you use.
- DBParameterGroups []DBParameterGroupStatus `xml:"DBParameterGroups>DBParameterGroup"` // Provides the list of DB parameter groups applied to this DB instance.
- DBSecurityGroups []DBSecurityGroupMembership `xml:"DBSecurityGroups>DBSecurityGroup"` // Provides List of DB security group elements containing only DBSecurityGroup.Name and DBSecurityGroup.Status subelements.
- DBSubnetGroup DBSubnetGroup `xml:"DBSubnetGroup"` // Specifies information on the subnet group associated with the DB instance, including the name, description, and subnets in the subnet group.
- Endpoint Endpoint `xml:"Endpoint"` // Specifies the connection endpoint.
- Engine string `xml:"Engine"` // Provides the name of the database engine to be used for this DB instance.
- EngineVersion string `xml:"EngineVersion"` // Indicates the database engine version.
- InstanceCreateTime string `xml:"InstanceCreateTime"` // Provides the date and time the DB instance was created.
- Iops int `xml:"Iops"` // Specifies the Provisioned IOPS (I/O operations per second) value.
- LatestRestorableTime string `xml:"LatestRestorableTime"` // Specifies the latest time to which a database can be restored with point-in-time restore.
- LicenseModel string `xml:"LicenseModel"` // License model information for this DB instance.
- MasterUsername string `xml:"MasterUsername"` // Contains the master username for the DB instance.
- MultiAZ bool `xml:"MultiAZ"` // Specifies if the DB instance is a Multi-AZ deployment.
- OptionGroupMemberships []OptionGroupMembership `xml:"OptionGroupMemberships>OptionGroupMembership"` // Provides the list of option group memberships for this DB instance.
- PendingModifiedValues PendingModifiedValues `xml:"PendingModifiedValues"` // Specifies that changes to the DB instance are pending. This element is only included when changes are pending. Specific changes are identified by subelements.
- PreferredBackupWindow string `xml:"PreferredBackupWindow"` // Specifies the daily time range during which automated backups are created if automated backups are enabled, as determined by the BackupRetentionPeriod.
- PreferredMaintenanceWindow string `xml:"PreferredMaintenanceWindow"` // Specifies the weekly time range (in UTC) during which system maintenance can occur.
- PubliclyAccessible bool `xml:"PubliclyAccessible"` // Specifies the accessibility options for the DB instance. A value of true specifies an Internet-facing instance with a publicly resolvable DNS name, which resolves to a public IP address. A value of false specifies an internal instance with a DNS name that resolves to a private IP address.
- ReadReplicaDBInstanceIdentifiers []string `xml:"ReadReplicaDBInstanceIdentifiers"` // Contains one or more identifiers of the read replicas associated with this DB instance.
- ReadReplicaSourceDBInstanceIdentifier string `xml:"ReadReplicaSourceDBInstanceIdentifier"` // Contains the identifier of the source DB instance if this DB instance is a read replica.
- SecondaryAvailabilityZone string `xml:"SecondaryAvailabilityZone"` // If present, specifies the name of the secondary Availability Zone for a DB instance with multi-AZ support.
- StatusInfos []DBInstanceStatusInfo `xml:"StatusInfos"` // The status of a read replica. If the instance is not a read replica, this will be blank.
- VpcSecurityGroups []VpcSecurityGroupMembership `xml:"VpcSecurityGroups"` // Provides List of VPC security group elements that the DB instance belongs to.
-}
-
-// DBInstanceStatusInfo provides a list of status information for a DB instance
-// See http://goo.gl/WuePdz for more details.
-type DBInstanceStatusInfo struct {
- Message string `xml:"Message"` // Details of the error if there is an error for the instance. If the instance is not in an error state, this value is blank.
- Normal bool `xml:"Normal"` // Boolean value that is true if the instance is operating normally, or false if the instance is in an error state.
- Status string `xml:"Status"` // Status of the DB instance. For a StatusType of read replica, the values can be replicating, error, stopped, or terminated.
- StatusType string `xml:"StatusType"` // This value is currently "read replication."
-}
-
-// DBParameterGroup contains the result of a successful invocation of the CreateDBParameterGroup action
-// See http://goo.gl/a8BCTy for more details.
-type DBParameterGroup struct {
- Name string `xml:"DBParameterGroupName"`
- Description string `xml:"Description"`
- Family string `xml:"DBParameterGroupFamily"`
-}
-
-// DBParameterGroupStatus represents the status of the DB parameter group
-// See http://goo.gl/X318cI for more details.
-type DBParameterGroupStatus struct {
- Name string `xml:"DBParameterGroupName"`
- Status string `xml:"ParameterApplyStatus"`
-}
-
-// DBSecurityGroup represents a RDS DB Security Group which controls network access to a DB instance that is not inside a VPC
-// See http://goo.gl/JF5oJy for more details.
-type DBSecurityGroup struct {
- Name string `xml:"DBSecurityGroupName"`
- Description string `xml:"DBSecurityGroupDescription"`
- EC2SecurityGroups []EC2SecurityGroup `xml:"EC2SecurityGroups"`
- IPRanges []IPRange `xml:"IPRanges"`
- OwnerId string `xml:"OwnerId"`
- VpcId string `xml:"VpcId"`
-}
-
-// DBSecurityGroupMembership represents a DBSecurityGroup which a Database Instance belongs to
-// See http://goo.gl/QjTK0b for more details.
-type DBSecurityGroupMembership struct {
- Name string `xml:"DBSecurityGroupName"`
- Status string `xml:"Status"`
-}
-
-// DBSnapshot represents a snapshot of a Database (a backup of the Instance data)
-// See http://goo.gl/wkf0L9 for more details.
-type DBSnapshot struct {
- AllocatedStorage int `xml:"AllocatedStorage"` // Specifies the allocated storage size in gigabytes (GB)
- AvailabilityZone string `xml:"AvailabilityZone"`
- DBInstanceIdentifier string `xml:"DBInstanceIdentifier"`
- DBSnapshotIdentifier string `xml:"DBSnapshotIdentifier"`
- Engine string `xml:"Engine"`
- EngineVersion string `xml:"EngineVersion"`
- InstanceCreateTime string `xml:"InstanceCreateTime"`
- Iops int `xml:"Iops"`
- LicenseModel string `xml:"LicenseModel"`
- MasterUsername string `xml:"MasterUsername"`
- OptionGroupName string `xml:"OptionGroupName"`
- PercentProgress int `xml:"PercentProgress"`
- Port int `xml:"Port"`
- SnapshotCreateTime string `xml:"SnapshotCreateTime"`
- SnapshotType string `xml:"SnapshotType"`
- SourceRegion string `xml:"SourceRegion"`
- Status string `xml:"Status"`
- VpcId string `xml:"VpcId"`
-}
-
-// DBSubnetGroup is a collection of subnets that is designated for an RDS DB Instance in a VPC
-// See http://goo.gl/8vMPkE for more details.
-type DBSubnetGroup struct {
- Name string `xml:"DBSubnetGroupName"`
- Description string `xml:"DBSubnetGroupDescription"`
- Status string `xml:"SubnetGroupStatus"`
- Subnets []Subnet `xml:"Subnets>Subnet"`
- VpcId string `xml:"VpcId"`
-}
-
-// EC2SecurityGroup a standard EC2 Security Group which can be assigned to a DB Instance
-// See http://goo.gl/AWavZ2 for more details.
-type EC2SecurityGroup struct {
- Id string `xml:"EC2SecurityGroupId"`
- Name string `xml:"EC2SecurityGroupName"`
- OwnerId string `xml:"EC2SecurityGroupOwnerId"` // The AWS ID of the owner of the EC2 security group
- Status string `xml:"Status"` // Status can be "authorizing", "authorized", "revoking", and "revoked"
-}
-
-// Endpoint encapsulates the connection endpoint for a DB Instance
-// See http://goo.gl/jefsJ4 for more details.
-type Endpoint struct {
- Address string `xml:"Address"`
- Port int `xml:"Port"`
-}
-
-// EngineDefaults describes the system parameter information for a given database engine
-// See http://goo.gl/XFy7Wv for more details.
-type EngineDefaults struct {
- DBParameterGroupFamily string `xml:"DBParameterGroupFamily"`
- Marker string `xml:"Marker"`
- Parameters []Parameter `xml:"Parameters"`
-}
-
-// Event encapsulates events related to DB instances, DB security groups, DB snapshots, and DB parameter groups
-// See http://goo.gl/6fUQow for more details.
-type Event struct {
- Date string `xml:"Date"` // Specifies the date and time of the event
- EventCategories []string `xml:"EventCategories"` // Specifies the category for the event
- Message string `xml:"Message"` // Provides the text of this event
- SourceIdentifier string `xml:"SourceIdentifier"` // Provides the identifier for the source of the event
- SourceType string `xml:"SourceType"` // Valid Values: db-instance | db-parameter-group | db-security-group | db-snapshot
-}
-
-// EventCategoriesMap encapsulates event categories for the specified source type
-// See http://goo.gl/9VY3aS for more details.
-type EventCategoriesMap struct {
- EventCategories []string `xml:"EventCategories"`
- SourceType string `xml:"SourceType"`
-}
-
-// EventSubscription describes a subscription, for a customer account, to a series of events
-// See http://goo.gl/zgNdXw for more details.
-type EventSubscription struct {
- CustSubscriptionId string `xml:"CustSubscriptionId"` // The RDS event notification subscription Id
- CustomerAwsId string `xml:"CustomerAwsId"` // The AWS customer account associated with the RDS event notification subscription
- Enabled bool `xml:"Enabled"` // True indicates the subscription is enabled
- EventCategoriesList []string `xml:"EventCategoriesList"` // A list of event categories for the RDS event notification subscription
- SnsTopicArn string `xml:"SnsTopicArn"` // The topic ARN of the RDS event notification subscription
- SourceIdsList []string `xml:"SourceIdsList"` // A list of source Ids for the RDS event notification subscription
- SourceType string `xml:"SourceType"` // The source type for the RDS event notification subscription
- Status string `xml:"Status"` // Can be one of the following: creating | modifying | deleting | active | no-permission | topic-not-exist
- SubscriptionCreationTime string `xml:"SubscriptionCreationTime"` // The time the RDS event notification subscription was created
-}
-
-// IPRange encapsulates an IP range (and its status) used by a DB Security Group
-// See http://goo.gl/VfntNm for more details.
-type IPRange struct {
- CIDRIP string `xml:"CIDRIP"`
- Status string `xml:"Status"` // Specifies the status of the IP range. Status can be "authorizing", "authorized", "revoking", and "revoked".
-}
-
-// Option describes a feature available for an RDS instance along with any settings applicable to it
-// See http://goo.gl/8DYY0J for more details.
-type Option struct {
- Name string `xml:"OptionName"`
- Description string `xml:"OptionDescription"`
- Settings []OptionSetting `xml:"OptionSettings"`
- Permanent bool `xml:"Permanent"`
- Persistent bool `xml:"Persistent"`
- Port int `xml:"Port"`
- DBSecurityGroupMemberships []DBSecurityGroupMembership `xml:"DBSecurityGroupMemberships"` // If the option requires access to a port, then this DB security group allows access to the port
- VpcSecurityGroupMemberships []VpcSecurityGroupMembership `xml:"VpcSecurityGroupMemberships"` // If the option requires access to a port, then this VPC security group allows access to the port
-}
-
-// OptionConfiguration is a list of all available options
-// See http://goo.gl/kkEzw1 for more details.
-type OptionConfiguration struct {
- OptionName string `xml:"OptionName"`
- OptionSettings []OptionSetting `xml:"OptionSettings"`
- Port int `xml:"Port"`
- DBSecurityGroupMemberships []string `xml:"DBSecurityGroupMemberships"`
- VpcSecurityGroupMemberships []string `xml:"VpcSecurityGroupMemberships"`
-}
-
-// OptionGroup represents a set of features, called options, that are available for a particular Amazon RDS DB instance
-// See http://goo.gl/NedBJl for more details.
-type OptionGroup struct {
- Name string `xml:"OptionGroupName"`
- Description string `xml:"OptionGroupDescription"`
- VpcId string `xml:"VpcId"`
- AllowsVpcAndNonVpcInstanceMemberships bool `xml:"AllowsVpcAndNonVpcInstanceMemberships"`
- EngineName string `xml:"EngineName"`
- MajorEngineVersion string `xml:"MajorEngineVersion"`
- Options []Option `xml:"Options"`
-}
-
-// OptionGroupMembership provides information on the option groups the DB instance is a member of
-// See http://goo.gl/XBW6j4 for more details.
-type OptionGroupMembership struct {
- Name string `xml:"OptionGroupName"` // The name of the option group that the instance belongs to
- Status string `xml:"Status"` // The status of the option group membership, e.g. in-sync, pending, pending-maintenance, applying
-}
-
-// OptionGroupOption represents an option within an option group
-// See http://goo.gl/jQYL0U for more details.
-type OptionGroupOption struct {
- DefaultPort int `xml:"DefaultPort"`
- Description string `xml:"Description"`
- EngineName string `xml:"EngineName"`
- MajorEngineVersion string `xml:"MajorEngineVersion"`
- MinimumRequiredMinorEngineVersion string `xml:"MinimumRequiredMinorEngineVersion"`
- Name string `xml:"Name"`
- OptionGroupOptionSettings []OptionGroupOptionSetting `xml:"OptionGroupOptionSettings"`
- OptionsDependedOn string `xml:"OptionsDependedOn"`
- Permanent bool `xml:"Permanent"`
- Persistent bool `xml:"Persistent"`
- PortRequired bool `xml:"PortRequired"`
-}
-
-// OptionGroupOptionSetting are used to display settings available for each option with their default values and other information
-// See http://goo.gl/9aIwNX for more details.
-type OptionGroupOptionSetting struct {
- AllowedValues string `xml:"AllowedValues"`
- ApplyType string `xml:"ApplyType"`
- DefaultValue string `xml:"DefaultValue"`
- IsModifiable bool `xml:"IsModifiable"`
- SettingDescription string `xml:"SettingDescription"`
- SettingName string `xml:"SettingName"`
-}
-
-// OptionSetting encapsulates modifiable settings for a particular option (a feature available for a Database Instance)
-// See http://goo.gl/VjOJmW for more details.
-type OptionSetting struct {
- Name string `xml:"Name"`
- Value string `xml:"Value"`
- Description string `xml:"Description"`
- AllowedValues string `xml:"AllowedValues"`
- ApplyType string `xml:"ApplyType"`
- DataType string `xml:"DataType"`
- DefaultValue string `xml:"DefaultValue"`
- IsCollection bool `xml:"IsCollection"`
- IsModifiable bool `xml:"IsModifiable"`
-}
-
-// OrderableDBInstanceOption contains a list of available options for a DB instance
-// See http://goo.gl/FVPeVC for more details.
-type OrderableDBInstanceOption struct {
- AvailabilityZones []AvailabilityZone `xml:"AvailabilityZones"`
- DBInstanceClass string `xml:"DBInstanceClass"`
- Engine string `xml:"Engine"`
- EngineVersion string `xml:"EngineVersion"`
- LicenseModel string `xml:"LicenseModel"`
- MultiAZCapable bool `xml:"MultiAZCapable"`
- ReadReplicaCapable bool `xml:"ReadReplicaCapable"`
- Vpc bool `xml:"Vpc"`
-}
-
-// Parameter is used as a request parameter in various actions
-// See http://goo.gl/cJmvVT for more details.
-type Parameter struct {
- AllowedValues string `xml:"AllowedValues"`
- ApplyMethod string `xml:"ApplyMethod"` // Valid Values: immediate | pending-reboot
- ApplyType string `xml:"ApplyType"`
- DataType string `xml:"DataType"`
- Description string `xml:"Description"`
- IsModifiable bool `xml:"IsModifiable"`
- MinimumEngineVersion string `xml:"MinimumEngineVersion"`
- ParameterName string `xml:"ParameterName"`
- ParameterValue string `xml:"ParameterValue"`
- Source string `xml:"Source"`
-}
-
-// PendingModifiedValues represents values modified in a ModifyDBInstance action
-// See http://goo.gl/UoXhLH for more details.
-type PendingModifiedValues struct {
- AllocatedStorage int `xml:"AllocatedStorage"`
- BackupRetentionPeriod int `xml:"BackupRetentionPeriod"`
- DBInstanceClass string `xml:"DBInstanceClass"`
- DBInstanceIdentifier string `xml:"DBInstanceIdentifier"`
- EngineVersion string `xml:"EngineVersion"`
- Iops int `xml:"Iops"`
- MasterUserPassword string `xml:"MasterUserPassword"`
- MultiAZ bool `xml:"MultiAZ"`
- Port string `xml:"Port"`
-}
-
-// RecurringCharge describes an amount that will be charged on a recurring basis with a given frequency
-// See http://goo.gl/3GDplh for more details.
-type RecurringCharge struct {
- Amount float64 `xml:"RecurringChargeAmount"`
- Frequency string `xml:"RecurringChargeFrequency"`
-}
-
-// ReservedDBInstance encapsulates a reserved Database Instance
-// See http://goo.gl/mjLhNI for more details.
-type ReservedDBInstance struct {
- CurrencyCode string `xml:"CurrencyCode"`
- DBInstanceClass string `xml:"DBInstanceClass"`
- DBInstanceCount int `xml:"DBInstanceCount"`
- Duration int `xml:"Duration"`
- FixedPrice float64 `xml:"FixedPrice"`
- MultiAZ bool `xml:"MultiAZ"`
- OfferingType string `xml:"OfferingType"`
- ProductDescription string `xml:"ProductDescription"`
- RecurringCharges []RecurringCharge `xml:"RecurringCharges"`
- ReservedDBInstanceId string `xml:"ReservedDBInstanceId"`
- ReservedDBInstancesOfferingId string `xml:"ReservedDBInstancesOfferingId"`
- StartTime string `xml:"StartTime"`
- State string `xml:"State"`
- UsagePrice float64 `xml:"UsagePrice"`
-}
-
-// ReservedDBInstancesOffering describes an available Reserved DB instance offering which can be purchased
-// See http://goo.gl/h5s8e6 for more details.
-type ReservedDBInstancesOffering struct {
- CurrencyCode string `xml:"CurrencyCode"`
- DBInstanceClass string `xml:"DBInstanceClass"`
- Duration int `xml:"Duration"`
- FixedPrice float64 `xml:"FixedPrice"`
- MultiAZ bool `xml:"MultiAZ"`
- OfferingType string `xml:"OfferingType"`
- ProductDescription string `xml:"ProductDescription"`
- RecurringCharges []RecurringCharge `xml:"RecurringCharges"`
- ReservedDBInstancesOfferingId string `xml:"ReservedDBInstancesOfferingId"`
- UsagePrice float64 `xml:"UsagePrice"`
-}
-
-// Subnet describes an EC2 subnet, along with its status and location
-// See http://goo.gl/Nc8ymd for more details.
-type Subnet struct {
- Id string `xml:"SubnetIdentifier"`
- Status string `xml:"SubnetStatus"`
- AvailabilityZone AvailabilityZone `xml:"SubnetAvailabilityZone"`
-}
-
-// Tag represents metadata assigned to an Amazon RDS resource consisting of a key-value pair
-// See http://goo.gl/YnXRrE for more details.
-type Tag struct {
- Key string `xml:"Key"`
- Value string `xml:"Value"`
-}
-
-// VpcSecurityGroupMembership describes a standard VPC Security Group which has been assigned to a DB Instance located in a VPC
-// See http://goo.gl/UIvmlS for more details.
-type VpcSecurityGroupMembership struct {
- Id string `xml:"VpcSecurityGroupId"`
- Status string `xml:"Status"`
-}
diff --git a/vendor/github.com/goamz/goamz/route53/route53.go b/vendor/github.com/goamz/goamz/route53/route53.go
deleted file mode 100644
index 0e26a6f73..000000000
--- a/vendor/github.com/goamz/goamz/route53/route53.go
+++ /dev/null
@@ -1,254 +0,0 @@
-package route53
-
-import (
- "bytes"
- "encoding/xml"
- "fmt"
- "github.com/goamz/goamz/aws"
- "io"
- "net/http"
-)
-
-type Route53 struct {
- Auth aws.Auth
- Endpoint string
- Signer *aws.Route53Signer
- Service *aws.Service
-}
-
-const route53_host = "https://route53.amazonaws.com"
-
-// Factory for the route53 type
-func NewRoute53(auth aws.Auth) (*Route53, error) {
- signer := aws.NewRoute53Signer(auth)
-
- return &Route53{
- Auth: auth,
- Signer: signer,
- Endpoint: route53_host + "/2013-04-01/hostedzone",
- }, nil
-}
-
-// General Structs used in all types of requests
-type HostedZone struct {
- XMLName xml.Name `xml:"HostedZone"`
- Id string
- Name string
- CallerReference string
- Config Config
- ResourceRecordSetCount int
-}
-
-type Config struct {
- XMLName xml.Name `xml:"Config"`
- Comment string
-}
-
-// Structs for getting the existing Hosted Zones
-type ListHostedZonesResponse struct {
- XMLName xml.Name `xml:"ListHostedZonesResponse"`
- HostedZones []HostedZone `xml:"HostedZones>HostedZone"`
- Marker string
- IsTruncated bool
- NextMarker string
- MaxItems int
-}
-
-// Structs for Creating a New Host
-type CreateHostedZoneRequest struct {
- XMLName xml.Name `xml:"CreateHostedZoneRequest"`
- Xmlns string `xml:"xmlns,attr"`
- Name string
- CallerReference string
- HostedZoneConfig HostedZoneConfig
-}
-
-type ResourceRecordValue struct {
- Value string `xml:"Value"`
-}
-
-type AliasTarget struct {
- HostedZoneId string `xml:"HostedZoneId"`
- DNSName string `xml:"DNSName"`
- EvaluateTargetHealth bool `xml:"EvaluateTargetHealth"`
-}
-
-// Wrapper for all the different resource record sets
-type ResourceRecordSet interface{}
-
-// Basic Change
-type Change struct {
- Action string `xml:"Action"`
- Name string `xml:"ResourceRecordSet>Name"`
- Type string `xml:"ResourceRecordSet>Type"`
- TTL int `xml:"ResourceRecordSet>TTL,omitempty"`
- Values []ResourceRecordValue `xml:"ResourceRecordSet>ResourceRecords>ResourceRecord"`
- HealthCheckId string `xml:"ResourceRecordSet>HealthCheckId,omitempty"`
-}
-
-// Basic Resource Recod Set
-type BasicResourceRecordSet struct {
- Action string `xml:"Action"`
- Name string `xml:"ResourceRecordSet>Name"`
- Type string `xml:"ResourceRecordSet>Type"`
- TTL int `xml:"ResourceRecordSet>TTL,omitempty"`
- Values []ResourceRecordValue `xml:"ResourceRecordSet>ResourceRecords>ResourceRecord"`
- HealthCheckId string `xml:"ResourceRecordSet>HealthCheckId,omitempty"`
-}
-
-// Alias Resource Record Set
-type AliasResourceRecordSet struct {
- Action string `xml:"Action"`
- Name string `xml:"ResourceRecordSet>Name"`
- Type string `xml:"ResourceRecordSet>Type"`
- AliasTarget AliasTarget `xml:"ResourceRecordSet>AliasTarget"`
- HealthCheckId string `xml:"ResourceRecordSet>HealthCheckId,omitempty"`
-}
-
-type ChangeResourceRecordSetsRequest struct {
- XMLName xml.Name `xml:"ChangeResourceRecordSetsRequest"`
- Xmlns string `xml:"xmlns,attr"`
- Changes []ResourceRecordSet `xml:"ChangeBatch>Changes>Change"`
-}
-
-type HostedZoneConfig struct {
- XMLName xml.Name `xml:"HostedZoneConfig"`
- Comment string
-}
-
-type CreateHostedZoneResponse struct {
- XMLName xml.Name `xml:"CreateHostedZoneResponse"`
- HostedZone HostedZone
- ChangeInfo ChangeInfo
- DelegationSet DelegationSet
-}
-
-type ChangeResourceRecordSetsResponse struct {
- XMLName xml.Name `xml:"ChangeResourceRecordSetsResponse"`
- Id string `xml:"ChangeInfo>Id"`
- Status string `xml:"ChangeInfo>Status"`
- SubmittedAt string `xml:"ChangeInfo>SubmittedAt"`
-}
-
-type ChangeInfo struct {
- XMLName xml.Name `xml:"ChangeInfo"`
- Id string
- Status string
- SubmittedAt string
-}
-
-type DelegationSet struct {
- XMLName xml.Name `xml:"DelegationSet`
- NameServers NameServers
-}
-
-type NameServers struct {
- XMLName xml.Name `xml:"NameServers`
- NameServer []string
-}
-
-type GetHostedZoneResponse struct {
- XMLName xml.Name `xml:"GetHostedZoneResponse"`
- HostedZone HostedZone
- DelegationSet DelegationSet
-}
-
-type DeleteHostedZoneResponse struct {
- XMLName xml.Name `xml:"DeleteHostedZoneResponse"`
- Xmlns string `xml:"xmlns,attr"`
- ChangeInfo ChangeInfo
-}
-
-// query sends the specified HTTP request to the path and signs the request
-// with the required authentication and headers based on the Auth.
-//
-// Automatically decodes the response into the the result interface
-func (r *Route53) query(method string, path string, body io.Reader, result interface{}) error {
- var err error
-
- // Create the POST request and sign the headers
- req, err := http.NewRequest(method, path, body)
- r.Signer.Sign(req)
-
- // Send the request and capture the response
- client := &http.Client{}
- res, err := client.Do(req)
- if err != nil {
- return err
- }
-
- if method == "POST" {
- defer req.Body.Close()
- }
-
- if res.StatusCode != 201 && res.StatusCode != 200 {
- err = r.Service.BuildError(res)
- return err
- }
-
- err = xml.NewDecoder(res.Body).Decode(result)
-
- return err
-}
-
-// CreateHostedZone send a creation request to the AWS Route53 API
-func (r *Route53) CreateHostedZone(hostedZoneReq *CreateHostedZoneRequest) (*CreateHostedZoneResponse, error) {
- xmlBytes, err := xml.Marshal(hostedZoneReq)
- if err != nil {
- return nil, err
- }
-
- result := new(CreateHostedZoneResponse)
- err = r.query("POST", r.Endpoint, bytes.NewBuffer(xmlBytes), result)
-
- return result, err
-}
-
-// ChangeResourceRecordSet send a change resource record request to the AWS Route53 API
-func (r *Route53) ChangeResourceRecordSet(req *ChangeResourceRecordSetsRequest, zoneId string) (*ChangeResourceRecordSetsResponse, error) {
- xmlBytes, err := xml.Marshal(req)
- if err != nil {
- return nil, err
- }
- xmlBytes = []byte(xml.Header + string(xmlBytes))
-
- result := new(ChangeResourceRecordSetsResponse)
- path := fmt.Sprintf("%s/%s/rrset", r.Endpoint, zoneId)
- err = r.query("POST", path, bytes.NewBuffer(xmlBytes), result)
-
- return result, err
-}
-
-// ListedHostedZones fetches a collection of HostedZones through the AWS Route53 API
-func (r *Route53) ListHostedZones(marker string, maxItems int) (result *ListHostedZonesResponse, err error) {
- path := ""
-
- if marker == "" {
- path = fmt.Sprintf("%s?maxitems=%d", r.Endpoint, maxItems)
- } else {
- path = fmt.Sprintf("%s?marker=%v&maxitems=%d", r.Endpoint, marker, maxItems)
- }
-
- result = new(ListHostedZonesResponse)
- err = r.query("GET", path, nil, result)
-
- return
-}
-
-// GetHostedZone fetches a particular hostedzones DelegationSet by id
-func (r *Route53) GetHostedZone(id string) (result *GetHostedZoneResponse, err error) {
- result = new(GetHostedZoneResponse)
- err = r.query("GET", fmt.Sprintf("%s/%v", r.Endpoint, id), nil, result)
-
- return
-}
-
-// DeleteHostedZone deletes the hosted zone with the given id
-func (r *Route53) DeleteHostedZone(id string) (result *DeleteHostedZoneResponse, err error) {
- path := fmt.Sprintf("%s/%s", r.Endpoint, id)
-
- result = new(DeleteHostedZoneResponse)
- err = r.query("DELETE", path, nil, result)
-
- return
-}
diff --git a/vendor/github.com/goamz/goamz/s3/export_test.go b/vendor/github.com/goamz/goamz/s3/export_test.go
deleted file mode 100644
index 4ff913cde..000000000
--- a/vendor/github.com/goamz/goamz/s3/export_test.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package s3
-
-import (
- "github.com/goamz/goamz/aws"
-)
-
-func Sign(auth aws.Auth, method, path string, params, headers map[string][]string) {
- sign(auth, method, path, params, headers)
-}
-
-func SetListPartsMax(n int) {
- listPartsMax = n
-}
-
-func SetListMultiMax(n int) {
- listMultiMax = n
-}
diff --git a/vendor/github.com/goamz/goamz/s3/multi.go b/vendor/github.com/goamz/goamz/s3/multi.go
deleted file mode 100644
index 348ead300..000000000
--- a/vendor/github.com/goamz/goamz/s3/multi.go
+++ /dev/null
@@ -1,439 +0,0 @@
-package s3
-
-import (
- "bytes"
- "crypto/md5"
- "encoding/base64"
- "encoding/hex"
- "encoding/xml"
- "errors"
- "io"
- "sort"
- "strconv"
-)
-
-// Multi represents an unfinished multipart upload.
-//
-// Multipart uploads allow sending big objects in smaller chunks.
-// After all parts have been sent, the upload must be explicitly
-// completed by calling Complete with the list of parts.
-//
-// See http://goo.gl/vJfTG for an overview of multipart uploads.
-type Multi struct {
- Bucket *Bucket
- Key string
- UploadId string
-}
-
-// That's the default. Here just for testing.
-var listMultiMax = 1000
-
-type listMultiResp struct {
- NextKeyMarker string
- NextUploadIdMarker string
- IsTruncated bool
- Upload []Multi
- CommonPrefixes []string `xml:"CommonPrefixes>Prefix"`
-}
-
-// ListMulti returns the list of unfinished multipart uploads in b.
-//
-// The prefix parameter limits the response to keys that begin with the
-// specified prefix. You can use prefixes to separate a bucket into different
-// groupings of keys (to get the feeling of folders, for example).
-//
-// The delim parameter causes the response to group all of the keys that
-// share a common prefix up to the next delimiter in a single entry within
-// the CommonPrefixes field. You can use delimiters to separate a bucket
-// into different groupings of keys, similar to how folders would work.
-//
-// See http://goo.gl/ePioY for details.
-func (b *Bucket) ListMulti(prefix, delim string) (multis []*Multi, prefixes []string, err error) {
- params := map[string][]string{
- "uploads": {""},
- "max-uploads": {strconv.FormatInt(int64(listMultiMax), 10)},
- "prefix": {prefix},
- "delimiter": {delim},
- }
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- req := &request{
- method: "GET",
- bucket: b.Name,
- params: params,
- }
- var resp listMultiResp
- err := b.S3.query(req, &resp)
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
- if err != nil {
- return nil, nil, err
- }
- for i := range resp.Upload {
- multi := &resp.Upload[i]
- multi.Bucket = b
- multis = append(multis, multi)
- }
- prefixes = append(prefixes, resp.CommonPrefixes...)
- if !resp.IsTruncated {
- return multis, prefixes, nil
- }
- params["key-marker"] = []string{resp.NextKeyMarker}
- params["upload-id-marker"] = []string{resp.NextUploadIdMarker}
- attempt = b.S3.AttemptStrategy.Start() // Last request worked.
- }
- panic("unreachable")
-}
-
-// Multi returns a multipart upload handler for the provided key
-// inside b. If a multipart upload exists for key, it is returned,
-// otherwise a new multipart upload is initiated with contType and perm.
-func (b *Bucket) Multi(key, contType string, perm ACL) (*Multi, error) {
- multis, _, err := b.ListMulti(key, "")
- if err != nil && !hasCode(err, "NoSuchUpload") {
- return nil, err
- }
- for _, m := range multis {
- if m.Key == key {
- return m, nil
- }
- }
- return b.InitMulti(key, contType, perm)
-}
-
-// InitMulti initializes a new multipart upload at the provided
-// key inside b and returns a value for manipulating it.
-//
-// See http://goo.gl/XP8kL for details.
-func (b *Bucket) InitMulti(key string, contType string, perm ACL) (*Multi, error) {
- headers := map[string][]string{
- "Content-Type": {contType},
- "Content-Length": {"0"},
- "x-amz-acl": {string(perm)},
- }
- params := map[string][]string{
- "uploads": {""},
- }
- req := &request{
- method: "POST",
- bucket: b.Name,
- path: key,
- headers: headers,
- params: params,
- }
- var err error
- var resp struct {
- UploadId string `xml:"UploadId"`
- }
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- err = b.S3.query(req, &resp)
- if !shouldRetry(err) {
- break
- }
- }
- if err != nil {
- return nil, err
- }
- return &Multi{Bucket: b, Key: key, UploadId: resp.UploadId}, nil
-}
-
-// PutPart sends part n of the multipart upload, reading all the content from r.
-// Each part, except for the last one, must be at least 5MB in size.
-//
-// See http://goo.gl/pqZer for details.
-func (m *Multi) PutPart(n int, r io.ReadSeeker) (Part, error) {
- partSize, _, md5b64, err := seekerInfo(r)
- if err != nil {
- return Part{}, err
- }
- return m.putPart(n, r, partSize, md5b64)
-}
-
-func (m *Multi) putPart(n int, r io.ReadSeeker, partSize int64, md5b64 string) (Part, error) {
- headers := map[string][]string{
- "Content-Length": {strconv.FormatInt(partSize, 10)},
- "Content-MD5": {md5b64},
- }
- params := map[string][]string{
- "uploadId": {m.UploadId},
- "partNumber": {strconv.FormatInt(int64(n), 10)},
- }
- for attempt := m.Bucket.S3.AttemptStrategy.Start(); attempt.Next(); {
- _, err := r.Seek(0, 0)
- if err != nil {
- return Part{}, err
- }
- req := &request{
- method: "PUT",
- bucket: m.Bucket.Name,
- path: m.Key,
- headers: headers,
- params: params,
- payload: r,
- }
- err = m.Bucket.S3.prepare(req)
- if err != nil {
- return Part{}, err
- }
- resp, err := m.Bucket.S3.run(req, nil)
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
- if err != nil {
- return Part{}, err
- }
- etag := resp.Header.Get("ETag")
- if etag == "" {
- return Part{}, errors.New("part upload succeeded with no ETag")
- }
- return Part{n, etag, partSize}, nil
- }
- panic("unreachable")
-}
-
-func seekerInfo(r io.ReadSeeker) (size int64, md5hex string, md5b64 string, err error) {
- _, err = r.Seek(0, 0)
- if err != nil {
- return 0, "", "", err
- }
- digest := md5.New()
- size, err = io.Copy(digest, r)
- if err != nil {
- return 0, "", "", err
- }
- sum := digest.Sum(nil)
- md5hex = hex.EncodeToString(sum)
- md5b64 = base64.StdEncoding.EncodeToString(sum)
- return size, md5hex, md5b64, nil
-}
-
-type Part struct {
- N int `xml:"PartNumber"`
- ETag string
- Size int64
-}
-
-type partSlice []Part
-
-func (s partSlice) Len() int { return len(s) }
-func (s partSlice) Less(i, j int) bool { return s[i].N < s[j].N }
-func (s partSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
-
-type listPartsResp struct {
- NextPartNumberMarker string
- IsTruncated bool
- Part []Part
-}
-
-// That's the default. Here just for testing.
-var listPartsMax = 1000
-
-// ListParts returns the list of previously uploaded parts in m,
-// ordered by part number.
-//
-// See http://goo.gl/ePioY for details.
-func (m *Multi) ListParts() ([]Part, error) {
- params := map[string][]string{
- "uploadId": {m.UploadId},
- "max-parts": {strconv.FormatInt(int64(listPartsMax), 10)},
- }
- var parts partSlice
- for attempt := m.Bucket.S3.AttemptStrategy.Start(); attempt.Next(); {
- req := &request{
- method: "GET",
- bucket: m.Bucket.Name,
- path: m.Key,
- params: params,
- }
- var resp listPartsResp
- err := m.Bucket.S3.query(req, &resp)
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
- if err != nil {
- return nil, err
- }
- parts = append(parts, resp.Part...)
- if !resp.IsTruncated {
- sort.Sort(parts)
- return parts, nil
- }
- params["part-number-marker"] = []string{resp.NextPartNumberMarker}
- attempt = m.Bucket.S3.AttemptStrategy.Start() // Last request worked.
- }
- panic("unreachable")
-}
-
-type ReaderAtSeeker interface {
- io.ReaderAt
- io.ReadSeeker
-}
-
-// PutAll sends all of r via a multipart upload with parts no larger
-// than partSize bytes, which must be set to at least 5MB.
-// Parts previously uploaded are either reused if their checksum
-// and size match the new part, or otherwise overwritten with the
-// new content.
-// PutAll returns all the parts of m (reused or not).
-func (m *Multi) PutAll(r ReaderAtSeeker, partSize int64) ([]Part, error) {
- old, err := m.ListParts()
- if err != nil && !hasCode(err, "NoSuchUpload") {
- return nil, err
- }
- reuse := 0 // Index of next old part to consider reusing.
- current := 1 // Part number of latest good part handled.
- totalSize, err := r.Seek(0, 2)
- if err != nil {
- return nil, err
- }
- first := true // Must send at least one empty part if the file is empty.
- var result []Part
-NextSection:
- for offset := int64(0); offset < totalSize || first; offset += partSize {
- first = false
- if offset+partSize > totalSize {
- partSize = totalSize - offset
- }
- section := io.NewSectionReader(r, offset, partSize)
- _, md5hex, md5b64, err := seekerInfo(section)
- if err != nil {
- return nil, err
- }
- for reuse < len(old) && old[reuse].N <= current {
- // Looks like this part was already sent.
- part := &old[reuse]
- etag := `"` + md5hex + `"`
- if part.N == current && part.Size == partSize && part.ETag == etag {
- // Checksum matches. Reuse the old part.
- result = append(result, *part)
- current++
- continue NextSection
- }
- reuse++
- }
-
- // Part wasn't found or doesn't match. Send it.
- part, err := m.putPart(current, section, partSize, md5b64)
- if err != nil {
- return nil, err
- }
- result = append(result, part)
- current++
- }
- return result, nil
-}
-
-type completeUpload struct {
- XMLName xml.Name `xml:"CompleteMultipartUpload"`
- Parts completeParts `xml:"Part"`
-}
-
-type completePart struct {
- PartNumber int
- ETag string
-}
-
-type completeParts []completePart
-
-func (p completeParts) Len() int { return len(p) }
-func (p completeParts) Less(i, j int) bool { return p[i].PartNumber < p[j].PartNumber }
-func (p completeParts) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-
-type completeResponse struct {
- // The element name: should be either CompleteMultipartUploadResult or Error.
- XMLName xml.Name
- // If the element was error, then it should have the following:
- Code string
- Message string
- RequestId string
- HostId string
-}
-
-// Complete assembles the given previously uploaded parts into the
-// final object. This operation may take several minutes.
-//
-// The complete call to AMZ may still fail after returning HTTP 200,
-// so even though it's unusued, the body of the reply must be demarshalled
-// and checked to see whether or not the complete succeeded.
-//
-// See http://goo.gl/2Z7Tw for details.
-func (m *Multi) Complete(parts []Part) error {
- params := map[string][]string{
- "uploadId": {m.UploadId},
- }
- c := completeUpload{}
- for _, p := range parts {
- c.Parts = append(c.Parts, completePart{p.N, p.ETag})
- }
- sort.Sort(c.Parts)
- data, err := xml.Marshal(&c)
- if err != nil {
- return err
- }
-
- // Setting Content-Length prevents breakage on DreamObjects
- for attempt := m.Bucket.S3.AttemptStrategy.Start(); attempt.Next(); {
- req := &request{
- method: "POST",
- bucket: m.Bucket.Name,
- path: m.Key,
- params: params,
- payload: bytes.NewReader(data),
- headers: map[string][]string{
- "Content-Length": []string{strconv.Itoa(len(data))},
- },
- }
-
- resp := &completeResponse{}
- err := m.Bucket.S3.query(req, resp)
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
- if err == nil && resp.XMLName.Local == "Error" {
- err = &Error{
- StatusCode: 200,
- Code: resp.Code,
- Message: resp.Message,
- RequestId: resp.RequestId,
- HostId: resp.HostId,
- }
- }
- return err
- }
- panic("unreachable")
-}
-
-// Abort deletes an unifinished multipart upload and any previously
-// uploaded parts for it.
-//
-// After a multipart upload is aborted, no additional parts can be
-// uploaded using it. However, if any part uploads are currently in
-// progress, those part uploads might or might not succeed. As a result,
-// it might be necessary to abort a given multipart upload multiple
-// times in order to completely free all storage consumed by all parts.
-//
-// NOTE: If the described scenario happens to you, please report back to
-// the goamz authors with details. In the future such retrying should be
-// handled internally, but it's not clear what happens precisely (Is an
-// error returned? Is the issue completely undetectable?).
-//
-// See http://goo.gl/dnyJw for details.
-func (m *Multi) Abort() error {
- params := map[string][]string{
- "uploadId": {m.UploadId},
- }
- for attempt := m.Bucket.S3.AttemptStrategy.Start(); attempt.Next(); {
- req := &request{
- method: "DELETE",
- bucket: m.Bucket.Name,
- path: m.Key,
- params: params,
- }
- err := m.Bucket.S3.query(req, nil)
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
- return err
- }
- panic("unreachable")
-}
diff --git a/vendor/github.com/goamz/goamz/s3/multi_test.go b/vendor/github.com/goamz/goamz/s3/multi_test.go
deleted file mode 100644
index 5c788d9cc..000000000
--- a/vendor/github.com/goamz/goamz/s3/multi_test.go
+++ /dev/null
@@ -1,373 +0,0 @@
-package s3_test
-
-import (
- "encoding/xml"
- "io"
- "io/ioutil"
- "strings"
-
- "github.com/goamz/goamz/s3"
- . "gopkg.in/check.v1"
-)
-
-func (s *S) TestInitMulti(c *C) {
- testServer.Response(200, nil, InitMultiResultDump)
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Header["Content-Type"], DeepEquals, []string{"text/plain"})
- c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
- c.Assert(req.Form["uploads"], DeepEquals, []string{""})
-
- c.Assert(multi.UploadId, Matches, "JNbR_[A-Za-z0-9.]+QQ--")
-}
-
-func (s *S) TestMultiNoPreviousUpload(c *C) {
- // Don't retry the NoSuchUpload error.
- s.DisableRetries()
-
- testServer.Response(404, nil, NoSuchUploadErrorDump)
- testServer.Response(200, nil, InitMultiResultDump)
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.Multi("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/")
- c.Assert(req.Form["uploads"], DeepEquals, []string{""})
- c.Assert(req.Form["prefix"], DeepEquals, []string{"multi"})
-
- req = testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form["uploads"], DeepEquals, []string{""})
-
- c.Assert(multi.UploadId, Matches, "JNbR_[A-Za-z0-9.]+QQ--")
-}
-
-func (s *S) TestMultiReturnOld(c *C) {
- testServer.Response(200, nil, ListMultiResultDump)
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.Multi("multi1", "text/plain", s3.Private)
- c.Assert(err, IsNil)
- c.Assert(multi.Key, Equals, "multi1")
- c.Assert(multi.UploadId, Equals, "iUVug89pPvSswrikD")
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/")
- c.Assert(req.Form["uploads"], DeepEquals, []string{""})
- c.Assert(req.Form["prefix"], DeepEquals, []string{"multi1"})
-}
-
-func (s *S) TestListParts(c *C) {
- testServer.Response(200, nil, InitMultiResultDump)
- testServer.Response(200, nil, ListPartsResultDump1)
- testServer.Response(404, nil, NoSuchUploadErrorDump) // :-(
- testServer.Response(200, nil, ListPartsResultDump2)
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- parts, err := multi.ListParts()
- c.Assert(err, IsNil)
- c.Assert(parts, HasLen, 3)
- c.Assert(parts[0].N, Equals, 1)
- c.Assert(parts[0].Size, Equals, int64(5))
- c.Assert(parts[0].ETag, Equals, `"ffc88b4ca90a355f8ddba6b2c3b2af5c"`)
- c.Assert(parts[1].N, Equals, 2)
- c.Assert(parts[1].Size, Equals, int64(5))
- c.Assert(parts[1].ETag, Equals, `"d067a0fa9dc61a6e7195ca99696b5a89"`)
- c.Assert(parts[2].N, Equals, 3)
- c.Assert(parts[2].Size, Equals, int64(5))
- c.Assert(parts[2].ETag, Equals, `"49dcd91231f801159e893fb5c6674985"`)
- testServer.WaitRequest()
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
- c.Assert(req.Form["max-parts"], DeepEquals, []string{"1000"})
-
- testServer.WaitRequest() // The internal error.
- req = testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
- c.Assert(req.Form["max-parts"], DeepEquals, []string{"1000"})
- c.Assert(req.Form["part-number-marker"], DeepEquals, []string{"2"})
-}
-
-func (s *S) TestPutPart(c *C) {
- headers := map[string]string{
- "ETag": `"26f90efd10d614f100252ff56d88dad8"`,
- }
- testServer.Response(200, nil, InitMultiResultDump)
- testServer.Response(200, headers, "")
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- part, err := multi.PutPart(1, strings.NewReader("<part 1>"))
- c.Assert(err, IsNil)
- c.Assert(part.N, Equals, 1)
- c.Assert(part.Size, Equals, int64(8))
- c.Assert(part.ETag, Equals, headers["ETag"])
-
- testServer.WaitRequest()
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
- c.Assert(req.Form["partNumber"], DeepEquals, []string{"1"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"8"})
- c.Assert(req.Header["Content-Md5"], DeepEquals, []string{"JvkO/RDWFPEAJS/1bYja2A=="})
-}
-
-func readAll(r io.Reader) string {
- data, err := ioutil.ReadAll(r)
- if err != nil {
- panic(err)
- }
- return string(data)
-}
-
-func (s *S) TestPutAllNoPreviousUpload(c *C) {
- // Don't retry the NoSuchUpload error.
- s.DisableRetries()
-
- etag1 := map[string]string{"ETag": `"etag1"`}
- etag2 := map[string]string{"ETag": `"etag2"`}
- etag3 := map[string]string{"ETag": `"etag3"`}
- testServer.Response(200, nil, InitMultiResultDump)
- testServer.Response(404, nil, NoSuchUploadErrorDump)
- testServer.Response(200, etag1, "")
- testServer.Response(200, etag2, "")
- testServer.Response(200, etag3, "")
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- parts, err := multi.PutAll(strings.NewReader("part1part2last"), 5)
- c.Assert(parts, HasLen, 3)
- c.Assert(parts[0].ETag, Equals, `"etag1"`)
- c.Assert(parts[1].ETag, Equals, `"etag2"`)
- c.Assert(parts[2].ETag, Equals, `"etag3"`)
- c.Assert(err, IsNil)
-
- // Init
- testServer.WaitRequest()
-
- // List old parts. Won't find anything.
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
-
- // Send part 1.
- req = testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form["partNumber"], DeepEquals, []string{"1"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"5"})
- c.Assert(readAll(req.Body), Equals, "part1")
-
- // Send part 2.
- req = testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form["partNumber"], DeepEquals, []string{"2"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"5"})
- c.Assert(readAll(req.Body), Equals, "part2")
-
- // Send part 3 with shorter body.
- req = testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form["partNumber"], DeepEquals, []string{"3"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"4"})
- c.Assert(readAll(req.Body), Equals, "last")
-}
-
-func (s *S) TestPutAllZeroSizeFile(c *C) {
- // Don't retry the NoSuchUpload error.
- s.DisableRetries()
-
- etag1 := map[string]string{"ETag": `"etag1"`}
- testServer.Response(200, nil, InitMultiResultDump)
- testServer.Response(404, nil, NoSuchUploadErrorDump)
- testServer.Response(200, etag1, "")
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- // Must send at least one part, so that completing it will work.
- parts, err := multi.PutAll(strings.NewReader(""), 5)
- c.Assert(parts, HasLen, 1)
- c.Assert(parts[0].ETag, Equals, `"etag1"`)
- c.Assert(err, IsNil)
-
- // Init
- testServer.WaitRequest()
-
- // List old parts. Won't find anything.
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
-
- // Send empty part.
- req = testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form["partNumber"], DeepEquals, []string{"1"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"0"})
- c.Assert(readAll(req.Body), Equals, "")
-}
-
-func (s *S) TestPutAllResume(c *C) {
- etag2 := map[string]string{"ETag": `"etag2"`}
- testServer.Response(200, nil, InitMultiResultDump)
- testServer.Response(200, nil, ListPartsResultDump1)
- testServer.Response(200, nil, ListPartsResultDump2)
- testServer.Response(200, etag2, "")
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- // "part1" and "part3" match the checksums in ResultDump1.
- // The middle one is a mismatch (it refers to "part2").
- parts, err := multi.PutAll(strings.NewReader("part1partXpart3"), 5)
- c.Assert(parts, HasLen, 3)
- c.Assert(parts[0].N, Equals, 1)
- c.Assert(parts[0].Size, Equals, int64(5))
- c.Assert(parts[0].ETag, Equals, `"ffc88b4ca90a355f8ddba6b2c3b2af5c"`)
- c.Assert(parts[1].N, Equals, 2)
- c.Assert(parts[1].Size, Equals, int64(5))
- c.Assert(parts[1].ETag, Equals, `"etag2"`)
- c.Assert(parts[2].N, Equals, 3)
- c.Assert(parts[2].Size, Equals, int64(5))
- c.Assert(parts[2].ETag, Equals, `"49dcd91231f801159e893fb5c6674985"`)
- c.Assert(err, IsNil)
-
- // Init
- testServer.WaitRequest()
-
- // List old parts, broken in two requests.
- for i := 0; i < 2; i++ {
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- }
-
- // Send part 2, as it didn't match the checksum.
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form["partNumber"], DeepEquals, []string{"2"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"5"})
- c.Assert(readAll(req.Body), Equals, "partX")
-}
-
-func (s *S) TestMultiComplete(c *C) {
- testServer.Response(200, nil, InitMultiResultDump)
- // Note the 200 response. Completing will hold the connection on some
- // kind of long poll, and may return a late error even after a 200.
- testServer.Response(200, nil, InternalErrorDump)
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- err = multi.Complete([]s3.Part{{2, `"ETag2"`, 32}, {1, `"ETag1"`, 64}})
- // returns InternalErrorDump in the payload, which should manifest as
- // an error.
- c.Assert(err, NotNil)
-
- testServer.WaitRequest()
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
-
- var payload struct {
- XMLName xml.Name
- Part []struct {
- PartNumber int
- ETag string
- }
- }
-
- dec := xml.NewDecoder(req.Body)
- err = dec.Decode(&payload)
- c.Assert(err, IsNil)
-
- c.Assert(payload.XMLName.Local, Equals, "CompleteMultipartUpload")
- c.Assert(len(payload.Part), Equals, 2)
- c.Assert(payload.Part[0].PartNumber, Equals, 1)
- c.Assert(payload.Part[0].ETag, Equals, `"ETag1"`)
- c.Assert(payload.Part[1].PartNumber, Equals, 2)
- c.Assert(payload.Part[1].ETag, Equals, `"ETag2"`)
-}
-
-func (s *S) TestMultiAbort(c *C) {
- testServer.Response(200, nil, InitMultiResultDump)
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("sample")
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
-
- err = multi.Abort()
- c.Assert(err, IsNil)
-
- testServer.WaitRequest()
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "DELETE")
- c.Assert(req.URL.Path, Equals, "/sample/multi")
- c.Assert(req.Form.Get("uploadId"), Matches, "JNbR_[A-Za-z0-9.]+QQ--")
-}
-
-func (s *S) TestListMulti(c *C) {
- testServer.Response(200, nil, ListMultiResultDump)
-
- b := s.s3.Bucket("sample")
-
- multis, prefixes, err := b.ListMulti("", "/")
- c.Assert(err, IsNil)
- c.Assert(prefixes, DeepEquals, []string{"a/", "b/"})
- c.Assert(multis, HasLen, 2)
- c.Assert(multis[0].Key, Equals, "multi1")
- c.Assert(multis[0].UploadId, Equals, "iUVug89pPvSswrikD")
- c.Assert(multis[1].Key, Equals, "multi2")
- c.Assert(multis[1].UploadId, Equals, "DkirwsSvPp98guVUi")
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/sample/")
- c.Assert(req.Form["uploads"], DeepEquals, []string{""})
- c.Assert(req.Form["prefix"], DeepEquals, []string{""})
- c.Assert(req.Form["delimiter"], DeepEquals, []string{"/"})
- c.Assert(req.Form["max-uploads"], DeepEquals, []string{"1000"})
-}
diff --git a/vendor/github.com/goamz/goamz/s3/responses_test.go b/vendor/github.com/goamz/goamz/s3/responses_test.go
deleted file mode 100644
index 414ede0a7..000000000
--- a/vendor/github.com/goamz/goamz/s3/responses_test.go
+++ /dev/null
@@ -1,202 +0,0 @@
-package s3_test
-
-var GetObjectErrorDump = `
-<?xml version="1.0" encoding="UTF-8"?>
-<Error>
- <Code>NoSuchBucket</Code>
- <Message>The specified bucket does not exist</Message>
- <BucketName>non-existent-bucket</BucketName>
- <RequestId>3F1B667FAD71C3D8</RequestId>
- <HostId>L4ee/zrm1irFXY5F45fKXIRdOf9ktsKY/8TDVawuMK2jWRb1RF84i1uBzkdNqS5D</HostId>
-</Error>
-`
-
-var GetListResultDump1 = `
-<?xml version="1.0" encoding="UTF-8"?>
-<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01">
- <Name>quotes</Name>
- <Prefix>N</Prefix>
- <IsTruncated>false</IsTruncated>
- <Contents>
- <Key>Nelson</Key>
- <LastModified>2006-01-01T12:00:00.000Z</LastModified>
- <ETag>&quot;828ef3fdfa96f00ad9f27c383fc9ac7f&quot;</ETag>
- <Size>5</Size>
- <StorageClass>STANDARD</StorageClass>
- <Owner>
- <ID>bcaf161ca5fb16fd081034f</ID>
- <DisplayName>webfile</DisplayName>
- </Owner>
- </Contents>
- <Contents>
- <Key>Neo</Key>
- <LastModified>2006-01-01T12:00:00.000Z</LastModified>
- <ETag>&quot;828ef3fdfa96f00ad9f27c383fc9ac7f&quot;</ETag>
- <Size>4</Size>
- <StorageClass>STANDARD</StorageClass>
- <Owner>
- <ID>bcaf1ffd86a5fb16fd081034f</ID>
- <DisplayName>webfile</DisplayName>
- </Owner>
- </Contents>
-</ListBucketResult>
-`
-
-var GetListResultDump2 = `
-<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
- <Name>example-bucket</Name>
- <Prefix>photos/2006/</Prefix>
- <Marker>some-marker</Marker>
- <MaxKeys>1000</MaxKeys>
- <Delimiter>/</Delimiter>
- <IsTruncated>false</IsTruncated>
-
- <CommonPrefixes>
- <Prefix>photos/2006/feb/</Prefix>
- </CommonPrefixes>
- <CommonPrefixes>
- <Prefix>photos/2006/jan/</Prefix>
- </CommonPrefixes>
-</ListBucketResult>
-`
-
-var InitMultiResultDump = `
-<?xml version="1.0" encoding="UTF-8"?>
-<InitiateMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
- <Bucket>sample</Bucket>
- <Key>multi</Key>
- <UploadId>JNbR_cMdwnGiD12jKAd6WK2PUkfj2VxA7i4nCwjE6t71nI9Tl3eVDPFlU0nOixhftH7I17ZPGkV3QA.l7ZD.QQ--</UploadId>
-</InitiateMultipartUploadResult>
-`
-
-var ListPartsResultDump1 = `
-<?xml version="1.0" encoding="UTF-8"?>
-<ListPartsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
- <Bucket>sample</Bucket>
- <Key>multi</Key>
- <UploadId>JNbR_cMdwnGiD12jKAd6WK2PUkfj2VxA7i4nCwjE6t71nI9Tl3eVDPFlU0nOixhftH7I17ZPGkV3QA.l7ZD.QQ--</UploadId>
- <Initiator>
- <ID>bb5c0f63b0b25f2d099c</ID>
- <DisplayName>joe</DisplayName>
- </Initiator>
- <Owner>
- <ID>bb5c0f63b0b25f2d099c</ID>
- <DisplayName>joe</DisplayName>
- </Owner>
- <StorageClass>STANDARD</StorageClass>
- <PartNumberMarker>0</PartNumberMarker>
- <NextPartNumberMarker>2</NextPartNumberMarker>
- <MaxParts>2</MaxParts>
- <IsTruncated>true</IsTruncated>
- <Part>
- <PartNumber>1</PartNumber>
- <LastModified>2013-01-30T13:45:51.000Z</LastModified>
- <ETag>&quot;ffc88b4ca90a355f8ddba6b2c3b2af5c&quot;</ETag>
- <Size>5</Size>
- </Part>
- <Part>
- <PartNumber>2</PartNumber>
- <LastModified>2013-01-30T13:45:52.000Z</LastModified>
- <ETag>&quot;d067a0fa9dc61a6e7195ca99696b5a89&quot;</ETag>
- <Size>5</Size>
- </Part>
-</ListPartsResult>
-`
-
-var ListPartsResultDump2 = `
-<?xml version="1.0" encoding="UTF-8"?>
-<ListPartsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
- <Bucket>sample</Bucket>
- <Key>multi</Key>
- <UploadId>JNbR_cMdwnGiD12jKAd6WK2PUkfj2VxA7i4nCwjE6t71nI9Tl3eVDPFlU0nOixhftH7I17ZPGkV3QA.l7ZD.QQ--</UploadId>
- <Initiator>
- <ID>bb5c0f63b0b25f2d099c</ID>
- <DisplayName>joe</DisplayName>
- </Initiator>
- <Owner>
- <ID>bb5c0f63b0b25f2d099c</ID>
- <DisplayName>joe</DisplayName>
- </Owner>
- <StorageClass>STANDARD</StorageClass>
- <PartNumberMarker>2</PartNumberMarker>
- <NextPartNumberMarker>3</NextPartNumberMarker>
- <MaxParts>2</MaxParts>
- <IsTruncated>false</IsTruncated>
- <Part>
- <PartNumber>3</PartNumber>
- <LastModified>2013-01-30T13:46:50.000Z</LastModified>
- <ETag>&quot;49dcd91231f801159e893fb5c6674985&quot;</ETag>
- <Size>5</Size>
- </Part>
-</ListPartsResult>
-`
-
-var ListMultiResultDump = `
-<?xml version="1.0"?>
-<ListMultipartUploadsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
- <Bucket>goamz-test-bucket-us-east-1-akiajk3wyewhctyqbf7a</Bucket>
- <KeyMarker/>
- <UploadIdMarker/>
- <NextKeyMarker>multi1</NextKeyMarker>
- <NextUploadIdMarker>iUVug89pPvSswrikD72p8uO62EzhNtpDxRmwC5WSiWDdK9SfzmDqe3xpP1kMWimyimSnz4uzFc3waVM5ufrKYQ--</NextUploadIdMarker>
- <Delimiter>/</Delimiter>
- <MaxUploads>1000</MaxUploads>
- <IsTruncated>false</IsTruncated>
- <Upload>
- <Key>multi1</Key>
- <UploadId>iUVug89pPvSswrikD</UploadId>
- <Initiator>
- <ID>bb5c0f63b0b25f2d0</ID>
- <DisplayName>gustavoniemeyer</DisplayName>
- </Initiator>
- <Owner>
- <ID>bb5c0f63b0b25f2d0</ID>
- <DisplayName>gustavoniemeyer</DisplayName>
- </Owner>
- <StorageClass>STANDARD</StorageClass>
- <Initiated>2013-01-30T18:15:47.000Z</Initiated>
- </Upload>
- <Upload>
- <Key>multi2</Key>
- <UploadId>DkirwsSvPp98guVUi</UploadId>
- <Initiator>
- <ID>bb5c0f63b0b25f2d0</ID>
- <DisplayName>joe</DisplayName>
- </Initiator>
- <Owner>
- <ID>bb5c0f63b0b25f2d0</ID>
- <DisplayName>joe</DisplayName>
- </Owner>
- <StorageClass>STANDARD</StorageClass>
- <Initiated>2013-01-30T18:15:47.000Z</Initiated>
- </Upload>
- <CommonPrefixes>
- <Prefix>a/</Prefix>
- </CommonPrefixes>
- <CommonPrefixes>
- <Prefix>b/</Prefix>
- </CommonPrefixes>
-</ListMultipartUploadsResult>
-`
-
-var NoSuchUploadErrorDump = `
-<?xml version="1.0" encoding="UTF-8"?>
-<Error>
- <Code>NoSuchUpload</Code>
- <Message>Not relevant</Message>
- <BucketName>sample</BucketName>
- <RequestId>3F1B667FAD71C3D8</RequestId>
- <HostId>kjhwqk</HostId>
-</Error>
-`
-
-var InternalErrorDump = `
-<?xml version="1.0" encoding="UTF-8"?>
-<Error>
- <Code>InternalError</Code>
- <Message>Not relevant</Message>
- <BucketName>sample</BucketName>
- <RequestId>3F1B667FAD71C3D8</RequestId>
- <HostId>kjhwqk</HostId>
-</Error>
-`
diff --git a/vendor/github.com/goamz/goamz/s3/s3.go b/vendor/github.com/goamz/goamz/s3/s3.go
deleted file mode 100644
index f27479cb4..000000000
--- a/vendor/github.com/goamz/goamz/s3/s3.go
+++ /dev/null
@@ -1,1164 +0,0 @@
-//
-// goamz - Go packages to interact with the Amazon Web Services.
-//
-// https://wiki.ubuntu.com/goamz
-//
-// Copyright (c) 2011 Canonical Ltd.
-//
-// Written by Gustavo Niemeyer <gustavo.niemeyer@canonical.com>
-//
-
-package s3
-
-import (
- "bytes"
- "crypto/hmac"
- "crypto/md5"
- "crypto/sha1"
- "encoding/base64"
- "encoding/xml"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "net"
- "net/http"
- "net/http/httputil"
- "net/url"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-const debug = false
-
-// The S3 type encapsulates operations with an S3 region.
-type S3 struct {
- aws.Auth
- aws.Region
-
- // ConnectTimeout is the maximum time a request attempt will
- // wait for a successful connection to be made.
- //
- // A value of zero means no timeout.
- ConnectTimeout time.Duration
-
- // ReadTimeout is the maximum time a request attempt will wait
- // for an individual read to complete.
- //
- // A value of zero means no timeout.
- ReadTimeout time.Duration
-
- // WriteTimeout is the maximum time a request attempt will
- // wait for an individual write to complete.
- //
- // A value of zero means no timeout.
- WriteTimeout time.Duration
-
- // RequestTimeout is the maximum time a request attempt can
- // take before operations return a timeout error.
- //
- // This includes connection time, any redirects, and reading
- // the response body. The timer remains running after the request
- // is made so it can interrupt reading of the response data.
- //
- // A Timeout of zero means no timeout.
- RequestTimeout time.Duration
-
- // AttemptStrategy is the attempt strategy used for requests.
- aws.AttemptStrategy
-
- // Reserve the right of using private data.
- private byte
-
- // client used for requests
- client *http.Client
-}
-
-// The Bucket type encapsulates operations with an S3 bucket.
-type Bucket struct {
- *S3
- Name string
-}
-
-// The Owner type represents the owner of the object in an S3 bucket.
-type Owner struct {
- ID string
- DisplayName string
-}
-
-// Fold options into an Options struct
-//
-type Options struct {
- SSE bool
- Meta map[string][]string
- ContentEncoding string
- CacheControl string
- RedirectLocation string
- ContentMD5 string
- // What else?
- // Content-Disposition string
- //// The following become headers so they are []strings rather than strings... I think
- // x-amz-storage-class []string
-}
-
-type CopyOptions struct {
- Options
- MetadataDirective string
- ContentType string
-}
-
-// CopyObjectResult is the output from a Copy request
-type CopyObjectResult struct {
- ETag string
- LastModified string
-}
-
-// DefaultAttemptStrategy is the default AttemptStrategy used by S3 objects created by New.
-var DefaultAttemptStrategy = aws.AttemptStrategy{
- Min: 5,
- Total: 5 * time.Second,
- Delay: 200 * time.Millisecond,
-}
-
-// New creates a new S3. Optional client argument allows for custom http.clients to be used.
-func New(auth aws.Auth, region aws.Region, client ...*http.Client) *S3 {
-
- var httpclient *http.Client
-
- if len(client) > 0 {
- httpclient = client[0]
- }
-
- return &S3{Auth: auth, Region: region, AttemptStrategy: DefaultAttemptStrategy, client: httpclient}
-}
-
-// Bucket returns a Bucket with the given name.
-func (s3 *S3) Bucket(name string) *Bucket {
- if s3.Region.S3BucketEndpoint != "" || s3.Region.S3LowercaseBucket {
- name = strings.ToLower(name)
- }
- return &Bucket{s3, name}
-}
-
-var createBucketConfiguration = `<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
- <LocationConstraint>%s</LocationConstraint>
-</CreateBucketConfiguration>`
-
-// locationConstraint returns an io.Reader specifying a LocationConstraint if
-// required for the region.
-//
-// See http://goo.gl/bh9Kq for details.
-func (s3 *S3) locationConstraint() io.Reader {
- constraint := ""
- if s3.Region.S3LocationConstraint {
- constraint = fmt.Sprintf(createBucketConfiguration, s3.Region.Name)
- }
- return strings.NewReader(constraint)
-}
-
-type ACL string
-
-const (
- Private = ACL("private")
- PublicRead = ACL("public-read")
- PublicReadWrite = ACL("public-read-write")
- AuthenticatedRead = ACL("authenticated-read")
- BucketOwnerRead = ACL("bucket-owner-read")
- BucketOwnerFull = ACL("bucket-owner-full-control")
-)
-
-// PutBucket creates a new bucket.
-//
-// See http://goo.gl/ndjnR for details.
-func (b *Bucket) PutBucket(perm ACL) error {
- headers := map[string][]string{
- "x-amz-acl": {string(perm)},
- }
- req := &request{
- method: "PUT",
- bucket: b.Name,
- path: "/",
- headers: headers,
- payload: b.locationConstraint(),
- }
- return b.S3.query(req, nil)
-}
-
-// DelBucket removes an existing S3 bucket. All objects in the bucket must
-// be removed before the bucket itself can be removed.
-//
-// See http://goo.gl/GoBrY for details.
-func (b *Bucket) DelBucket() (err error) {
- req := &request{
- method: "DELETE",
- bucket: b.Name,
- path: "/",
- }
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- err = b.S3.query(req, nil)
- if !shouldRetry(err) {
- break
- }
- }
- return err
-}
-
-// Get retrieves an object from an S3 bucket.
-//
-// See http://goo.gl/isCO7 for details.
-func (b *Bucket) Get(path string) (data []byte, err error) {
- body, err := b.GetReader(path)
- defer func() {
- if body != nil {
- body.Close()
- }
- }()
- if err != nil {
- return nil, err
- }
- data, err = ioutil.ReadAll(body)
- return data, err
-}
-
-// GetReader retrieves an object from an S3 bucket,
-// returning the body of the HTTP response.
-// It is the caller's responsibility to call Close on rc when
-// finished reading.
-func (b *Bucket) GetReader(path string) (rc io.ReadCloser, err error) {
- resp, err := b.GetResponse(path)
- if resp != nil {
- return resp.Body, err
- }
- return nil, err
-}
-
-// GetResponse retrieves an object from an S3 bucket,
-// returning the HTTP response.
-// It is the caller's responsibility to call Close on rc when
-// finished reading
-func (b *Bucket) GetResponse(path string) (resp *http.Response, err error) {
- return b.GetResponseWithHeaders(path, make(http.Header))
-}
-
-// GetReaderWithHeaders retrieves an object from an S3 bucket
-// Accepts custom headers to be sent as the second parameter
-// returning the body of the HTTP response.
-// It is the caller's responsibility to call Close on rc when
-// finished reading
-func (b *Bucket) GetResponseWithHeaders(path string, headers map[string][]string) (resp *http.Response, err error) {
- req := &request{
- bucket: b.Name,
- path: path,
- headers: headers,
- }
- err = b.S3.prepare(req)
- if err != nil {
- return nil, err
- }
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- resp, err := b.S3.run(req, nil)
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
- if err != nil {
- return nil, err
- }
- return resp, nil
- }
- panic("unreachable")
-}
-
-// Exists checks whether or not an object exists on an S3 bucket using a HEAD request.
-func (b *Bucket) Exists(path string) (exists bool, err error) {
- req := &request{
- method: "HEAD",
- bucket: b.Name,
- path: path,
- }
- err = b.S3.prepare(req)
- if err != nil {
- return
- }
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- resp, err := b.S3.run(req, nil)
-
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
-
- if err != nil {
- // We can treat a 403 or 404 as non existance
- if e, ok := err.(*Error); ok && (e.StatusCode == 403 || e.StatusCode == 404) {
- return false, nil
- }
- return false, err
- }
-
- if resp.StatusCode/100 == 2 {
- exists = true
- }
- return exists, err
- }
- return false, fmt.Errorf("S3 Currently Unreachable")
-}
-
-// Head HEADs an object in the S3 bucket, returns the response with
-// no body see http://bit.ly/17K1ylI
-func (b *Bucket) Head(path string, headers map[string][]string) (*http.Response, error) {
- req := &request{
- method: "HEAD",
- bucket: b.Name,
- path: path,
- headers: headers,
- }
- err := b.S3.prepare(req)
- if err != nil {
- return nil, err
- }
-
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- resp, err := b.S3.run(req, nil)
- if shouldRetry(err) && attempt.HasNext() {
- continue
- }
- if err != nil {
- return nil, err
- }
- return resp, err
- }
- return nil, fmt.Errorf("S3 Currently Unreachable")
-}
-
-// Put inserts an object into the S3 bucket.
-//
-// See http://goo.gl/FEBPD for details.
-func (b *Bucket) Put(path string, data []byte, contType string, perm ACL, options Options) error {
- body := bytes.NewBuffer(data)
- return b.PutReader(path, body, int64(len(data)), contType, perm, options)
-}
-
-// PutCopy puts a copy of an object given by the key path into bucket b using b.Path as the target key
-func (b *Bucket) PutCopy(path string, perm ACL, options CopyOptions, source string) (result *CopyObjectResult, err error) {
- headers := map[string][]string{
- "x-amz-acl": {string(perm)},
- "x-amz-copy-source": {source},
- }
- options.addHeaders(headers)
- req := &request{
- method: "PUT",
- bucket: b.Name,
- path: path,
- headers: headers,
- }
- result = &CopyObjectResult{}
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- err = b.S3.query(req, result)
- if !shouldRetry(err) {
- break
- }
- }
- if err != nil {
- return nil, err
- }
- return result, nil
-}
-
-/*
-PutHeader - like Put, inserts an object into the S3 bucket.
-Instead of Content-Type string, pass in custom headers to override defaults.
-*/
-func (b *Bucket) PutHeader(path string, data []byte, customHeaders map[string][]string, perm ACL) error {
- body := bytes.NewBuffer(data)
- return b.PutReaderHeader(path, body, int64(len(data)), customHeaders, perm)
-}
-
-// PutReader inserts an object into the S3 bucket by consuming data
-// from r until EOF.
-func (b *Bucket) PutReader(path string, r io.Reader, length int64, contType string, perm ACL, options Options) error {
- headers := map[string][]string{
- "Content-Length": {strconv.FormatInt(length, 10)},
- "Content-Type": {contType},
- "x-amz-acl": {string(perm)},
- }
- options.addHeaders(headers)
- req := &request{
- method: "PUT",
- bucket: b.Name,
- path: path,
- headers: headers,
- payload: r,
- }
- return b.S3.query(req, nil)
-}
-
-/*
-PutReaderHeader - like PutReader, inserts an object into S3 from a reader.
-Instead of Content-Type string, pass in custom headers to override defaults.
-*/
-func (b *Bucket) PutReaderHeader(path string, r io.Reader, length int64, customHeaders map[string][]string, perm ACL) error {
- // Default headers
- headers := map[string][]string{
- "Content-Length": {strconv.FormatInt(length, 10)},
- "Content-Type": {"application/text"},
- "x-amz-acl": {string(perm)},
- }
-
- // Override with custom headers
- for key, value := range customHeaders {
- headers[key] = value
- }
-
- req := &request{
- method: "PUT",
- bucket: b.Name,
- path: path,
- headers: headers,
- payload: r,
- }
- return b.S3.query(req, nil)
-}
-
-// addHeaders adds o's specified fields to headers
-func (o Options) addHeaders(headers map[string][]string) {
- if o.SSE {
- headers["x-amz-server-side-encryption"] = []string{"AES256"}
- }
- if len(o.ContentEncoding) != 0 {
- headers["Content-Encoding"] = []string{o.ContentEncoding}
- }
- if len(o.CacheControl) != 0 {
- headers["Cache-Control"] = []string{o.CacheControl}
- }
- if len(o.ContentMD5) != 0 {
- headers["Content-MD5"] = []string{o.ContentMD5}
- }
- if len(o.RedirectLocation) != 0 {
- headers["x-amz-website-redirect-location"] = []string{o.RedirectLocation}
- }
- for k, v := range o.Meta {
- headers["x-amz-meta-"+k] = v
- }
-}
-
-// addHeaders adds o's specified fields to headers
-func (o CopyOptions) addHeaders(headers map[string][]string) {
- o.Options.addHeaders(headers)
- if len(o.MetadataDirective) != 0 {
- headers["x-amz-metadata-directive"] = []string{o.MetadataDirective}
- }
- if len(o.ContentType) != 0 {
- headers["Content-Type"] = []string{o.ContentType}
- }
-}
-
-func makeXmlBuffer(doc []byte) *bytes.Buffer {
- buf := new(bytes.Buffer)
- buf.WriteString(xml.Header)
- buf.Write(doc)
- return buf
-}
-
-type RoutingRule struct {
- ConditionKeyPrefixEquals string `xml:"Condition>KeyPrefixEquals"`
- RedirectReplaceKeyPrefixWith string `xml:"Redirect>ReplaceKeyPrefixWith,omitempty"`
- RedirectReplaceKeyWith string `xml:"Redirect>ReplaceKeyWith,omitempty"`
-}
-
-type WebsiteConfiguration struct {
- XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ WebsiteConfiguration"`
- IndexDocumentSuffix string `xml:"IndexDocument>Suffix"`
- ErrorDocumentKey string `xml:"ErrorDocument>Key"`
- RoutingRules *[]RoutingRule `xml:"RoutingRules>RoutingRule,omitempty"`
-}
-
-func (b *Bucket) PutBucketWebsite(configuration WebsiteConfiguration) error {
-
- doc, err := xml.Marshal(configuration)
- if err != nil {
- return err
- }
-
- buf := makeXmlBuffer(doc)
-
- return b.PutBucketSubresource("website", buf, int64(buf.Len()))
-}
-
-func (b *Bucket) PutBucketSubresource(subresource string, r io.Reader, length int64) error {
- headers := map[string][]string{
- "Content-Length": {strconv.FormatInt(length, 10)},
- }
- req := &request{
- path: "/",
- method: "PUT",
- bucket: b.Name,
- headers: headers,
- payload: r,
- params: url.Values{subresource: {""}},
- }
-
- return b.S3.query(req, nil)
-}
-
-// Del removes an object from the S3 bucket.
-//
-// See http://goo.gl/APeTt for details.
-func (b *Bucket) Del(path string) error {
- req := &request{
- method: "DELETE",
- bucket: b.Name,
- path: path,
- }
- return b.S3.query(req, nil)
-}
-
-type Delete struct {
- Quiet bool `xml:"Quiet,omitempty"`
- Objects []Object `xml:"Object"`
-}
-
-type Object struct {
- Key string `xml:"Key"`
- VersionId string `xml:"VersionId,omitempty"`
-}
-
-// DelMulti removes up to 1000 objects from the S3 bucket.
-//
-// See http://goo.gl/jx6cWK for details.
-func (b *Bucket) DelMulti(objects Delete) error {
- doc, err := xml.Marshal(objects)
- if err != nil {
- return err
- }
-
- buf := makeXmlBuffer(doc)
- digest := md5.New()
- size, err := digest.Write(buf.Bytes())
- if err != nil {
- return err
- }
-
- headers := map[string][]string{
- "Content-Length": {strconv.FormatInt(int64(size), 10)},
- "Content-MD5": {base64.StdEncoding.EncodeToString(digest.Sum(nil))},
- "Content-Type": {"text/xml"},
- }
- req := &request{
- path: "/",
- method: "POST",
- params: url.Values{"delete": {""}},
- bucket: b.Name,
- headers: headers,
- payload: buf,
- }
-
- return b.S3.query(req, nil)
-}
-
-// The ListResp type holds the results of a List bucket operation.
-type ListResp struct {
- Name string
- Prefix string
- Delimiter string
- Marker string
- NextMarker string
- MaxKeys int
-
- // IsTruncated is true if the results have been truncated because
- // there are more keys and prefixes than can fit in MaxKeys.
- // N.B. this is the opposite sense to that documented (incorrectly) in
- // http://goo.gl/YjQTc
- IsTruncated bool
- Contents []Key
- CommonPrefixes []string `xml:">Prefix"`
-}
-
-// The Key type represents an item stored in an S3 bucket.
-type Key struct {
- Key string
- LastModified string
- Size int64
- // ETag gives the hex-encoded MD5 sum of the contents,
- // surrounded with double-quotes.
- ETag string
- StorageClass string
- Owner Owner
-}
-
-// List returns information about objects in an S3 bucket.
-//
-// The prefix parameter limits the response to keys that begin with the
-// specified prefix.
-//
-// The delim parameter causes the response to group all of the keys that
-// share a common prefix up to the next delimiter in a single entry within
-// the CommonPrefixes field. You can use delimiters to separate a bucket
-// into different groupings of keys, similar to how folders would work.
-//
-// The marker parameter specifies the key to start with when listing objects
-// in a bucket. Amazon S3 lists objects in alphabetical order and
-// will return keys alphabetically greater than the marker.
-//
-// The max parameter specifies how many keys + common prefixes to return in
-// the response. The default is 1000.
-//
-// For example, given these keys in a bucket:
-//
-// index.html
-// index2.html
-// photos/2006/January/sample.jpg
-// photos/2006/February/sample2.jpg
-// photos/2006/February/sample3.jpg
-// photos/2006/February/sample4.jpg
-//
-// Listing this bucket with delimiter set to "/" would yield the
-// following result:
-//
-// &ListResp{
-// Name: "sample-bucket",
-// MaxKeys: 1000,
-// Delimiter: "/",
-// Contents: []Key{
-// {Key: "index.html", "index2.html"},
-// },
-// CommonPrefixes: []string{
-// "photos/",
-// },
-// }
-//
-// Listing the same bucket with delimiter set to "/" and prefix set to
-// "photos/2006/" would yield the following result:
-//
-// &ListResp{
-// Name: "sample-bucket",
-// MaxKeys: 1000,
-// Delimiter: "/",
-// Prefix: "photos/2006/",
-// CommonPrefixes: []string{
-// "photos/2006/February/",
-// "photos/2006/January/",
-// },
-// }
-//
-// See http://goo.gl/YjQTc for details.
-func (b *Bucket) List(prefix, delim, marker string, max int) (result *ListResp, err error) {
- params := map[string][]string{
- "prefix": {prefix},
- "delimiter": {delim},
- "marker": {marker},
- }
- if max != 0 {
- params["max-keys"] = []string{strconv.FormatInt(int64(max), 10)}
- }
- req := &request{
- bucket: b.Name,
- params: params,
- }
- result = &ListResp{}
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- err = b.S3.query(req, result)
- if !shouldRetry(err) {
- break
- }
- }
- if err != nil {
- return nil, err
- }
- return result, nil
-}
-
-// The VersionsResp type holds the results of a list bucket Versions operation.
-type VersionsResp struct {
- Name string
- Prefix string
- KeyMarker string
- VersionIdMarker string
- MaxKeys int
- Delimiter string
- IsTruncated bool
- Versions []Version
- CommonPrefixes []string `xml:">Prefix"`
-}
-
-// The Version type represents an object version stored in an S3 bucket.
-type Version struct {
- Key string
- VersionId string
- IsLatest bool
- LastModified string
- // ETag gives the hex-encoded MD5 sum of the contents,
- // surrounded with double-quotes.
- ETag string
- Size int64
- Owner Owner
- StorageClass string
-}
-
-func (b *Bucket) Versions(prefix, delim, keyMarker string, versionIdMarker string, max int) (result *VersionsResp, err error) {
- params := map[string][]string{
- "versions": {""},
- "prefix": {prefix},
- "delimiter": {delim},
- }
-
- if len(versionIdMarker) != 0 {
- params["version-id-marker"] = []string{versionIdMarker}
- }
- if len(keyMarker) != 0 {
- params["key-marker"] = []string{keyMarker}
- }
-
- if max != 0 {
- params["max-keys"] = []string{strconv.FormatInt(int64(max), 10)}
- }
- req := &request{
- bucket: b.Name,
- params: params,
- }
- result = &VersionsResp{}
- for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
- err = b.S3.query(req, result)
- if !shouldRetry(err) {
- break
- }
- }
- if err != nil {
- return nil, err
- }
- return result, nil
-}
-
-// Returns a mapping of all key names in this bucket to Key objects
-func (b *Bucket) GetBucketContents() (*map[string]Key, error) {
- bucket_contents := map[string]Key{}
- prefix := ""
- path_separator := ""
- marker := ""
- for {
- contents, err := b.List(prefix, path_separator, marker, 1000)
- if err != nil {
- return &bucket_contents, err
- }
- for _, key := range contents.Contents {
- bucket_contents[key.Key] = key
- }
- if contents.IsTruncated {
- marker = contents.NextMarker
- } else {
- break
- }
- }
-
- return &bucket_contents, nil
-}
-
-// URL returns a non-signed URL that allows retriving the
-// object at path. It only works if the object is publicly
-// readable (see SignedURL).
-func (b *Bucket) URL(path string) string {
- req := &request{
- bucket: b.Name,
- path: path,
- }
- err := b.S3.prepare(req)
- if err != nil {
- panic(err)
- }
- u, err := req.url()
- if err != nil {
- panic(err)
- }
- u.RawQuery = ""
- return u.String()
-}
-
-// SignedURL returns a signed URL that allows anyone holding the URL
-// to retrieve the object at path. The signature is valid until expires.
-func (b *Bucket) SignedURL(path string, expires time.Time) string {
- req := &request{
- bucket: b.Name,
- path: path,
- params: url.Values{"Expires": {strconv.FormatInt(expires.Unix(), 10)}},
- }
- err := b.S3.prepare(req)
- if err != nil {
- panic(err)
- }
- u, err := req.url()
- if err != nil {
- panic(err)
- }
- if b.S3.Auth.Token() != "" {
- return u.String() + "&x-amz-security-token=" + url.QueryEscape(req.headers["X-Amz-Security-Token"][0])
- } else {
- return u.String()
- }
-}
-
-// UploadSignedURL returns a signed URL that allows anyone holding the URL
-// to upload the object at path. The signature is valid until expires.
-// contenttype is a string like image/png
-// path is the resource name in s3 terminalogy like images/ali.png [obviously exclusing the bucket name itself]
-func (b *Bucket) UploadSignedURL(path, method, content_type string, expires time.Time) string {
- expire_date := expires.Unix()
- if method != "POST" {
- method = "PUT"
- }
- stringToSign := method + "\n\n" + content_type + "\n" + strconv.FormatInt(expire_date, 10) + "\n/" + b.Name + "/" + path
- fmt.Println("String to sign:\n", stringToSign)
- a := b.S3.Auth
- secretKey := a.SecretKey
- accessId := a.AccessKey
- mac := hmac.New(sha1.New, []byte(secretKey))
- mac.Write([]byte(stringToSign))
- macsum := mac.Sum(nil)
- signature := base64.StdEncoding.EncodeToString([]byte(macsum))
- signature = strings.TrimSpace(signature)
-
- signedurl, err := url.Parse("https://" + b.Name + ".s3.amazonaws.com/")
- if err != nil {
- log.Println("ERROR sining url for S3 upload", err)
- return ""
- }
- signedurl.Path += path
- params := url.Values{}
- params.Add("AWSAccessKeyId", accessId)
- params.Add("Expires", strconv.FormatInt(expire_date, 10))
- params.Add("Signature", signature)
- if a.Token() != "" {
- params.Add("token", a.Token())
- }
-
- signedurl.RawQuery = params.Encode()
- return signedurl.String()
-}
-
-// PostFormArgs returns the action and input fields needed to allow anonymous
-// uploads to a bucket within the expiration limit
-func (b *Bucket) PostFormArgs(path string, expires time.Time, redirect string) (action string, fields map[string]string) {
- conditions := make([]string, 0)
- fields = map[string]string{
- "AWSAccessKeyId": b.Auth.AccessKey,
- "key": path,
- }
-
- conditions = append(conditions, fmt.Sprintf("{\"key\": \"%s\"}", path))
- conditions = append(conditions, fmt.Sprintf("{\"bucket\": \"%s\"}", b.Name))
- if redirect != "" {
- conditions = append(conditions, fmt.Sprintf("{\"success_action_redirect\": \"%s\"}", redirect))
- fields["success_action_redirect"] = redirect
- }
-
- vExpiration := expires.Format("2006-01-02T15:04:05Z")
- vConditions := strings.Join(conditions, ",")
- policy := fmt.Sprintf("{\"expiration\": \"%s\", \"conditions\": [%s]}", vExpiration, vConditions)
- policy64 := base64.StdEncoding.EncodeToString([]byte(policy))
- fields["policy"] = policy64
-
- signer := hmac.New(sha1.New, []byte(b.Auth.SecretKey))
- signer.Write([]byte(policy64))
- fields["signature"] = base64.StdEncoding.EncodeToString(signer.Sum(nil))
-
- action = fmt.Sprintf("%s/%s/", b.S3.Region.S3Endpoint, b.Name)
- return
-}
-
-type request struct {
- method string
- bucket string
- path string
- signpath string
- params url.Values
- headers http.Header
- baseurl string
- payload io.Reader
- prepared bool
-}
-
-func (req *request) url() (*url.URL, error) {
- u, err := url.Parse(req.baseurl)
- if err != nil {
- return nil, fmt.Errorf("bad S3 endpoint URL %q: %v", req.baseurl, err)
- }
- u.RawQuery = req.params.Encode()
- u.Path = req.path
- return u, nil
-}
-
-// query prepares and runs the req request.
-// If resp is not nil, the XML data contained in the response
-// body will be unmarshalled on it.
-func (s3 *S3) query(req *request, resp interface{}) error {
- err := s3.prepare(req)
- if err == nil {
- var httpResponse *http.Response
- httpResponse, err = s3.run(req, resp)
- if resp == nil && httpResponse != nil {
- httpResponse.Body.Close()
- }
- }
- return err
-}
-
-// prepare sets up req to be delivered to S3.
-func (s3 *S3) prepare(req *request) error {
- var signpath = req.path
-
- if !req.prepared {
- req.prepared = true
- if req.method == "" {
- req.method = "GET"
- }
- // Copy so they can be mutated without affecting on retries.
- params := make(url.Values)
- headers := make(http.Header)
- for k, v := range req.params {
- params[k] = v
- }
- for k, v := range req.headers {
- headers[k] = v
- }
- req.params = params
- req.headers = headers
- if !strings.HasPrefix(req.path, "/") {
- req.path = "/" + req.path
- }
- signpath = req.path
- if req.bucket != "" {
- req.baseurl = s3.Region.S3BucketEndpoint
- if req.baseurl == "" {
- // Use the path method to address the bucket.
- req.baseurl = s3.Region.S3Endpoint
- req.path = "/" + req.bucket + req.path
- } else {
- // Just in case, prevent injection.
- if strings.IndexAny(req.bucket, "/:@") >= 0 {
- return fmt.Errorf("bad S3 bucket: %q", req.bucket)
- }
- req.baseurl = strings.Replace(req.baseurl, "${bucket}", req.bucket, -1)
- }
- signpath = "/" + req.bucket + signpath
- }
- }
-
- // Always sign again as it's not clear how far the
- // server has handled a previous attempt.
- u, err := url.Parse(req.baseurl)
- if err != nil {
- return fmt.Errorf("bad S3 endpoint URL %q: %v", req.baseurl, err)
- }
- reqSignpathSpaceFix := (&url.URL{Path: signpath}).String()
- req.headers["Host"] = []string{u.Host}
- req.headers["Date"] = []string{time.Now().In(time.UTC).Format(time.RFC1123)}
- if s3.Auth.Token() != "" {
- req.headers["X-Amz-Security-Token"] = []string{s3.Auth.Token()}
- }
- sign(s3.Auth, req.method, reqSignpathSpaceFix, req.params, req.headers)
- return nil
-}
-
-// run sends req and returns the http response from the server.
-// If resp is not nil, the XML data contained in the response
-// body will be unmarshalled on it.
-func (s3 *S3) run(req *request, resp interface{}) (*http.Response, error) {
- if debug {
- log.Printf("Running S3 request: %#v", req)
- }
-
- u, err := req.url()
- if err != nil {
- return nil, err
- }
-
- hreq := http.Request{
- URL: u,
- Method: req.method,
- ProtoMajor: 1,
- ProtoMinor: 1,
- Close: true,
- Header: req.headers,
- }
-
- if v, ok := req.headers["Content-Length"]; ok {
- hreq.ContentLength, _ = strconv.ParseInt(v[0], 10, 64)
- delete(req.headers, "Content-Length")
- if hreq.ContentLength == 0 {
- req.payload = nil
- }
- }
- if req.payload != nil {
- hreq.Body = ioutil.NopCloser(req.payload)
- }
-
- if s3.client == nil {
- s3.client = &http.Client{
- Transport: &http.Transport{
- Dial: func(netw, addr string) (c net.Conn, err error) {
- c, err = net.DialTimeout(netw, addr, s3.ConnectTimeout)
- if err != nil {
- return
- }
-
- var deadline time.Time
- if s3.RequestTimeout > 0 {
- deadline = time.Now().Add(s3.RequestTimeout)
- c.SetDeadline(deadline)
- }
-
- if s3.ReadTimeout > 0 || s3.WriteTimeout > 0 {
- c = &ioTimeoutConn{
- TCPConn: c.(*net.TCPConn),
- readTimeout: s3.ReadTimeout,
- writeTimeout: s3.WriteTimeout,
- requestDeadline: deadline,
- }
- }
- return
- },
- },
- }
- }
-
- hresp, err := s3.client.Do(&hreq)
- if err != nil {
- return nil, err
- }
- if debug {
- dump, _ := httputil.DumpResponse(hresp, true)
- log.Printf("} -> %s\n", dump)
- }
- if hresp.StatusCode != 200 && hresp.StatusCode != 204 && hresp.StatusCode != 206 {
- defer hresp.Body.Close()
- return nil, buildError(hresp)
- }
- if resp != nil {
- err = xml.NewDecoder(hresp.Body).Decode(resp)
- hresp.Body.Close()
- if debug {
- log.Printf("goamz.s3> decoded xml into %#v", resp)
- }
- }
- return hresp, err
-}
-
-// Error represents an error in an operation with S3.
-type Error struct {
- StatusCode int // HTTP status code (200, 403, ...)
- Code string // EC2 error code ("UnsupportedOperation", ...)
- Message string // The human-oriented error message
- BucketName string
- RequestId string
- HostId string
-}
-
-func (e *Error) Error() string {
- return e.Message
-}
-
-func buildError(r *http.Response) error {
- if debug {
- log.Printf("got error (status code %v)", r.StatusCode)
- data, err := ioutil.ReadAll(r.Body)
- if err != nil {
- log.Printf("\tread error: %v", err)
- } else {
- log.Printf("\tdata:\n%s\n\n", data)
- }
- r.Body = ioutil.NopCloser(bytes.NewBuffer(data))
- }
-
- err := Error{}
- // TODO return error if Unmarshal fails?
- xml.NewDecoder(r.Body).Decode(&err)
- r.Body.Close()
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- if debug {
- log.Printf("err: %#v\n", err)
- }
- return &err
-}
-
-func shouldRetry(err error) bool {
- if err == nil {
- return false
- }
- if e, ok := err.(*url.Error); ok {
- // Transport returns this string if it detects a write on a connection which
- // has already had an error
- if e.Err.Error() == "http: can't write HTTP request on broken connection" {
- return true
- }
- err = e.Err
- }
-
- switch err {
- case io.ErrUnexpectedEOF, io.EOF:
- return true
- }
- switch e := err.(type) {
- case *net.DNSError:
- return true
- case *net.OpError:
- switch e.Op {
- case "read", "write", "WSARecv", "WSASend", "ConnectEx":
- return true
- }
- case *Error:
- switch e.Code {
- case "InternalError", "NoSuchUpload", "NoSuchBucket", "RequestTimeout":
- return true
- }
- // let's handle tls handshake timeout issues and similar temporary errors
- case net.Error:
- return e.Temporary()
- }
-
- return false
-}
-
-func hasCode(err error, code string) bool {
- s3err, ok := err.(*Error)
- return ok && s3err.Code == code
-}
-
-// ioTimeoutConn is a net.Conn which sets a deadline for each Read or Write operation
-type ioTimeoutConn struct {
- *net.TCPConn
- readTimeout time.Duration
- writeTimeout time.Duration
- requestDeadline time.Time
-}
-
-func (c *ioTimeoutConn) deadline(timeout time.Duration) time.Time {
- dl := time.Now().Add(timeout)
- if c.requestDeadline.IsZero() || dl.Before(c.requestDeadline) {
- return dl
- }
-
- return c.requestDeadline
-}
-
-func (c *ioTimeoutConn) Read(b []byte) (int, error) {
- if c.readTimeout > 0 {
- err := c.TCPConn.SetReadDeadline(c.deadline(c.readTimeout))
- if err != nil {
- return 0, err
- }
- }
- return c.TCPConn.Read(b)
-}
-
-func (c *ioTimeoutConn) Write(b []byte) (int, error) {
- if c.writeTimeout > 0 {
- err := c.TCPConn.SetWriteDeadline(c.deadline(c.writeTimeout))
- if err != nil {
- return 0, err
- }
- }
- return c.TCPConn.Write(b)
-}
diff --git a/vendor/github.com/goamz/goamz/s3/s3_test.go b/vendor/github.com/goamz/goamz/s3/s3_test.go
deleted file mode 100644
index 24d4dfcc0..000000000
--- a/vendor/github.com/goamz/goamz/s3/s3_test.go
+++ /dev/null
@@ -1,427 +0,0 @@
-package s3_test
-
-import (
- "bytes"
- "io/ioutil"
- "net/http"
- "testing"
- "time"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/s3"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-type S struct {
- s3 *s3.S3
-}
-
-var _ = Suite(&S{})
-
-var testServer = testutil.NewHTTPServer()
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.s3 = s3.New(auth, aws.Region{Name: "faux-region-1", S3Endpoint: testServer.URL})
-}
-
-func (s *S) TearDownSuite(c *C) {
- s.s3.AttemptStrategy = s3.DefaultAttemptStrategy
-}
-
-func (s *S) SetUpTest(c *C) {
- s.s3.AttemptStrategy = aws.AttemptStrategy{
- Total: 300 * time.Millisecond,
- Delay: 100 * time.Millisecond,
- }
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) DisableRetries() {
- s.s3.AttemptStrategy = aws.AttemptStrategy{}
-}
-
-// PutBucket docs: http://goo.gl/kBTCu
-
-func (s *S) TestPutBucket(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- err := b.PutBucket(s3.Private)
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/bucket/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-}
-
-// Head docs: http://bit.ly/17K1ylI
-
-func (s *S) TestHead(c *C) {
- testServer.Response(200, nil, "content")
-
- b := s.s3.Bucket("bucket")
- resp, err := b.Head("name", nil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "HEAD")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(err, IsNil)
- c.Assert(resp.ContentLength, FitsTypeOf, int64(0))
- c.Assert(resp, FitsTypeOf, &http.Response{})
-}
-
-// DeleteBucket docs: http://goo.gl/GoBrY
-
-func (s *S) TestDelBucket(c *C) {
- testServer.Response(204, nil, "")
-
- b := s.s3.Bucket("bucket")
- err := b.DelBucket()
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "DELETE")
- c.Assert(req.URL.Path, Equals, "/bucket/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-}
-
-// GetObject docs: http://goo.gl/isCO7
-
-func (s *S) TestGet(c *C) {
- testServer.Response(200, nil, "content")
-
- b := s.s3.Bucket("bucket")
- data, err := b.Get("name")
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(err, IsNil)
- c.Assert(string(data), Equals, "content")
-}
-
-func (s *S) TestURL(c *C) {
- testServer.Response(200, nil, "content")
-
- b := s.s3.Bucket("bucket")
- url := b.URL("name")
- r, err := http.Get(url)
- c.Assert(err, IsNil)
- data, err := ioutil.ReadAll(r.Body)
- r.Body.Close()
- c.Assert(err, IsNil)
- c.Assert(string(data), Equals, "content")
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
-}
-
-func (s *S) TestGetReader(c *C) {
- testServer.Response(200, nil, "content")
-
- b := s.s3.Bucket("bucket")
- rc, err := b.GetReader("name")
- c.Assert(err, IsNil)
- data, err := ioutil.ReadAll(rc)
- rc.Close()
- c.Assert(err, IsNil)
- c.Assert(string(data), Equals, "content")
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(Equals), "")
-}
-
-func (s *S) TestGetNotFound(c *C) {
- for i := 0; i < 10; i++ {
- testServer.Response(404, nil, GetObjectErrorDump)
- }
-
- b := s.s3.Bucket("non-existent-bucket")
- data, err := b.Get("non-existent")
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/non-existent-bucket/non-existent")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- s3err, _ := err.(*s3.Error)
- c.Assert(s3err, NotNil)
- c.Assert(s3err.StatusCode, Equals, 404)
- c.Assert(s3err.BucketName, Equals, "non-existent-bucket")
- c.Assert(s3err.RequestId, Equals, "3F1B667FAD71C3D8")
- c.Assert(s3err.HostId, Equals, "L4ee/zrm1irFXY5F45fKXIRdOf9ktsKY/8TDVawuMK2jWRb1RF84i1uBzkdNqS5D")
- c.Assert(s3err.Code, Equals, "NoSuchBucket")
- c.Assert(s3err.Message, Equals, "The specified bucket does not exist")
- c.Assert(s3err.Error(), Equals, "The specified bucket does not exist")
- c.Assert(data, IsNil)
-}
-
-// PutObject docs: http://goo.gl/FEBPD
-
-func (s *S) TestPutObject(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- err := b.Put("name", []byte("content"), "content-type", s3.Private, s3.Options{})
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
- c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
- //c.Assert(req.Header["Content-MD5"], DeepEquals, "...")
- c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
-}
-
-func (s *S) TestPutObjectReadTimeout(c *C) {
- s.s3.ReadTimeout = 50 * time.Millisecond
- defer func() {
- s.s3.ReadTimeout = 0
- }()
-
- b := s.s3.Bucket("bucket")
- err := b.Put("name", []byte("content"), "content-type", s3.Private, s3.Options{})
-
- // Make sure that we get a timeout error.
- c.Assert(err, NotNil)
-
- // Set the response after the request times out so that the next request will work.
- testServer.Response(200, nil, "")
-
- // This time set the response within our timeout period so that we expect the call
- // to return successfully.
- go func() {
- time.Sleep(25 * time.Millisecond)
- testServer.Response(200, nil, "")
- }()
- err = b.Put("name", []byte("content"), "content-type", s3.Private, s3.Options{})
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestPutObjectHeader(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- err := b.PutHeader(
- "name",
- []byte("content"),
- map[string][]string{"Content-Type": {"content-type"}},
- s3.Private,
- )
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
- c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
- //c.Assert(req.Header["Content-MD5"], DeepEquals, "...")
- c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
-}
-
-func (s *S) TestPutReader(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- buf := bytes.NewBufferString("content")
- err := b.PutReader("name", buf, int64(buf.Len()), "content-type", s3.Private, s3.Options{})
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
- c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
- //c.Assert(req.Header["Content-MD5"], Equals, "...")
- c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
-}
-
-func (s *S) TestPutReaderHeader(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- buf := bytes.NewBufferString("content")
- err := b.PutReaderHeader(
- "name",
- buf,
- int64(buf.Len()),
- map[string][]string{"Content-Type": {"content-type"}},
- s3.Private,
- )
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "PUT")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
- c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
- c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
- //c.Assert(req.Header["Content-MD5"], Equals, "...")
- c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
-}
-
-// DelObject docs: http://goo.gl/APeTt
-
-func (s *S) TestDelObject(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- err := b.Del("name")
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "DELETE")
- c.Assert(req.URL.Path, Equals, "/bucket/name")
- c.Assert(req.Header["Date"], Not(Equals), "")
-}
-
-func (s *S) TestDelMultiObjects(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- objects := []s3.Object{s3.Object{Key: "test"}}
- err := b.DelMulti(s3.Delete{
- Quiet: false,
- Objects: objects,
- })
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "POST")
- c.Assert(req.URL.RawQuery, Equals, "delete=")
- c.Assert(req.Header["Date"], Not(Equals), "")
- c.Assert(req.Header["Content-MD5"], Not(Equals), "")
- c.Assert(req.Header["Content-Type"], Not(Equals), "")
- c.Assert(req.ContentLength, Not(Equals), "")
-}
-
-// Bucket List Objects docs: http://goo.gl/YjQTc
-
-func (s *S) TestList(c *C) {
- testServer.Response(200, nil, GetListResultDump1)
-
- b := s.s3.Bucket("quotes")
-
- data, err := b.List("N", "", "", 0)
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/quotes/")
- c.Assert(req.Header["Date"], Not(Equals), "")
- c.Assert(req.Form["prefix"], DeepEquals, []string{"N"})
- c.Assert(req.Form["delimiter"], DeepEquals, []string{""})
- c.Assert(req.Form["marker"], DeepEquals, []string{""})
- c.Assert(req.Form["max-keys"], DeepEquals, []string(nil))
-
- c.Assert(data.Name, Equals, "quotes")
- c.Assert(data.Prefix, Equals, "N")
- c.Assert(data.IsTruncated, Equals, false)
- c.Assert(len(data.Contents), Equals, 2)
-
- c.Assert(data.Contents[0].Key, Equals, "Nelson")
- c.Assert(data.Contents[0].LastModified, Equals, "2006-01-01T12:00:00.000Z")
- c.Assert(data.Contents[0].ETag, Equals, `"828ef3fdfa96f00ad9f27c383fc9ac7f"`)
- c.Assert(data.Contents[0].Size, Equals, int64(5))
- c.Assert(data.Contents[0].StorageClass, Equals, "STANDARD")
- c.Assert(data.Contents[0].Owner.ID, Equals, "bcaf161ca5fb16fd081034f")
- c.Assert(data.Contents[0].Owner.DisplayName, Equals, "webfile")
-
- c.Assert(data.Contents[1].Key, Equals, "Neo")
- c.Assert(data.Contents[1].LastModified, Equals, "2006-01-01T12:00:00.000Z")
- c.Assert(data.Contents[1].ETag, Equals, `"828ef3fdfa96f00ad9f27c383fc9ac7f"`)
- c.Assert(data.Contents[1].Size, Equals, int64(4))
- c.Assert(data.Contents[1].StorageClass, Equals, "STANDARD")
- c.Assert(data.Contents[1].Owner.ID, Equals, "bcaf1ffd86a5fb16fd081034f")
- c.Assert(data.Contents[1].Owner.DisplayName, Equals, "webfile")
-}
-
-func (s *S) TestListWithDelimiter(c *C) {
- testServer.Response(200, nil, GetListResultDump2)
-
- b := s.s3.Bucket("quotes")
-
- data, err := b.List("photos/2006/", "/", "some-marker", 1000)
- c.Assert(err, IsNil)
-
- req := testServer.WaitRequest()
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/quotes/")
- c.Assert(req.Header["Date"], Not(Equals), "")
- c.Assert(req.Form["prefix"], DeepEquals, []string{"photos/2006/"})
- c.Assert(req.Form["delimiter"], DeepEquals, []string{"/"})
- c.Assert(req.Form["marker"], DeepEquals, []string{"some-marker"})
- c.Assert(req.Form["max-keys"], DeepEquals, []string{"1000"})
-
- c.Assert(data.Name, Equals, "example-bucket")
- c.Assert(data.Prefix, Equals, "photos/2006/")
- c.Assert(data.Delimiter, Equals, "/")
- c.Assert(data.Marker, Equals, "some-marker")
- c.Assert(data.IsTruncated, Equals, false)
- c.Assert(len(data.Contents), Equals, 0)
- c.Assert(data.CommonPrefixes, DeepEquals, []string{"photos/2006/feb/", "photos/2006/jan/"})
-}
-
-func (s *S) TestExists(c *C) {
- testServer.Response(200, nil, "")
-
- b := s.s3.Bucket("bucket")
- result, err := b.Exists("name")
-
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "HEAD")
-
- c.Assert(err, IsNil)
- c.Assert(result, Equals, true)
-}
-
-func (s *S) TestExistsNotFound404(c *C) {
- testServer.Response(404, nil, "")
-
- b := s.s3.Bucket("bucket")
- result, err := b.Exists("name")
-
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "HEAD")
-
- c.Assert(err, IsNil)
- c.Assert(result, Equals, false)
-}
-
-func (s *S) TestExistsNotFound403(c *C) {
- testServer.Response(403, nil, "")
-
- b := s.s3.Bucket("bucket")
- result, err := b.Exists("name")
-
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "HEAD")
-
- c.Assert(err, IsNil)
- c.Assert(result, Equals, false)
-}
diff --git a/vendor/github.com/goamz/goamz/s3/s3i_test.go b/vendor/github.com/goamz/goamz/s3/s3i_test.go
deleted file mode 100644
index 1b898efc4..000000000
--- a/vendor/github.com/goamz/goamz/s3/s3i_test.go
+++ /dev/null
@@ -1,590 +0,0 @@
-package s3_test
-
-import (
- "bytes"
- "crypto/md5"
- "fmt"
- "io/ioutil"
- "net"
- "net/http"
- "sort"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/s3"
- "github.com/goamz/goamz/testutil"
- . "gopkg.in/check.v1"
-)
-
-// AmazonServer represents an Amazon S3 server.
-type AmazonServer struct {
- auth aws.Auth
-}
-
-func (s *AmazonServer) SetUp(c *C) {
- auth, err := aws.EnvAuth()
- if err != nil {
- c.Fatal(err.Error())
- }
- s.auth = auth
-}
-
-var _ = Suite(&AmazonClientSuite{Region: aws.USEast})
-var _ = Suite(&AmazonClientSuite{Region: aws.EUWest})
-var _ = Suite(&AmazonDomainClientSuite{Region: aws.USEast})
-
-// AmazonClientSuite tests the client against a live S3 server.
-type AmazonClientSuite struct {
- aws.Region
- srv AmazonServer
- ClientTests
-}
-
-func (s *AmazonClientSuite) SetUpSuite(c *C) {
- if !testutil.Amazon {
- c.Skip("live tests against AWS disabled (no -amazon)")
- }
- s.srv.SetUp(c)
- s.s3 = s3.New(s.srv.auth, s.Region)
- // In case tests were interrupted in the middle before.
- s.ClientTests.Cleanup()
-}
-
-func (s *AmazonClientSuite) TearDownTest(c *C) {
- s.ClientTests.Cleanup()
-}
-
-// AmazonDomainClientSuite tests the client against a live S3
-// server using bucket names in the endpoint domain name rather
-// than the request path.
-type AmazonDomainClientSuite struct {
- aws.Region
- srv AmazonServer
- ClientTests
-}
-
-func (s *AmazonDomainClientSuite) SetUpSuite(c *C) {
- if !testutil.Amazon {
- c.Skip("live tests against AWS disabled (no -amazon)")
- }
- s.srv.SetUp(c)
- region := s.Region
- region.S3BucketEndpoint = "https://${bucket}.s3.amazonaws.com"
- s.s3 = s3.New(s.srv.auth, region)
- s.ClientTests.Cleanup()
-}
-
-func (s *AmazonDomainClientSuite) TearDownTest(c *C) {
- s.ClientTests.Cleanup()
-}
-
-// ClientTests defines integration tests designed to test the client.
-// It is not used as a test suite in itself, but embedded within
-// another type.
-type ClientTests struct {
- s3 *s3.S3
- authIsBroken bool
-}
-
-func (s *ClientTests) Cleanup() {
- killBucket(testBucket(s.s3))
-}
-
-func testBucket(s *s3.S3) *s3.Bucket {
- // Watch out! If this function is corrupted and made to match with something
- // people own, killBucket will happily remove *everything* inside the bucket.
- key := s.Auth.AccessKey
- if len(key) >= 8 {
- key = s.Auth.AccessKey[:8]
- }
- return s.Bucket(fmt.Sprintf("goamz-%s-%s", s.Region.Name, key))
-}
-
-var attempts = aws.AttemptStrategy{
- Min: 5,
- Total: 20 * time.Second,
- Delay: 100 * time.Millisecond,
-}
-
-func killBucket(b *s3.Bucket) {
- var err error
- for attempt := attempts.Start(); attempt.Next(); {
- err = b.DelBucket()
- if err == nil {
- return
- }
- if _, ok := err.(*net.DNSError); ok {
- return
- }
- e, ok := err.(*s3.Error)
- if ok && e.Code == "NoSuchBucket" {
- return
- }
- if ok && e.Code == "BucketNotEmpty" {
- // Errors are ignored here. Just retry.
- resp, err := b.List("", "", "", 1000)
- if err == nil {
- for _, key := range resp.Contents {
- _ = b.Del(key.Key)
- }
- }
- multis, _, _ := b.ListMulti("", "")
- for _, m := range multis {
- _ = m.Abort()
- }
- }
- }
- message := "cannot delete test bucket"
- if err != nil {
- message += ": " + err.Error()
- }
- panic(message)
-}
-
-func get(url string) ([]byte, error) {
- for attempt := attempts.Start(); attempt.Next(); {
- resp, err := http.Get(url)
- if err != nil {
- if attempt.HasNext() {
- continue
- }
- return nil, err
- }
- data, err := ioutil.ReadAll(resp.Body)
- resp.Body.Close()
- if err != nil {
- if attempt.HasNext() {
- continue
- }
- return nil, err
- }
- return data, err
- }
- panic("unreachable")
-}
-
-func (s *ClientTests) TestBasicFunctionality(c *C) {
- b := testBucket(s.s3)
- err := b.PutBucket(s3.PublicRead)
- c.Assert(err, IsNil)
-
- err = b.Put("name", []byte("yo!"), "text/plain", s3.PublicRead, s3.Options{})
- c.Assert(err, IsNil)
- defer b.Del("name")
-
- data, err := b.Get("name")
- c.Assert(err, IsNil)
- c.Assert(string(data), Equals, "yo!")
-
- data, err = get(b.URL("name"))
- c.Assert(err, IsNil)
- c.Assert(string(data), Equals, "yo!")
-
- buf := bytes.NewBufferString("hey!")
- err = b.PutReader("name2", buf, int64(buf.Len()), "text/plain", s3.Private, s3.Options{})
- c.Assert(err, IsNil)
- defer b.Del("name2")
-
- rc, err := b.GetReader("name2")
- c.Assert(err, IsNil)
- data, err = ioutil.ReadAll(rc)
- c.Check(err, IsNil)
- c.Check(string(data), Equals, "hey!")
- rc.Close()
-
- data, err = get(b.SignedURL("name2", time.Now().Add(time.Hour)))
- c.Assert(err, IsNil)
- c.Assert(string(data), Equals, "hey!")
-
- if !s.authIsBroken {
- data, err = get(b.SignedURL("name2", time.Now().Add(-time.Hour)))
- c.Assert(err, IsNil)
- c.Assert(string(data), Matches, "(?s).*AccessDenied.*")
- }
-
- err = b.DelBucket()
- c.Assert(err, NotNil)
-
- s3err, ok := err.(*s3.Error)
- c.Assert(ok, Equals, true)
- c.Assert(s3err.Code, Equals, "BucketNotEmpty")
- c.Assert(s3err.BucketName, Equals, b.Name)
- c.Assert(s3err.Message, Equals, "The bucket you tried to delete is not empty")
-
- err = b.Del("name")
- c.Assert(err, IsNil)
- err = b.Del("name2")
- c.Assert(err, IsNil)
-
- err = b.DelBucket()
- c.Assert(err, IsNil)
-}
-
-func (s *ClientTests) TestGetNotFound(c *C) {
- b := s.s3.Bucket("goamz-" + s.s3.Auth.AccessKey)
- data, err := b.Get("non-existent")
-
- s3err, _ := err.(*s3.Error)
- c.Assert(s3err, NotNil)
- c.Assert(s3err.StatusCode, Equals, 404)
- c.Assert(s3err.Code, Equals, "NoSuchBucket")
- c.Assert(s3err.Message, Equals, "The specified bucket does not exist")
- c.Assert(data, IsNil)
-}
-
-// Communicate with all endpoints to see if they are alive.
-func (s *ClientTests) TestRegions(c *C) {
- errs := make(chan error, len(aws.Regions))
- for _, region := range aws.Regions {
- go func(r aws.Region) {
- s := s3.New(s.s3.Auth, r)
- b := s.Bucket("goamz-" + s.Auth.AccessKey)
- _, err := b.Get("non-existent")
- errs <- err
- }(region)
- }
- for _ = range aws.Regions {
- err := <-errs
- if err != nil {
- s3_err, ok := err.(*s3.Error)
- if ok {
- c.Check(s3_err.Code, Matches, "NoSuchBucket")
- } else if _, ok = err.(*net.DNSError); ok {
- // Okay as well.
- } else {
- c.Errorf("Non-S3 error: %s", err)
- }
- } else {
- c.Errorf("Test should have errored but it seems to have succeeded")
- }
- }
-}
-
-var objectNames = []string{
- "index.html",
- "index2.html",
- "photos/2006/February/sample2.jpg",
- "photos/2006/February/sample3.jpg",
- "photos/2006/February/sample4.jpg",
- "photos/2006/January/sample.jpg",
- "test/bar",
- "test/foo",
-}
-
-func keys(names ...string) []s3.Key {
- ks := make([]s3.Key, len(names))
- for i, name := range names {
- ks[i].Key = name
- }
- return ks
-}
-
-// As the ListResp specifies all the parameters to the
-// request too, we use it to specify request parameters
-// and expected results. The Contents field is
-// used only for the key names inside it.
-var listTests = []s3.ListResp{
- // normal list.
- {
- Contents: keys(objectNames...),
- }, {
- Marker: objectNames[0],
- Contents: keys(objectNames[1:]...),
- }, {
- Marker: objectNames[0] + "a",
- Contents: keys(objectNames[1:]...),
- }, {
- Marker: "z",
- },
-
- // limited results.
- {
- MaxKeys: 2,
- Contents: keys(objectNames[0:2]...),
- IsTruncated: true,
- }, {
- MaxKeys: 2,
- Marker: objectNames[0],
- Contents: keys(objectNames[1:3]...),
- IsTruncated: true,
- }, {
- MaxKeys: 2,
- Marker: objectNames[len(objectNames)-2],
- Contents: keys(objectNames[len(objectNames)-1:]...),
- },
-
- // with delimiter
- {
- Delimiter: "/",
- CommonPrefixes: []string{"photos/", "test/"},
- Contents: keys("index.html", "index2.html"),
- }, {
- Delimiter: "/",
- Prefix: "photos/2006/",
- CommonPrefixes: []string{"photos/2006/February/", "photos/2006/January/"},
- }, {
- Delimiter: "/",
- Prefix: "t",
- CommonPrefixes: []string{"test/"},
- }, {
- Delimiter: "/",
- MaxKeys: 1,
- Contents: keys("index.html"),
- IsTruncated: true,
- }, {
- Delimiter: "/",
- MaxKeys: 1,
- Marker: "index2.html",
- CommonPrefixes: []string{"photos/"},
- IsTruncated: true,
- }, {
- Delimiter: "/",
- MaxKeys: 1,
- Marker: "photos/",
- CommonPrefixes: []string{"test/"},
- IsTruncated: false,
- }, {
- Delimiter: "Feb",
- CommonPrefixes: []string{"photos/2006/Feb"},
- Contents: keys("index.html", "index2.html", "photos/2006/January/sample.jpg", "test/bar", "test/foo"),
- },
-}
-
-func (s *ClientTests) TestDoublePutBucket(c *C) {
- b := testBucket(s.s3)
- err := b.PutBucket(s3.PublicRead)
- c.Assert(err, IsNil)
-
- err = b.PutBucket(s3.PublicRead)
- if err != nil {
- c.Assert(err, FitsTypeOf, new(s3.Error))
- c.Assert(err.(*s3.Error).Code, Equals, "BucketAlreadyOwnedByYou")
- }
-}
-
-func (s *ClientTests) TestBucketList(c *C) {
- b := testBucket(s.s3)
- err := b.PutBucket(s3.Private)
- c.Assert(err, IsNil)
-
- objData := make(map[string][]byte)
- for i, path := range objectNames {
- data := []byte(strings.Repeat("a", i))
- err := b.Put(path, data, "text/plain", s3.Private, s3.Options{})
- c.Assert(err, IsNil)
- defer b.Del(path)
- objData[path] = data
- }
-
- for i, t := range listTests {
- c.Logf("test %d", i)
- resp, err := b.List(t.Prefix, t.Delimiter, t.Marker, t.MaxKeys)
- c.Assert(err, IsNil)
- c.Check(resp.Name, Equals, b.Name)
- c.Check(resp.Delimiter, Equals, t.Delimiter)
- c.Check(resp.IsTruncated, Equals, t.IsTruncated)
- c.Check(resp.CommonPrefixes, DeepEquals, t.CommonPrefixes)
- checkContents(c, resp.Contents, objData, t.Contents)
- }
-}
-
-func etag(data []byte) string {
- sum := md5.New()
- sum.Write(data)
- return fmt.Sprintf(`"%x"`, sum.Sum(nil))
-}
-
-func checkContents(c *C, contents []s3.Key, data map[string][]byte, expected []s3.Key) {
- c.Assert(contents, HasLen, len(expected))
- for i, k := range contents {
- c.Check(k.Key, Equals, expected[i].Key)
- // TODO mtime
- c.Check(k.Size, Equals, int64(len(data[k.Key])))
- c.Check(k.ETag, Equals, etag(data[k.Key]))
- }
-}
-
-func (s *ClientTests) TestMultiInitPutList(c *C) {
- b := testBucket(s.s3)
- err := b.PutBucket(s3.Private)
- c.Assert(err, IsNil)
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
- c.Assert(multi.UploadId, Matches, ".+")
- defer multi.Abort()
-
- var sent []s3.Part
-
- for i := 0; i < 5; i++ {
- p, err := multi.PutPart(i+1, strings.NewReader(fmt.Sprintf("<part %d>", i+1)))
- c.Assert(err, IsNil)
- c.Assert(p.N, Equals, i+1)
- c.Assert(p.Size, Equals, int64(8))
- c.Assert(p.ETag, Matches, ".+")
- sent = append(sent, p)
- }
-
- s3.SetListPartsMax(2)
-
- parts, err := multi.ListParts()
- c.Assert(err, IsNil)
- c.Assert(parts, HasLen, len(sent))
- for i := range parts {
- c.Assert(parts[i].N, Equals, sent[i].N)
- c.Assert(parts[i].Size, Equals, sent[i].Size)
- c.Assert(parts[i].ETag, Equals, sent[i].ETag)
- }
-
- err = multi.Complete(parts)
- s3err, failed := err.(*s3.Error)
- c.Assert(failed, Equals, true)
- c.Assert(s3err.Code, Equals, "EntityTooSmall")
-
- err = multi.Abort()
- c.Assert(err, IsNil)
- _, err = multi.ListParts()
- s3err, ok := err.(*s3.Error)
- c.Assert(ok, Equals, true)
- c.Assert(s3err.Code, Equals, "NoSuchUpload")
-}
-
-// This may take a minute or more due to the minimum size accepted S3
-// on multipart upload parts.
-func (s *ClientTests) TestMultiComplete(c *C) {
- b := testBucket(s.s3)
- err := b.PutBucket(s3.Private)
- c.Assert(err, IsNil)
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
- c.Assert(multi.UploadId, Matches, ".+")
- defer multi.Abort()
-
- // Minimum size S3 accepts for all but the last part is 5MB.
- data1 := make([]byte, 5*1024*1024)
- data2 := []byte("<part 2>")
-
- part1, err := multi.PutPart(1, bytes.NewReader(data1))
- c.Assert(err, IsNil)
- part2, err := multi.PutPart(2, bytes.NewReader(data2))
- c.Assert(err, IsNil)
-
- // Purposefully reversed. The order requirement must be handled.
- err = multi.Complete([]s3.Part{part2, part1})
- c.Assert(err, IsNil)
-
- data, err := b.Get("multi")
- c.Assert(err, IsNil)
-
- c.Assert(len(data), Equals, len(data1)+len(data2))
- for i := range data1 {
- if data[i] != data1[i] {
- c.Fatalf("uploaded object at byte %d: want %d, got %d", data1[i], data[i])
- }
- }
- c.Assert(string(data[len(data1):]), Equals, string(data2))
-}
-
-type multiList []*s3.Multi
-
-func (l multiList) Len() int { return len(l) }
-func (l multiList) Less(i, j int) bool { return l[i].Key < l[j].Key }
-func (l multiList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
-
-func (s *ClientTests) TestListMulti(c *C) {
- b := testBucket(s.s3)
- err := b.PutBucket(s3.Private)
- c.Assert(err, IsNil)
-
- // Ensure an empty state before testing its behavior.
- multis, _, err := b.ListMulti("", "")
- for _, m := range multis {
- err := m.Abort()
- c.Assert(err, IsNil)
- }
-
- keys := []string{
- "a/multi2",
- "a/multi3",
- "b/multi4",
- "multi1",
- }
- for _, key := range keys {
- m, err := b.InitMulti(key, "", s3.Private)
- c.Assert(err, IsNil)
- defer m.Abort()
- }
-
- // Amazon's implementation of the multiple-request listing for
- // multipart uploads in progress seems broken in multiple ways.
- // (next tokens are not provided, etc).
- //s3.SetListMultiMax(2)
-
- multis, prefixes, err := b.ListMulti("", "")
- c.Assert(err, IsNil)
- for attempt := attempts.Start(); attempt.Next() && len(multis) < len(keys); {
- multis, prefixes, err = b.ListMulti("", "")
- c.Assert(err, IsNil)
- }
- sort.Sort(multiList(multis))
- c.Assert(prefixes, IsNil)
- var gotKeys []string
- for _, m := range multis {
- gotKeys = append(gotKeys, m.Key)
- }
- c.Assert(gotKeys, DeepEquals, keys)
- for _, m := range multis {
- c.Assert(m.Bucket, Equals, b)
- c.Assert(m.UploadId, Matches, ".+")
- }
-
- multis, prefixes, err = b.ListMulti("", "/")
- for attempt := attempts.Start(); attempt.Next() && len(prefixes) < 2; {
- multis, prefixes, err = b.ListMulti("", "")
- c.Assert(err, IsNil)
- }
- c.Assert(err, IsNil)
- c.Assert(prefixes, DeepEquals, []string{"a/", "b/"})
- c.Assert(multis, HasLen, 1)
- c.Assert(multis[0].Bucket, Equals, b)
- c.Assert(multis[0].Key, Equals, "multi1")
- c.Assert(multis[0].UploadId, Matches, ".+")
-
- for attempt := attempts.Start(); attempt.Next() && len(multis) < 2; {
- multis, prefixes, err = b.ListMulti("", "")
- c.Assert(err, IsNil)
- }
- multis, prefixes, err = b.ListMulti("a/", "/")
- c.Assert(err, IsNil)
- c.Assert(prefixes, IsNil)
- c.Assert(multis, HasLen, 2)
- c.Assert(multis[0].Bucket, Equals, b)
- c.Assert(multis[0].Key, Equals, "a/multi2")
- c.Assert(multis[0].UploadId, Matches, ".+")
- c.Assert(multis[1].Bucket, Equals, b)
- c.Assert(multis[1].Key, Equals, "a/multi3")
- c.Assert(multis[1].UploadId, Matches, ".+")
-}
-
-func (s *ClientTests) TestMultiPutAllZeroLength(c *C) {
- b := testBucket(s.s3)
- err := b.PutBucket(s3.Private)
- c.Assert(err, IsNil)
-
- multi, err := b.InitMulti("multi", "text/plain", s3.Private)
- c.Assert(err, IsNil)
- defer multi.Abort()
-
- // This tests an edge case. Amazon requires at least one
- // part for multiprat uploads to work, even the part is empty.
- parts, err := multi.PutAll(strings.NewReader(""), 5*1024*1024)
- c.Assert(err, IsNil)
- c.Assert(parts, HasLen, 1)
- c.Assert(parts[0].Size, Equals, int64(0))
- c.Assert(parts[0].ETag, Equals, `"d41d8cd98f00b204e9800998ecf8427e"`)
-
- err = multi.Complete(parts)
- c.Assert(err, IsNil)
-}
diff --git a/vendor/github.com/goamz/goamz/s3/s3t_test.go b/vendor/github.com/goamz/goamz/s3/s3t_test.go
deleted file mode 100644
index 4e6f61fdb..000000000
--- a/vendor/github.com/goamz/goamz/s3/s3t_test.go
+++ /dev/null
@@ -1,83 +0,0 @@
-package s3_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/s3"
- "github.com/goamz/goamz/s3/s3test"
- . "gopkg.in/check.v1"
-)
-
-type LocalServer struct {
- auth aws.Auth
- region aws.Region
- srv *s3test.Server
- config *s3test.Config
-}
-
-func (s *LocalServer) SetUp(c *C) {
- srv, err := s3test.NewServer(s.config)
- c.Assert(err, IsNil)
- c.Assert(srv, NotNil)
-
- s.srv = srv
- s.region = aws.Region{
- Name: "faux-region-1",
- S3Endpoint: srv.URL(),
- S3LocationConstraint: true, // s3test server requires a LocationConstraint
- }
-}
-
-// LocalServerSuite defines tests that will run
-// against the local s3test server. It includes
-// selected tests from ClientTests;
-// when the s3test functionality is sufficient, it should
-// include all of them, and ClientTests can be simply embedded.
-type LocalServerSuite struct {
- srv LocalServer
- clientTests ClientTests
-}
-
-var (
- // run tests twice, once in us-east-1 mode, once not.
- _ = Suite(&LocalServerSuite{
- srv: LocalServer{
- config: &s3test.Config{},
- },
- })
- _ = Suite(&LocalServerSuite{
- srv: LocalServer{
- config: &s3test.Config{
- Send409Conflict: true,
- },
- },
- })
-)
-
-func (s *LocalServerSuite) SetUpSuite(c *C) {
- s.srv.SetUp(c)
- s.clientTests.s3 = s3.New(s.srv.auth, s.srv.region)
-
- // TODO Sadly the fake server ignores auth completely right now. :-(
- s.clientTests.authIsBroken = true
- s.clientTests.Cleanup()
-}
-
-func (s *LocalServerSuite) TearDownTest(c *C) {
- s.clientTests.Cleanup()
-}
-
-func (s *LocalServerSuite) TestBasicFunctionality(c *C) {
- s.clientTests.TestBasicFunctionality(c)
-}
-
-func (s *LocalServerSuite) TestGetNotFound(c *C) {
- s.clientTests.TestGetNotFound(c)
-}
-
-func (s *LocalServerSuite) TestBucketList(c *C) {
- s.clientTests.TestBucketList(c)
-}
-
-func (s *LocalServerSuite) TestDoublePutBucket(c *C) {
- s.clientTests.TestDoublePutBucket(c)
-}
diff --git a/vendor/github.com/goamz/goamz/s3/s3test/server.go b/vendor/github.com/goamz/goamz/s3/s3test/server.go
deleted file mode 100644
index 04808d3ad..000000000
--- a/vendor/github.com/goamz/goamz/s3/s3test/server.go
+++ /dev/null
@@ -1,642 +0,0 @@
-package s3test
-
-import (
- "bytes"
- "crypto/md5"
- "encoding/base64"
- "encoding/hex"
- "encoding/xml"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "net"
- "net/http"
- "net/url"
- "regexp"
- "sort"
- "strconv"
- "strings"
- "sync"
- "time"
-
- "github.com/goamz/goamz/s3"
-)
-
-const debug = false
-
-type s3Error struct {
- statusCode int
- XMLName struct{} `xml:"Error"`
- Code string
- Message string
- BucketName string
- RequestId string
- HostId string
-}
-
-type action struct {
- srv *Server
- w http.ResponseWriter
- req *http.Request
- reqId string
-}
-
-// Config controls the internal behaviour of the Server. A nil config is the default
-// and behaves as if all configurations assume their default behaviour. Once passed
-// to NewServer, the configuration must not be modified.
-type Config struct {
- // Send409Conflict controls how the Server will respond to calls to PUT on a
- // previously existing bucket. The default is false, and corresponds to the
- // us-east-1 s3 enpoint. Setting this value to true emulates the behaviour of
- // all other regions.
- // http://docs.amazonwebservices.com/AmazonS3/latest/API/ErrorResponses.html
- Send409Conflict bool
- // Set the host string on which to serve s3test server.
- Host string
-}
-
-func (c *Config) send409Conflict() bool {
- if c != nil {
- return c.Send409Conflict
- }
- return false
-}
-
-// Server is a fake S3 server for testing purposes.
-// All of the data for the server is kept in memory.
-type Server struct {
- url string
- reqId int
- listener net.Listener
- mu sync.Mutex
- buckets map[string]*bucket
- config *Config
-}
-
-type bucket struct {
- name string
- acl s3.ACL
- ctime time.Time
- objects map[string]*object
-}
-
-type object struct {
- name string
- mtime time.Time
- meta http.Header // metadata to return with requests.
- checksum []byte // also held as Content-MD5 in meta.
- data []byte
-}
-
-// A resource encapsulates the subject of an HTTP request.
-// The resource referred to may or may not exist
-// when the request is made.
-type resource interface {
- put(a *action) interface{}
- get(a *action) interface{}
- post(a *action) interface{}
- delete(a *action) interface{}
-}
-
-func NewServer(config *Config) (*Server, error) {
- if config.Host == "" {
- config.Host = "localhost:0"
- }
-
- l, err := net.Listen("tcp", config.Host)
- if err != nil {
- return nil, fmt.Errorf("cannot listen on localhost: %v", err)
- }
- srv := &Server{
- listener: l,
- url: "http://" + l.Addr().String(),
- buckets: make(map[string]*bucket),
- config: config,
- }
- go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
- srv.serveHTTP(w, req)
- }))
- return srv, nil
-}
-
-// Quit closes down the server.
-func (srv *Server) Quit() {
- srv.listener.Close()
-}
-
-// URL returns a URL for the server.
-func (srv *Server) URL() string {
- return srv.url
-}
-
-func fatalf(code int, codeStr string, errf string, a ...interface{}) {
- panic(&s3Error{
- statusCode: code,
- Code: codeStr,
- Message: fmt.Sprintf(errf, a...),
- })
-}
-
-// serveHTTP serves the S3 protocol.
-func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
- // ignore error from ParseForm as it's usually spurious.
- req.ParseForm()
-
- srv.mu.Lock()
- defer srv.mu.Unlock()
-
- if debug {
- log.Printf("s3test %q %q", req.Method, req.URL)
- }
- a := &action{
- srv: srv,
- w: w,
- req: req,
- reqId: fmt.Sprintf("%09X", srv.reqId),
- }
- srv.reqId++
-
- var r resource
- defer func() {
- switch err := recover().(type) {
- case *s3Error:
- switch r := r.(type) {
- case objectResource:
- err.BucketName = r.bucket.name
- case bucketResource:
- err.BucketName = r.name
- }
- err.RequestId = a.reqId
- // TODO HostId
- w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
- w.WriteHeader(err.statusCode)
- xmlMarshal(w, err)
- case nil:
- default:
- panic(err)
- }
- }()
-
- r = srv.resourceForURL(req.URL)
-
- var resp interface{}
- switch req.Method {
- case "PUT":
- resp = r.put(a)
- case "GET", "HEAD":
- resp = r.get(a)
- case "DELETE":
- resp = r.delete(a)
- case "POST":
- resp = r.post(a)
- default:
- fatalf(400, "MethodNotAllowed", "unknown http request method %q", req.Method)
- }
- if resp != nil && req.Method != "HEAD" {
- xmlMarshal(w, resp)
- }
-}
-
-// xmlMarshal is the same as xml.Marshal except that
-// it panics on error. The marshalling should not fail,
-// but we want to know if it does.
-func xmlMarshal(w io.Writer, x interface{}) {
- if err := xml.NewEncoder(w).Encode(x); err != nil {
- panic(fmt.Errorf("error marshalling %#v: %v", x, err))
- }
-}
-
-// In a fully implemented test server, each of these would have
-// its own resource type.
-var unimplementedBucketResourceNames = map[string]bool{
- "acl": true,
- "lifecycle": true,
- "policy": true,
- "location": true,
- "logging": true,
- "notification": true,
- "versions": true,
- "requestPayment": true,
- "versioning": true,
- "website": true,
- "uploads": true,
-}
-
-var unimplementedObjectResourceNames = map[string]bool{
- "uploadId": true,
- "acl": true,
- "torrent": true,
- "uploads": true,
-}
-
-var pathRegexp = regexp.MustCompile("/(([^/]+)(/(.*))?)?")
-
-// resourceForURL returns a resource object for the given URL.
-func (srv *Server) resourceForURL(u *url.URL) (r resource) {
- m := pathRegexp.FindStringSubmatch(u.Path)
- if m == nil {
- fatalf(404, "InvalidURI", "Couldn't parse the specified URI")
- }
- bucketName := m[2]
- objectName := m[4]
- if bucketName == "" {
- return nullResource{} // root
- }
- b := bucketResource{
- name: bucketName,
- bucket: srv.buckets[bucketName],
- }
- q := u.Query()
- if objectName == "" {
- for name := range q {
- if unimplementedBucketResourceNames[name] {
- return nullResource{}
- }
- }
- return b
-
- }
- if b.bucket == nil {
- fatalf(404, "NoSuchBucket", "The specified bucket does not exist")
- }
- objr := objectResource{
- name: objectName,
- version: q.Get("versionId"),
- bucket: b.bucket,
- }
- for name := range q {
- if unimplementedObjectResourceNames[name] {
- return nullResource{}
- }
- }
- if obj := objr.bucket.objects[objr.name]; obj != nil {
- objr.object = obj
- }
- return objr
-}
-
-// nullResource has error stubs for all resource methods.
-type nullResource struct{}
-
-func notAllowed() interface{} {
- fatalf(400, "MethodNotAllowed", "The specified method is not allowed against this resource")
- return nil
-}
-
-func (nullResource) put(a *action) interface{} { return notAllowed() }
-func (nullResource) get(a *action) interface{} { return notAllowed() }
-func (nullResource) post(a *action) interface{} { return notAllowed() }
-func (nullResource) delete(a *action) interface{} { return notAllowed() }
-
-const timeFormat = "2006-01-02T15:04:05.000Z07:00"
-
-type bucketResource struct {
- name string
- bucket *bucket // non-nil if the bucket already exists.
-}
-
-// GET on a bucket lists the objects in the bucket.
-// http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGET.html
-func (r bucketResource) get(a *action) interface{} {
- if r.bucket == nil {
- fatalf(404, "NoSuchBucket", "The specified bucket does not exist")
- }
- delimiter := a.req.Form.Get("delimiter")
- marker := a.req.Form.Get("marker")
- maxKeys := -1
- if s := a.req.Form.Get("max-keys"); s != "" {
- i, err := strconv.Atoi(s)
- if err != nil || i < 0 {
- fatalf(400, "invalid value for max-keys: %q", s)
- }
- maxKeys = i
- }
- prefix := a.req.Form.Get("prefix")
- a.w.Header().Set("Content-Type", "application/xml")
-
- if a.req.Method == "HEAD" {
- return nil
- }
-
- var objs orderedObjects
-
- // first get all matching objects and arrange them in alphabetical order.
- for name, obj := range r.bucket.objects {
- if strings.HasPrefix(name, prefix) {
- objs = append(objs, obj)
- }
- }
- sort.Sort(objs)
-
- if maxKeys <= 0 {
- maxKeys = 1000
- }
- resp := &s3.ListResp{
- Name: r.bucket.name,
- Prefix: prefix,
- Delimiter: delimiter,
- Marker: marker,
- MaxKeys: maxKeys,
- }
-
- var prefixes []string
- for _, obj := range objs {
- if !strings.HasPrefix(obj.name, prefix) {
- continue
- }
- name := obj.name
- isPrefix := false
- if delimiter != "" {
- if i := strings.Index(obj.name[len(prefix):], delimiter); i >= 0 {
- name = obj.name[:len(prefix)+i+len(delimiter)]
- if prefixes != nil && prefixes[len(prefixes)-1] == name {
- continue
- }
- isPrefix = true
- }
- }
- if name <= marker {
- continue
- }
- if len(resp.Contents)+len(prefixes) >= maxKeys {
- resp.IsTruncated = true
- break
- }
- if isPrefix {
- prefixes = append(prefixes, name)
- } else {
- // Contents contains only keys not found in CommonPrefixes
- resp.Contents = append(resp.Contents, obj.s3Key())
- }
- }
- resp.CommonPrefixes = prefixes
- return resp
-}
-
-// orderedObjects holds a slice of objects that can be sorted
-// by name.
-type orderedObjects []*object
-
-func (s orderedObjects) Len() int {
- return len(s)
-}
-func (s orderedObjects) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
-}
-func (s orderedObjects) Less(i, j int) bool {
- return s[i].name < s[j].name
-}
-
-func (obj *object) s3Key() s3.Key {
- return s3.Key{
- Key: obj.name,
- LastModified: obj.mtime.Format(timeFormat),
- Size: int64(len(obj.data)),
- ETag: fmt.Sprintf(`"%x"`, obj.checksum),
- // TODO StorageClass
- // TODO Owner
- }
-}
-
-// DELETE on a bucket deletes the bucket if it's not empty.
-func (r bucketResource) delete(a *action) interface{} {
- b := r.bucket
- if b == nil {
- fatalf(404, "NoSuchBucket", "The specified bucket does not exist")
- }
- if len(b.objects) > 0 {
- fatalf(400, "BucketNotEmpty", "The bucket you tried to delete is not empty")
- }
- delete(a.srv.buckets, b.name)
- return nil
-}
-
-// PUT on a bucket creates the bucket.
-// http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUT.html
-func (r bucketResource) put(a *action) interface{} {
- var created bool
- if r.bucket == nil {
- if !validBucketName(r.name) {
- fatalf(400, "InvalidBucketName", "The specified bucket is not valid")
- }
- if loc := locationConstraint(a); loc == "" {
- fatalf(400, "InvalidRequets", "The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.")
- }
- // TODO validate acl
- r.bucket = &bucket{
- name: r.name,
- // TODO default acl
- objects: make(map[string]*object),
- }
- a.srv.buckets[r.name] = r.bucket
- created = true
- }
- if !created && a.srv.config.send409Conflict() {
- fatalf(409, "BucketAlreadyOwnedByYou", "Your previous request to create the named bucket succeeded and you already own it.")
- }
- r.bucket.acl = s3.ACL(a.req.Header.Get("x-amz-acl"))
- return nil
-}
-
-func (bucketResource) post(a *action) interface{} {
- fatalf(400, "Method", "bucket POST method not available")
- return nil
-}
-
-// validBucketName returns whether name is a valid bucket name.
-// Here are the rules, from:
-// http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/BucketRestrictions.html
-//
-// Can contain lowercase letters, numbers, periods (.), underscores (_),
-// and dashes (-). You can use uppercase letters for buckets only in the
-// US Standard region.
-//
-// Must start with a number or letter
-//
-// Must be between 3 and 255 characters long
-//
-// There's one extra rule (Must not be formatted as an IP address (e.g., 192.168.5.4)
-// but the real S3 server does not seem to check that rule, so we will not
-// check it either.
-//
-func validBucketName(name string) bool {
- if len(name) < 3 || len(name) > 255 {
- return false
- }
- r := name[0]
- if !(r >= '0' && r <= '9' || r >= 'a' && r <= 'z') {
- return false
- }
- for _, r := range name {
- switch {
- case r >= '0' && r <= '9':
- case r >= 'a' && r <= 'z':
- case r == '_' || r == '-':
- case r == '.':
- default:
- return false
- }
- }
- return true
-}
-
-var responseParams = map[string]bool{
- "content-type": true,
- "content-language": true,
- "expires": true,
- "cache-control": true,
- "content-disposition": true,
- "content-encoding": true,
-}
-
-type objectResource struct {
- name string
- version string
- bucket *bucket // always non-nil.
- object *object // may be nil.
-}
-
-const awsTimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT"
-
-// GET on an object gets the contents of the object.
-// http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html
-func (objr objectResource) get(a *action) interface{} {
- obj := objr.object
- if obj == nil {
- fatalf(404, "NoSuchKey", "The specified key does not exist.")
- }
- h := a.w.Header()
- // add metadata
- for name, d := range obj.meta {
- h[name] = d
- }
- // override header values in response to request parameters.
- for name, vals := range a.req.Form {
- if strings.HasPrefix(name, "response-") {
- name = name[len("response-"):]
- if !responseParams[name] {
- continue
- }
- h.Set(name, vals[0])
- }
- }
- if r := a.req.Header.Get("Range"); r != "" {
- fatalf(400, "NotImplemented", "range unimplemented")
- }
- // TODO Last-Modified-Since
- // TODO If-Modified-Since
- // TODO If-Unmodified-Since
- // TODO If-Match
- // TODO If-None-Match
- // TODO Connection: close ??
- // TODO x-amz-request-id
- h.Set("Content-Length", fmt.Sprint(len(obj.data)))
- h.Set("ETag", hex.EncodeToString(obj.checksum))
- h.Set("Last-Modified", obj.mtime.Format(awsTimeFormat))
- if a.req.Method == "HEAD" {
- return nil
- }
- // TODO avoid holding the lock when writing data.
- _, err := a.w.Write(obj.data)
- if err != nil {
- // we can't do much except just log the fact.
- log.Printf("error writing data: %v", err)
- }
- return nil
-}
-
-var metaHeaders = map[string]bool{
- "Content-MD5": true,
- "x-amz-acl": true,
- "Content-Type": true,
- "Content-Encoding": true,
- "Content-Disposition": true,
-}
-
-// PUT on an object creates the object.
-func (objr objectResource) put(a *action) interface{} {
- // TODO Cache-Control header
- // TODO Expires header
- // TODO x-amz-server-side-encryption
- // TODO x-amz-storage-class
-
- // TODO is this correct, or should we erase all previous metadata?
- obj := objr.object
- if obj == nil {
- obj = &object{
- name: objr.name,
- meta: make(http.Header),
- }
- }
-
- var expectHash []byte
- if c := a.req.Header.Get("Content-MD5"); c != "" {
- var err error
- expectHash, err = base64.StdEncoding.DecodeString(c)
- if err != nil || len(expectHash) != md5.Size {
- fatalf(400, "InvalidDigest", "The Content-MD5 you specified was invalid")
- }
- }
- sum := md5.New()
- // TODO avoid holding lock while reading data.
- data, err := ioutil.ReadAll(io.TeeReader(a.req.Body, sum))
- if err != nil {
- fatalf(400, "TODO", "read error")
- }
- gotHash := sum.Sum(nil)
- if expectHash != nil && bytes.Compare(gotHash, expectHash) != 0 {
- fatalf(400, "BadDigest", "The Content-MD5 you specified did not match what we received")
- }
- if a.req.ContentLength >= 0 && int64(len(data)) != a.req.ContentLength {
- fatalf(400, "IncompleteBody", "You did not provide the number of bytes specified by the Content-Length HTTP header")
- }
-
- // PUT request has been successful - save data and metadata
- for key, values := range a.req.Header {
- key = http.CanonicalHeaderKey(key)
- if metaHeaders[key] || strings.HasPrefix(key, "X-Amz-Meta-") {
- obj.meta[key] = values
- }
- }
- obj.data = data
- obj.checksum = gotHash
- obj.mtime = time.Now()
- objr.bucket.objects[objr.name] = obj
-
- h := a.w.Header()
- h.Set("ETag", fmt.Sprintf(`"%s"`, hex.EncodeToString(obj.checksum)))
-
- return nil
-}
-
-func (objr objectResource) delete(a *action) interface{} {
- delete(objr.bucket.objects, objr.name)
- return nil
-}
-
-func (objr objectResource) post(a *action) interface{} {
- fatalf(400, "MethodNotAllowed", "The specified method is not allowed against this resource")
- return nil
-}
-
-type CreateBucketConfiguration struct {
- LocationConstraint string
-}
-
-// locationConstraint parses the <CreateBucketConfiguration /> request body (if present).
-// If there is no body, an empty string will be returned.
-func locationConstraint(a *action) string {
- var body bytes.Buffer
- if _, err := io.Copy(&body, a.req.Body); err != nil {
- fatalf(400, "InvalidRequest", err.Error())
- }
- if body.Len() == 0 {
- return ""
- }
- var loc CreateBucketConfiguration
- if err := xml.NewDecoder(&body).Decode(&loc); err != nil {
- fatalf(400, "InvalidRequest", err.Error())
- }
- return loc.LocationConstraint
-}
diff --git a/vendor/github.com/goamz/goamz/s3/sign.go b/vendor/github.com/goamz/goamz/s3/sign.go
deleted file mode 100644
index 722d97d29..000000000
--- a/vendor/github.com/goamz/goamz/s3/sign.go
+++ /dev/null
@@ -1,141 +0,0 @@
-package s3
-
-import (
- "crypto/hmac"
- "crypto/sha1"
- "encoding/base64"
- "github.com/goamz/goamz/aws"
- "log"
- "sort"
- "strings"
-)
-
-var b64 = base64.StdEncoding
-
-// ----------------------------------------------------------------------------
-// S3 signing (http://goo.gl/G1LrK)
-
-var s3ParamsToSign = map[string]bool{
- "acl": true,
- "location": true,
- "logging": true,
- "notification": true,
- "partNumber": true,
- "policy": true,
- "requestPayment": true,
- "torrent": true,
- "uploadId": true,
- "uploads": true,
- "versionId": true,
- "versioning": true,
- "versions": true,
- "response-content-type": true,
- "response-content-language": true,
- "response-expires": true,
- "response-cache-control": true,
- "response-content-disposition": true,
- "response-content-encoding": true,
- "website": true,
- "delete": true,
-}
-
-type keySortableTupleList []keySortableTuple
-
-type keySortableTuple struct {
- Key string
- TupleString string
-}
-
-func (l keySortableTupleList) StringSlice() []string {
- slice := make([]string, len(l))
- for i, v := range l {
- slice[i] = v.TupleString
- }
- return slice
-}
-
-func (l keySortableTupleList) Len() int {
- return len(l)
-}
-
-func (l keySortableTupleList) Less(i, j int) bool {
- return l[i].Key < l[j].Key
-}
-
-func (l keySortableTupleList) Swap(i, j int) {
- l[i], l[j] = l[j], l[i]
-}
-
-func sign(auth aws.Auth, method, canonicalPath string, params, headers map[string][]string) {
- var md5, ctype, date, xamz string
- var xamzDate bool
- var sarray keySortableTupleList
- for k, v := range headers {
- k = strings.ToLower(k)
- switch k {
- case "content-md5":
- md5 = v[0]
- case "content-type":
- ctype = v[0]
- case "date":
- if !xamzDate {
- date = v[0]
- }
- default:
- if strings.HasPrefix(k, "x-amz-") {
- vall := strings.Join(v, ",")
- sarray = append(sarray, keySortableTuple{k, k + ":" + vall})
- if k == "x-amz-date" {
- xamzDate = true
- date = ""
- }
- }
- }
- }
- if len(sarray) > 0 {
- sort.Sort(sarray)
- xamz = strings.Join(sarray.StringSlice(), "\n") + "\n"
- }
-
- expires := false
- if v, ok := params["Expires"]; ok {
- // Query string request authentication alternative.
- expires = true
- date = v[0]
- params["AWSAccessKeyId"] = []string{auth.AccessKey}
- }
-
- sarray = sarray[0:0]
- for k, v := range params {
- if s3ParamsToSign[k] {
- for _, vi := range v {
- if vi == "" {
- sarray = append(sarray, keySortableTuple{k, k})
- } else {
- // "When signing you do not encode these values."
- sarray = append(sarray, keySortableTuple{k, k + "=" + vi})
- }
- }
- }
- }
- if len(sarray) > 0 {
- sort.Sort(sarray)
- canonicalPath = canonicalPath + "?" + strings.Join(sarray.StringSlice(), "&")
- }
-
- payload := method + "\n" + md5 + "\n" + ctype + "\n" + date + "\n" + xamz + canonicalPath
- hash := hmac.New(sha1.New, []byte(auth.SecretKey))
- hash.Write([]byte(payload))
- signature := make([]byte, b64.EncodedLen(hash.Size()))
- b64.Encode(signature, hash.Sum(nil))
-
- if expires {
- params["Signature"] = []string{string(signature)}
- } else {
- headers["Authorization"] = []string{"AWS " + auth.AccessKey + ":" + string(signature)}
- }
- if debug {
- log.Printf("Signature payload: %q", payload)
- log.Printf("Signature: %q", signature)
- }
-}
diff --git a/vendor/github.com/goamz/goamz/s3/sign_test.go b/vendor/github.com/goamz/goamz/s3/sign_test.go
deleted file mode 100644
index 112e1ca3e..000000000
--- a/vendor/github.com/goamz/goamz/s3/sign_test.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package s3_test
-
-import (
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/s3"
- . "gopkg.in/check.v1"
-)
-
-// S3 ReST authentication docs: http://goo.gl/G1LrK
-
-var testAuth = aws.Auth{AccessKey: "0PN5J17HBGZHT7JJ3X82", SecretKey: "uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o"}
-
-func (s *S) TestSignExampleObjectGet(c *C) {
- method := "GET"
- path := "/johnsmith/photos/puppy.jpg"
- headers := map[string][]string{
- "Host": {"johnsmith.s3.amazonaws.com"},
- "Date": {"Tue, 27 Mar 2007 19:36:42 +0000"},
- }
- s3.Sign(testAuth, method, path, nil, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:xXjDGYUmKxnwqr5KXNPGldn5LbA="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
-
-func (s *S) TestSignExampleObjectPut(c *C) {
- method := "PUT"
- path := "/johnsmith/photos/puppy.jpg"
- headers := map[string][]string{
- "Host": {"johnsmith.s3.amazonaws.com"},
- "Date": {"Tue, 27 Mar 2007 21:15:45 +0000"},
- "Content-Type": {"image/jpeg"},
- "Content-Length": {"94328"},
- }
- s3.Sign(testAuth, method, path, nil, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:hcicpDDvL9SsO6AkvxqmIWkmOuQ="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
-
-func (s *S) TestSignExampleList(c *C) {
- method := "GET"
- path := "/johnsmith/"
- params := map[string][]string{
- "prefix": {"photos"},
- "max-keys": {"50"},
- "marker": {"puppy"},
- }
- headers := map[string][]string{
- "Host": {"johnsmith.s3.amazonaws.com"},
- "Date": {"Tue, 27 Mar 2007 19:42:41 +0000"},
- "User-Agent": {"Mozilla/5.0"},
- }
- s3.Sign(testAuth, method, path, params, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:jsRt/rhG+Vtp88HrYL706QhE4w4="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
-
-func (s *S) TestSignExampleFetch(c *C) {
- method := "GET"
- path := "/johnsmith/"
- params := map[string][]string{
- "acl": {""},
- }
- headers := map[string][]string{
- "Host": {"johnsmith.s3.amazonaws.com"},
- "Date": {"Tue, 27 Mar 2007 19:44:46 +0000"},
- }
- s3.Sign(testAuth, method, path, params, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:thdUi9VAkzhkniLj96JIrOPGi0g="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
-
-func (s *S) TestSignExampleDelete(c *C) {
- method := "DELETE"
- path := "/johnsmith/photos/puppy.jpg"
- params := map[string][]string{}
- headers := map[string][]string{
- "Host": {"s3.amazonaws.com"},
- "Date": {"Tue, 27 Mar 2007 21:20:27 +0000"},
- "User-Agent": {"dotnet"},
- "x-amz-date": {"Tue, 27 Mar 2007 21:20:26 +0000"},
- }
- s3.Sign(testAuth, method, path, params, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:k3nL7gH3+PadhTEVn5Ip83xlYzk="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
-
-func (s *S) TestSignExampleUpload(c *C) {
- method := "PUT"
- path := "/static.johnsmith.net/db-backup.dat.gz"
- params := map[string][]string{}
- headers := map[string][]string{
- "Host": {"static.johnsmith.net:8080"},
- "Date": {"Tue, 27 Mar 2007 21:06:08 +0000"},
- "User-Agent": {"curl/7.15.5"},
- "x-amz-acl": {"public-read"},
- "content-type": {"application/x-download"},
- "Content-MD5": {"4gJE4saaMU4BqNR0kLY+lw=="},
- "X-Amz-Meta-ReviewedBy": {"joe@johnsmith.net,jane@johnsmith.net"},
- "X-Amz-Meta-FileChecksum": {"0x02661779"},
- "X-Amz-Meta-ChecksumAlgorithm": {"crc32"},
- "Content-Disposition": {"attachment; filename=database.dat"},
- "Content-Encoding": {"gzip"},
- "Content-Length": {"5913339"},
- }
- s3.Sign(testAuth, method, path, params, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:C0FlOtU8Ylb9KDTpZqYkZPX91iI="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
-
-func (s *S) TestSignExampleListAllMyBuckets(c *C) {
- method := "GET"
- path := "/"
- headers := map[string][]string{
- "Host": {"s3.amazonaws.com"},
- "Date": {"Wed, 28 Mar 2007 01:29:59 +0000"},
- }
- s3.Sign(testAuth, method, path, nil, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:Db+gepJSUbZKwpx1FR0DLtEYoZA="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
-
-func (s *S) TestSignExampleUnicodeKeys(c *C) {
- method := "GET"
- path := "/dictionary/fran%C3%A7ais/pr%c3%a9f%c3%a8re"
- headers := map[string][]string{
- "Host": {"s3.amazonaws.com"},
- "Date": {"Wed, 28 Mar 2007 01:49:49 +0000"},
- }
- s3.Sign(testAuth, method, path, nil, headers)
- expected := "AWS 0PN5J17HBGZHT7JJ3X82:dxhSBHoI6eVSPcXJqEghlUzZMnY="
- c.Assert(headers["Authorization"], DeepEquals, []string{expected})
-}
diff --git a/vendor/github.com/goamz/goamz/sqs/Makefile b/vendor/github.com/goamz/goamz/sqs/Makefile
deleted file mode 100644
index 1219acfb9..000000000
--- a/vendor/github.com/goamz/goamz/sqs/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-include $(GOROOT)/src/Make.inc
-
-TARG=launchpad.net/goamz/sqs
-
-GOFILES=\
- sqs.go\
-
-include $(GOROOT)/src/Make.pkg
-
-GOFMT=gofmt
-BADFMT=$(shell $(GOFMT) -l $(GOFILES) 2> /dev/null)
-
-gofmt: $(BADFMT)
- @for F in $(BADFMT); do $(GOFMT) -w $$F && echo $$F; done
-
-ifneq ($(BADFMT),)
-ifneq ($(MAKECMDGOALS), gofmt)
-#$(warning WARNING: make gofmt: $(BADFMT))
-endif
-endif
diff --git a/vendor/github.com/goamz/goamz/sqs/README.md b/vendor/github.com/goamz/goamz/sqs/README.md
deleted file mode 100644
index a283a4eec..000000000
--- a/vendor/github.com/goamz/goamz/sqs/README.md
+++ /dev/null
@@ -1,38 +0,0 @@
-Amazon Simple Queue Service API Client Written in Golang.
-=========================================================
-
-Merged from https://github.com/Mistobaan/sqs
-
-Installation
-------------
-
- go get github.com/goamz/goamz/sqs
-
-Documentation
--------------
-
-http://godoc.org/github.com/goamz/goamz/sqs
-
-
-Sample Usage
-------------
-
- var auth = aws.Auth{
- AccessKey: os.Getenv("AWS_ACCESS_KEY_ID"),
- SecretKey: os.Getenv("AWS_SECRET_ACCESS_KEY"),
- }
-
- conn := sqs.New(auth, aws.USEast)
-
- q, err := conn.CreateQueue(queueName)
- if err != nil {
- log.Fatalf(err.Error())
- }
-
- q.SendMessage(batch)
-
-
-Testing
--------
-
- go test .
diff --git a/vendor/github.com/goamz/goamz/sqs/responses_test.go b/vendor/github.com/goamz/goamz/sqs/responses_test.go
deleted file mode 100644
index 857fb9104..000000000
--- a/vendor/github.com/goamz/goamz/sqs/responses_test.go
+++ /dev/null
@@ -1,196 +0,0 @@
-package sqs
-
-var TestCreateQueueXmlOK = `
-<CreateQueueResponse>
- <CreateQueueResult>
- <QueueUrl>http://sqs.us-east-1.amazonaws.com/123456789012/testQueue</QueueUrl>
- </CreateQueueResult>
- <ResponseMetadata>
- <RequestId>7a62c49f-347e-4fc4-9331-6e8e7a96aa73</RequestId>
- </ResponseMetadata>
-</CreateQueueResponse>
-`
-
-var TestListQueuesXmlOK = `
-<ListQueuesResponse>
- <ListQueuesResult>
- <QueueUrl>http://sqs.us-east-1.amazonaws.com/123456789012/testQueue</QueueUrl>
- </ListQueuesResult>
- <ResponseMetadata>
- <RequestId>725275ae-0b9b-4762-b238-436d7c65a1ac</RequestId>
- </ResponseMetadata>
-</ListQueuesResponse>
-`
-
-var TestDeleteQueueXmlOK = `
-<DeleteQueueResponse>
- <ResponseMetadata>
- <RequestId>6fde8d1e-52cd-4581-8cd9-c512f4c64223</RequestId>
- </ResponseMetadata>
-</DeleteQueueResponse>
-`
-
-var TestPurgeQueueXmlOK = `
-<PurgeQueueResponse>
- <ResponseMetadata>
- <RequestId>6fde8d1e-52cd-4581-8cd9-c512f4c64223</RequestId>
- </ResponseMetadata>
-</PurgeQueueResponse>
-`
-
-var TestSendMessageXmlOK = `
-<SendMessageResponse>
- <SendMessageResult>
- <MD5OfMessageBody>fafb00f5732ab283681e124bf8747ed1</MD5OfMessageBody>
- <MessageId>5fea7756-0ea4-451a-a703-a558b933e274</MessageId>
- <MD5OfMessageAttributes>ba056227cfd9533dba1f72ad9816d233</MD5OfMessageAttributes>
- </SendMessageResult>
- <ResponseMetadata>
- <RequestId>27daac76-34dd-47df-bd01-1f6e873584a0</RequestId>
- </ResponseMetadata>
-</SendMessageResponse>
-`
-
-var TestSendMessageBatchXmlOk = `
-<SendMessageBatchResponse>
-<SendMessageBatchResult>
- <SendMessageBatchResultEntry>
- <Id>test_msg_001</Id>
- <MessageId>0a5231c7-8bff-4955-be2e-8dc7c50a25fa</MessageId>
- <MD5OfMessageBody>0e024d309850c78cba5eabbeff7cae71</MD5OfMessageBody>
- </SendMessageBatchResultEntry>
- <SendMessageBatchResultEntry>
- <Id>test_msg_002</Id>
- <MessageId>15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9</MessageId>
- <MD5OfMessageBody>7fb8146a82f95e0af155278f406862c2</MD5OfMessageBody>
- </SendMessageBatchResultEntry>
-</SendMessageBatchResult>
-<ResponseMetadata>
- <RequestId>ca1ad5d0-8271-408b-8d0f-1351bf547e74</RequestId>
-</ResponseMetadata>
-</SendMessageBatchResponse>
-`
-
-var TestReceiveMessageXmlOK = `
-<ReceiveMessageResponse>
- <ReceiveMessageResult>
- <Message>
- <MessageId>5fea7756-0ea4-451a-a703-a558b933e274</MessageId>
- <ReceiptHandle>MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+CwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0=</ReceiptHandle>
- <MD5OfBody>fafb00f5732ab283681e124bf8747ed1</MD5OfBody>
- <Body>This is a test message</Body>
- <Attribute>
- <Name>SenderId</Name>
- <Value>195004372649</Value>
- </Attribute>
- <Attribute>
- <Name>SentTimestamp</Name>
- <Value>1238099229000</Value>
- </Attribute>
- <Attribute>
- <Name>ApproximateReceiveCount</Name>
- <Value>5</Value>
- </Attribute>
- <Attribute>
- <Name>ApproximateFirstReceiveTimestamp</Name>
- <Value>1250700979248</Value>
- </Attribute>
- <MessageAttribute>
- <Name>CustomAttribute</Name>
- <Value>
- <DataType>String</DataType>
- <StringValue>Testing, testing, 1, 2, 3</StringValue>
- </Value>
- </MessageAttribute>
- <MessageAttribute>
- <Name>BinaryCustomAttribute</Name>
- <Value>
- <DataType>Binary</DataType>
- <BinaryValue>iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAABA0lEQVQ4T72UrQ4CMRCEewhyiiBPopBgcfAUSIICB88CDhRB8hTgsCBRyJMEdUFwZJpMs/3LHQlhVdPufJ1ut03UjyKJcR5zVc4umbW87eeqvVFBjTdJwP54D+4xGXVUCGiBxoOsJOCd9IKgRnnV8wAezrnRmwGcpKtCJ8UgJBNWLFNzVAOimyqIhElXGkQ3LmQ6fKrdqaW1cixhdKVBcEOBLEwViBugVv8B1elVuLYcoTea624drcl5LW4KTRsFhQpLtVzzQKGCh2DuHI8FvdVH7vGQKEPerHRjgegKMESsXgAgWBtu5D1a9BQWCXSrzx9BvjPPkRQR6IJcQNTRV/cvkj93DqUTWzVDIQAAAABJRU5ErkJggg==</BinaryValue>
- </Value>
- </MessageAttribute>
- </Message>
- </ReceiveMessageResult>
-<ResponseMetadata>
- <RequestId>b6633655-283d-45b4-aee4-4e84e0ae6afa</RequestId>
-</ResponseMetadata>
-</ReceiveMessageResponse>
-`
-
-var TestChangeMessageVisibilityXmlOK = `
-<ChangeMessageVisibilityResponse>
- <ResponseMetadata>
- <RequestId>6a7a282a-d013-4a59-aba9-335b0fa48bed</RequestId>
- </ResponseMetadata>
-</ChangeMessageVisibilityResponse>
-`
-
-var TestDeleteMessageBatchXmlOK = `
-<DeleteMessageBatchResponse>
- <DeleteMessageBatchResult>
- <DeleteMessageBatchResultEntry>
- <Id>msg1</Id>
- </DeleteMessageBatchResultEntry>
- <DeleteMessageBatchResultEntry>
- <Id>msg2</Id>
- </DeleteMessageBatchResultEntry>
- </DeleteMessageBatchResult>
- <ResponseMetadata>
- <RequestId>d6f86b7a-74d1-4439-b43f-196a1e29cd85</RequestId>
- </ResponseMetadata>
-</DeleteMessageBatchResponse>
-`
-
-var TestDeleteMessageUsingReceiptXmlOK = `
-<DeleteMessageResponse>
- <ResponseMetadata>
- <RequestId>d6d86b7a-74d1-4439-b43f-196a1e29cd85</RequestId>
- </ResponseMetadata>
-</DeleteMessageResponse>
-`
-
-var TestGetQueueAttributesXmlOK = `
-<GetQueueAttributesResponse>
- <GetQueueAttributesResult>
- <Attribute>
- <Name>ReceiveMessageWaitTimeSeconds</Name>
- <Value>2</Value>
- </Attribute>
- <Attribute>
- <Name>VisibilityTimeout</Name>
- <Value>30</Value>
- </Attribute>
- <Attribute>
- <Name>ApproximateNumberOfMessages</Name>
- <Value>0</Value>
- </Attribute>
- <Attribute>
- <Name>ApproximateNumberOfMessagesNotVisible</Name>
- <Value>0</Value>
- </Attribute>
- <Attribute>
- <Name>CreatedTimestamp</Name>
- <Value>1286771522</Value>
- </Attribute>
- <Attribute>
- <Name>LastModifiedTimestamp</Name>
- <Value>1286771522</Value>
- </Attribute>
- <Attribute>
- <Name>QueueArn</Name>
- <Value>arn:aws:sqs:us-east-1:123456789012:qfoo</Value>
- </Attribute>
- <Attribute>
- <Name>MaximumMessageSize</Name>
- <Value>8192</Value>
- </Attribute>
- <Attribute>
- <Name>MessageRetentionPeriod</Name>
- <Value>345600</Value>
- </Attribute>
- </GetQueueAttributesResult>
- <ResponseMetadata>
- <RequestId>1ea71be5-b5a2-4f9d-b85a-945d8d08cd0b</RequestId>
- </ResponseMetadata>
-</GetQueueAttributesResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/sqs/sqs.go b/vendor/github.com/goamz/goamz/sqs/sqs.go
deleted file mode 100644
index b54b698a8..000000000
--- a/vendor/github.com/goamz/goamz/sqs/sqs.go
+++ /dev/null
@@ -1,585 +0,0 @@
-//
-// gosqs - Go packages to interact with the Amazon SQS Web Services.
-//
-// depends on https://wiki.ubuntu.com/goamz
-//
-//
-// Written by Prudhvi Krishna Surapaneni <me@prudhvi.net>
-// Extended by Fabrizio Milo <mistobaan@gmail.com>
-//
-package sqs
-
-import (
- "encoding/xml"
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-const API_VERSION = "2012-11-05"
-
-const debug = false
-
-// The SQS type encapsulates operation with an SQS region.
-type SQS struct {
- aws.Auth
- aws.Region
- private byte // Reserve the right of using private data.
- transport *http.Transport
-}
-
-// NewFrom Create A new SQS Client given an access and secret Key
-// region must be one of "us.east, us.west, eu.west"
-func NewFrom(accessKey, secretKey, region string) (*SQS, error) {
-
- auth := aws.Auth{AccessKey: accessKey, SecretKey: secretKey}
- aws_region := aws.USEast
-
- switch region {
- case "us.east", "us.east.1":
- aws_region = aws.USEast
- case "us.east.2":
- aws_region = aws.USEast2
- case "us.west", "us.west.1":
- aws_region = aws.USWest
- case "us.west.2":
- aws_region = aws.USWest2
- case "eu.west":
- aws_region = aws.EUWest
- case "ap.southeast", "ap.southeast.1":
- aws_region = aws.APSoutheast
- case "ap.southeast.2":
- aws_region = aws.APSoutheast2
- case "ap.northeast", "ap.northeast.1":
- aws_region = aws.APNortheast
- case "ap.northeast.2":
- aws_region = aws.APNortheast2
- case "sa.east", "sa.east.1":
- aws_region = aws.SAEast
- case "cn.north", "cn.north.1":
- aws_region = aws.CNNorth
- default:
- return nil, errors.New(fmt.Sprintf("Unknown/Unsupported region %s", region))
- }
-
- aws_sqs := New(auth, aws_region)
- return aws_sqs, nil
-}
-
-// NewFrom Create A new SQS Client from an exisisting aws.Auth
-func New(auth aws.Auth, region aws.Region) *SQS {
- return &SQS{auth, region, 0, nil}
-}
-
-// NewFromTransport Create A new SQS Client that uses a given &http.Transport
-func NewFromTransport(auth aws.Auth, region aws.Region, transport *http.Transport) *SQS {
- return &SQS{auth, region, 0, transport}
-}
-
-// Queue Reference to a Queue
-type Queue struct {
- *SQS
- Url string
-}
-
-type CreateQueueResponse struct {
- QueueUrl string `xml:"CreateQueueResult>QueueUrl"`
- ResponseMetadata ResponseMetadata
-}
-
-type GetQueueUrlResponse struct {
- QueueUrl string `xml:"GetQueueUrlResult>QueueUrl"`
- ResponseMetadata ResponseMetadata
-}
-
-type ListQueuesResponse struct {
- QueueUrl []string `xml:"ListQueuesResult>QueueUrl"`
- ResponseMetadata ResponseMetadata
-}
-
-type DeleteMessageResponse struct {
- ResponseMetadata ResponseMetadata
-}
-
-type DeleteQueueResponse struct {
- ResponseMetadata ResponseMetadata
-}
-
-type PurgeQueueResponse struct {
- ResponseMetadata ResponseMetadata
-}
-
-type SendMessageResponse struct {
- MD5 string `xml:"SendMessageResult>MD5OfMessageBody"`
- MD5OfMessageAttributes string `xml:"SendMessageResult>MD5OfMessageAttributes"`
- Id string `xml:"SendMessageResult>MessageId"`
- ResponseMetadata ResponseMetadata
-}
-
-type ReceiveMessageResponse struct {
- Messages []Message `xml:"ReceiveMessageResult>Message"`
- ResponseMetadata ResponseMetadata
-}
-
-type Message struct {
- MessageId string `xml:"MessageId"`
- Body string `xml:"Body"`
- MD5OfBody string `xml:"MD5OfBody"`
- ReceiptHandle string `xml:"ReceiptHandle"`
- Attribute []Attribute `xml:"Attribute"`
- MessageAttribute []MessageAttribute `xml:"MessageAttribute"`
- MD5OfMessageAttributes string `xml:"MD5OfMessageAttributes"`
-}
-
-type Attribute struct {
- Name string `xml:"Name"`
- Value string `xml:"Value"`
-}
-
-type MessageAttribute struct {
- Name string `xml:"Name"`
- Value MessageAttributeValue `xml:"Value"`
-}
-
-type MessageAttributeValue struct {
- DataType string `xml:"DataType"`
- BinaryValue []byte `xml:"BinaryValue"`
- StringValue string `xml:"StringValue"`
-
- // Not yet implemented (Reserved for future use)
- BinaryListValues [][]byte `xml:"BinaryListValues"`
- StringListValues []string `xml:"StringListValues"`
-}
-
-type ChangeMessageVisibilityResponse struct {
- ResponseMetadata ResponseMetadata
-}
-
-type GetQueueAttributesResponse struct {
- Attributes []Attribute `xml:"GetQueueAttributesResult>Attribute"`
- ResponseMetadata ResponseMetadata
-}
-
-type ResponseMetadata struct {
- RequestId string
- BoxUsage float64
-}
-
-type Error struct {
- StatusCode int
- Code string
- Message string
- RequestId string
-}
-
-func (err *Error) Error() string {
- if err.Code == "" {
- return err.Message
- }
- return fmt.Sprintf("%s (%s)", err.Message, err.Code)
-}
-
-func (err *Error) String() string {
- return err.Message
-}
-
-type xmlErrors struct {
- RequestId string
- Errors []Error `xml:"Errors>Error"`
- Error Error
-}
-
-// CreateQueue create a queue with a specific name
-func (s *SQS) CreateQueue(queueName string) (*Queue, error) {
- return s.CreateQueueWithTimeout(queueName, 30)
-}
-
-// CreateQueue create a queue with a specific name and a timeout
-func (s *SQS) CreateQueueWithTimeout(queueName string, timeout int) (*Queue, error) {
- params := map[string]string{
- "VisibilityTimeout": strconv.Itoa(timeout),
- }
- return s.CreateQueueWithAttributes(queueName, params)
-}
-
-func (s *SQS) CreateQueueWithAttributes(queueName string, attrs map[string]string) (q *Queue, err error) {
- resp, err := s.newQueue(queueName, attrs)
- if err != nil {
- return nil, err
- }
- q = &Queue{s, resp.QueueUrl}
- return
-}
-
-// GetQueue get a reference to the given quename
-func (s *SQS) GetQueue(queueName string) (*Queue, error) {
- var q *Queue
- resp, err := s.getQueueUrl(queueName)
- if err != nil {
- return q, err
- }
- q = &Queue{s, resp.QueueUrl}
- return q, nil
-}
-
-func (s *SQS) QueueFromArn(queueUrl string) (q *Queue) {
- q = &Queue{s, queueUrl}
- return
-}
-
-func (s *SQS) getQueueUrl(queueName string) (resp *GetQueueUrlResponse, err error) {
- resp = &GetQueueUrlResponse{}
- params := makeParams("GetQueueUrl")
- params["QueueName"] = queueName
- err = s.query("", params, resp)
- return resp, err
-}
-
-func (s *SQS) newQueue(queueName string, attrs map[string]string) (resp *CreateQueueResponse, err error) {
- resp = &CreateQueueResponse{}
- params := makeParams("CreateQueue")
- params["QueueName"] = queueName
-
- i := 1
- for k, v := range attrs {
- nameParam := fmt.Sprintf("Attribute.%d.Name", i)
- valParam := fmt.Sprintf("Attribute.%d.Value", i)
- params[nameParam] = k
- params[valParam] = v
- i++
- }
-
- err = s.query("", params, resp)
- return
-}
-
-func (s *SQS) ListQueues(QueueNamePrefix string) (resp *ListQueuesResponse, err error) {
- resp = &ListQueuesResponse{}
- params := makeParams("ListQueues")
-
- if QueueNamePrefix != "" {
- params["QueueNamePrefix"] = QueueNamePrefix
- }
-
- err = s.query("", params, resp)
- return
-}
-
-func (q *Queue) Delete() (resp *DeleteQueueResponse, err error) {
- resp = &DeleteQueueResponse{}
- params := makeParams("DeleteQueue")
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-func (q *Queue) Purge() (resp *PurgeQueueResponse, err error) {
- resp = &PurgeQueueResponse{}
- params := makeParams("PurgeQueue")
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-func (q *Queue) SendMessageWithDelay(MessageBody string, DelaySeconds int64) (resp *SendMessageResponse, err error) {
- resp = &SendMessageResponse{}
- params := makeParams("SendMessage")
-
- params["MessageBody"] = MessageBody
- params["DelaySeconds"] = strconv.Itoa(int(DelaySeconds))
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-func (q *Queue) SendMessage(MessageBody string) (resp *SendMessageResponse, err error) {
- resp = &SendMessageResponse{}
- params := makeParams("SendMessage")
-
- params["MessageBody"] = MessageBody
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-func (q *Queue) SendMessageWithAttributes(MessageBody string, attrs map[string]string) (resp *SendMessageResponse, err error) {
- resp = &SendMessageResponse{}
- params := makeParams("SendMessage")
-
- params["MessageBody"] = MessageBody
-
- i := 1
- for k, v := range attrs {
- nameParam := fmt.Sprintf("MessageAttribute.%d.Name", i)
- valParam := fmt.Sprintf("MessageAttribute.%d.Value.StringValue", i)
- typeParam := fmt.Sprintf("MessageAttribute.%d.Value.DataType", i)
- params[nameParam] = k
- params[valParam] = v
- params[typeParam] = "String"
- i++
- }
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-// ReceiveMessageWithVisibilityTimeout
-func (q *Queue) ReceiveMessageWithVisibilityTimeout(MaxNumberOfMessages, VisibilityTimeoutSec int) (*ReceiveMessageResponse, error) {
- params := map[string]string{
- "MaxNumberOfMessages": strconv.Itoa(MaxNumberOfMessages),
- "VisibilityTimeout": strconv.Itoa(VisibilityTimeoutSec),
- }
- return q.ReceiveMessageWithParameters(params)
-}
-
-// ReceiveMessage
-func (q *Queue) ReceiveMessage(MaxNumberOfMessages int) (*ReceiveMessageResponse, error) {
- params := map[string]string{
- "MaxNumberOfMessages": strconv.Itoa(MaxNumberOfMessages),
- }
- return q.ReceiveMessageWithParameters(params)
-}
-
-func (q *Queue) ReceiveMessageWithParameters(p map[string]string) (resp *ReceiveMessageResponse, err error) {
- resp = &ReceiveMessageResponse{}
- params := makeParams("ReceiveMessage")
- params["AttributeName"] = "All"
- params["MessageAttributeNames"] = "All"
-
- for k, v := range p {
- params[k] = v
- }
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-func (q *Queue) ChangeMessageVisibility(M *Message, VisibilityTimeout int) (resp *ChangeMessageVisibilityResponse, err error) {
- resp = &ChangeMessageVisibilityResponse{}
- params := makeParams("ChangeMessageVisibility")
- params["VisibilityTimeout"] = strconv.Itoa(VisibilityTimeout)
- params["ReceiptHandle"] = M.ReceiptHandle
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-func (q *Queue) GetQueueAttributes(A string) (resp *GetQueueAttributesResponse, err error) {
- resp = &GetQueueAttributesResponse{}
- params := makeParams("GetQueueAttributes")
- params["AttributeName"] = A
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-func (q *Queue) DeleteMessage(M *Message) (resp *DeleteMessageResponse, err error) {
- return q.DeleteMessageUsingReceiptHandle(M.ReceiptHandle)
-}
-
-func (q *Queue) DeleteMessageUsingReceiptHandle(receiptHandle string) (resp *DeleteMessageResponse, err error) {
- resp = &DeleteMessageResponse{}
- params := makeParams("DeleteMessage")
- params["ReceiptHandle"] = receiptHandle
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-type SendMessageBatchResultEntry struct {
- Id string `xml:"Id"`
- MessageId string `xml:"MessageId"`
- MD5OfMessageBody string `xml:"MD5OfMessageBody"`
-}
-
-type SendMessageBatchResponse struct {
- SendMessageBatchResult []SendMessageBatchResultEntry `xml:"SendMessageBatchResult>SendMessageBatchResultEntry"`
- ResponseMetadata ResponseMetadata
-}
-
-/* SendMessageBatch
- */
-func (q *Queue) SendMessageBatch(msgList []Message) (resp *SendMessageBatchResponse, err error) {
- resp = &SendMessageBatchResponse{}
- params := makeParams("SendMessageBatch")
-
- for idx, msg := range msgList {
- count := idx + 1
- params[fmt.Sprintf("SendMessageBatchRequestEntry.%d.Id", count)] = fmt.Sprintf("msg-%d", count)
- params[fmt.Sprintf("SendMessageBatchRequestEntry.%d.MessageBody", count)] = msg.Body
- }
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-/* SendMessageBatchString
- */
-func (q *Queue) SendMessageBatchString(msgList []string) (resp *SendMessageBatchResponse, err error) {
- resp = &SendMessageBatchResponse{}
- params := makeParams("SendMessageBatch")
-
- for idx, msg := range msgList {
- count := idx + 1
- params[fmt.Sprintf("SendMessageBatchRequestEntry.%d.Id", count)] = fmt.Sprintf("msg-%d", count)
- params[fmt.Sprintf("SendMessageBatchRequestEntry.%d.MessageBody", count)] = msg
- }
-
- err = q.SQS.query(q.Url, params, resp)
- return
-}
-
-type DeleteMessageBatchResponse struct {
- DeleteMessageBatchResult []struct {
- Id string
- SenderFault bool
- Code string
- Message string
- } `xml:"DeleteMessageBatchResult>DeleteMessageBatchResultEntry"`
- ResponseMetadata ResponseMetadata
-}
-
-/* DeleteMessageBatch */
-func (q *Queue) DeleteMessageBatch(msgList []Message) (resp *DeleteMessageBatchResponse, err error) {
- resp = &DeleteMessageBatchResponse{}
- params := makeParams("DeleteMessageBatch")
-
- lutMsg := make(map[string]Message)
-
- for idx := range msgList {
- params[fmt.Sprintf("DeleteMessageBatchRequestEntry.%d.Id", idx+1)] = msgList[idx].MessageId
- params[fmt.Sprintf("DeleteMessageBatchRequestEntry.%d.ReceiptHandle", idx+1)] = msgList[idx].ReceiptHandle
-
- lutMsg[string(msgList[idx].MessageId)] = msgList[idx]
- }
-
- err = q.SQS.query(q.Url, params, resp)
-
- messageWithErrors := make([]Message, 0, len(msgList))
-
- for idx := range resp.DeleteMessageBatchResult {
- if resp.DeleteMessageBatchResult[idx].SenderFault {
- msg, ok := lutMsg[resp.DeleteMessageBatchResult[idx].Id]
- if ok {
- messageWithErrors = append(messageWithErrors, msg)
- }
- }
- }
-
- if len(messageWithErrors) > 0 {
- log.Printf("%d Message have not been sent", len(messageWithErrors))
- }
-
- return
-}
-
-func (s *SQS) query(queueUrl string, params map[string]string, resp interface{}) (err error) {
- params["Version"] = API_VERSION
- params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
- var url_ *url.URL
-
- switch {
- // fully qualified queueUrl
- case strings.HasPrefix(queueUrl, "http"):
- url_, err = url.Parse(queueUrl)
- // relative queueUrl
- case strings.HasPrefix(queueUrl, "/"):
- url_, err = url.Parse(s.Region.SQSEndpoint + queueUrl)
- // zero-value for queueUrl
- default:
- url_, err = url.Parse(s.Region.SQSEndpoint)
- }
-
- if err != nil {
- return err
- }
-
- if s.Auth.Token() != "" {
- params["SecurityToken"] = s.Auth.Token()
- }
-
- var r *http.Response
-
- var sarray []string
- for k, v := range params {
- sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v))
- }
-
- req, err := http.NewRequest("GET", fmt.Sprintf("%s?%s", url_, strings.Join(sarray, "&")), nil)
- if err != nil {
- return err
- }
- signer := aws.NewV4Signer(s.Auth, "sqs", s.Region)
- signer.Sign(req)
- var client http.Client
- if s.transport == nil {
- client = http.Client{}
- } else {
- client = http.Client{Transport: s.transport}
- }
- r, err = client.Do(req)
-
- if debug {
- log.Printf("GET %s\n", url_.String())
- }
-
- if err != nil {
- return err
- }
-
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("DUMP:%s\n", string(dump))
- }
-
- if r.StatusCode != 200 {
- return buildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- io.Copy(ioutil.Discard, r.Body)
-
- return err
-}
-
-func buildError(r *http.Response) error {
- errors := xmlErrors{}
- xml.NewDecoder(r.Body).Decode(&errors)
- var err Error
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- } else {
- err = errors.Error
- }
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func makeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
diff --git a/vendor/github.com/goamz/goamz/sqs/sqs_test.go b/vendor/github.com/goamz/goamz/sqs/sqs_test.go
deleted file mode 100644
index a06433535..000000000
--- a/vendor/github.com/goamz/goamz/sqs/sqs_test.go
+++ /dev/null
@@ -1,414 +0,0 @@
-package sqs
-
-import (
- "crypto/md5"
- "encoding/binary"
- "fmt"
- "hash"
-
- "github.com/goamz/goamz/aws"
- . "gopkg.in/check.v1"
-)
-
-var _ = Suite(&S{})
-
-type S struct {
- HTTPSuite
- sqs *SQS
-}
-
-func (s *S) SetUpSuite(c *C) {
- s.HTTPSuite.SetUpSuite(c)
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.sqs = New(auth, aws.Region{SQSEndpoint: testServer.URL})
-}
-
-func (s *S) TestCreateQueue(c *C) {
- testServer.PrepareResponse(200, nil, TestCreateQueueXmlOK)
-
- resp, err := s.sqs.CreateQueue("testQueue")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
- fmt.Printf("%+v\n", req)
- c.Assert(req.Form["Action"], DeepEquals, []string{"CreateQueue"})
- c.Assert(req.Form["Attribute.1.Name"], DeepEquals, []string{"VisibilityTimeout"})
- c.Assert(req.Form["Attribute.1.Value"], DeepEquals, []string{"30"})
-
- c.Assert(resp.Url, Equals, "http://sqs.us-east-1.amazonaws.com/123456789012/testQueue")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestCreateQueueWithTimeout(c *C) {
- testServer.PrepareResponse(200, nil, TestCreateQueueXmlOK)
-
- s.sqs.CreateQueueWithTimeout("testQueue", 180)
- req := testServer.WaitRequest()
-
- // TestCreateQueue() tests the core functionality, just check the timeout in this test
- c.Assert(req.Form["Attribute.1.Name"], DeepEquals, []string{"VisibilityTimeout"})
- c.Assert(req.Form["Attribute.1.Value"], DeepEquals, []string{"180"})
-}
-
-func (s *S) TestCreateQueueWithAttributes(c *C) {
- testServer.PrepareResponse(200, nil, TestCreateQueueXmlOK)
-
- s.sqs.CreateQueueWithAttributes("testQueue", map[string]string{
- "ReceiveMessageWaitTimeSeconds": "20",
- "VisibilityTimeout": "240",
- })
- req := testServer.WaitRequest()
-
- // TestCreateQueue() tests the core functionality, just check the timeout in this test
- var receiveMessageWaitSet bool
- var visibilityTimeoutSet bool
-
- for i := 1; i <= 2; i++ {
- prefix := fmt.Sprintf("Attribute.%d.", i)
- attr := req.FormValue(prefix + "Name")
- value := req.FormValue(prefix + "Value")
- switch attr {
- case "ReceiveMessageWaitTimeSeconds":
- c.Assert(value, DeepEquals, "20")
- receiveMessageWaitSet = true
- case "VisibilityTimeout":
- c.Assert(value, DeepEquals, "240")
- visibilityTimeoutSet = true
- }
- }
- c.Assert(receiveMessageWaitSet, Equals, true)
- c.Assert(visibilityTimeoutSet, Equals, true)
-}
-
-func (s *S) TestListQueues(c *C) {
- testServer.PrepareResponse(200, nil, TestListQueuesXmlOK)
-
- resp, err := s.sqs.ListQueues("")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.QueueUrl), Not(Equals), 0)
- c.Assert(resp.QueueUrl[0], Equals, "http://sqs.us-east-1.amazonaws.com/123456789012/testQueue")
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "725275ae-0b9b-4762-b238-436d7c65a1ac")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestDeleteQueue(c *C) {
- testServer.PrepareResponse(200, nil, TestDeleteQueueXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
- resp, err := q.Delete()
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "6fde8d1e-52cd-4581-8cd9-c512f4c64223")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestPurgeQueue(c *C) {
- testServer.PrepareResponse(200, nil, TestPurgeQueueXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
- resp, err := q.Purge()
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "6fde8d1e-52cd-4581-8cd9-c512f4c64223")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSendMessage(c *C) {
- testServer.PrepareResponse(200, nil, TestSendMessageXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
- resp, err := q.SendMessage("This is a test message")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- msg := "This is a test message"
- var h hash.Hash = md5.New()
- h.Write([]byte(msg))
- c.Assert(resp.MD5, Equals, fmt.Sprintf("%x", h.Sum(nil)))
- c.Assert(resp.Id, Equals, "5fea7756-0ea4-451a-a703-a558b933e274")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSendMessageRelativePath(c *C) {
- testServer.PrepareResponse(200, nil, TestSendMessageXmlOK)
-
- q := &Queue{s.sqs, "/123456789012/testQueue/"}
- resp, err := q.SendMessage("This is a test message")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- msg := "This is a test message"
- var h hash.Hash = md5.New()
- h.Write([]byte(msg))
- c.Assert(resp.MD5, Equals, fmt.Sprintf("%x", h.Sum(nil)))
- c.Assert(resp.Id, Equals, "5fea7756-0ea4-451a-a703-a558b933e274")
- c.Assert(err, IsNil)
-}
-
-func encodeMessageAttribute(str string) []byte {
- bstr := []byte(str)
- bs := make([]byte, 4+len(bstr))
- binary.BigEndian.PutUint32(bs, uint32(len(bstr)))
- copy(bs[4:len(bs)], bstr)
- return bs
-}
-
-func (s *S) TestSendMessageWithAttributes(c *C) {
- testServer.PrepareResponse(200, nil, TestSendMessageXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
- attrs := map[string]string{
- "test_attribute_name_1": "test_attribute_value_1",
- }
- resp, err := q.SendMessageWithAttributes("This is a test message", attrs)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- var attrsHash = md5.New()
- attrsHash.Write(encodeMessageAttribute("test_attribute_name_1"))
- attrsHash.Write(encodeMessageAttribute("String"))
- attrsHash.Write([]byte{1})
- attrsHash.Write(encodeMessageAttribute("test_attribute_value_1"))
- c.Assert(resp.MD5OfMessageAttributes, Equals, fmt.Sprintf("%x", attrsHash.Sum(nil)))
-
- msg := "This is a test message"
- var h hash.Hash = md5.New()
- h.Write([]byte(msg))
- c.Assert(resp.MD5, Equals, fmt.Sprintf("%x", h.Sum(nil)))
- c.Assert(resp.Id, Equals, "5fea7756-0ea4-451a-a703-a558b933e274")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestSendMessageBatch(c *C) {
- testServer.PrepareResponse(200, nil, TestSendMessageBatchXmlOk)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
-
- msgList := []string{"test message body 1", "test message body 2"}
- resp, err := q.SendMessageBatchString(msgList)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- for idx, msg := range msgList {
- var h hash.Hash = md5.New()
- h.Write([]byte(msg))
- c.Assert(resp.SendMessageBatchResult[idx].MD5OfMessageBody, Equals, fmt.Sprintf("%x", h.Sum(nil)))
- c.Assert(err, IsNil)
- }
-}
-
-func (s *S) TestDeleteMessageBatch(c *C) {
- testServer.PrepareResponse(200, nil, TestDeleteMessageBatchXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
-
- msgList := []Message{*(&Message{ReceiptHandle: "gfk0T0R0waama4fVFffkjPQrrvzMrOg0fTFk2LxT33EuB8wR0ZCFgKWyXGWFoqqpCIiprQUEhir%2F5LeGPpYTLzjqLQxyQYaQALeSNHb0us3uE84uujxpBhsDkZUQkjFFkNqBXn48xlMcVhTcI3YLH%2Bd%2BIqetIOHgBCZAPx6r%2B09dWaBXei6nbK5Ygih21DCDdAwFV68Jo8DXhb3ErEfoDqx7vyvC5nCpdwqv%2BJhU%2FTNGjNN8t51v5c%2FAXvQsAzyZVNapxUrHIt4NxRhKJ72uICcxruyE8eRXlxIVNgeNP8ZEDcw7zZU1Zw%3D%3D"}),
- *(&Message{ReceiptHandle: "gfk0T0R0waama4fVFffkjKzmhMCymjQvfTFk2LxT33G4ms5subrE0deLKWSscPU1oD3J9zgeS4PQQ3U30qOumIE6AdAv3w%2F%2Fa1IXW6AqaWhGsEPaLm3Vf6IiWqdM8u5imB%2BNTwj3tQRzOWdTOePjOjPcTpRxBtXix%2BEvwJOZUma9wabv%2BSw6ZHjwmNcVDx8dZXJhVp16Bksiox%2FGrUvrVTCJRTWTLc59oHLLF8sEkKzRmGNzTDGTiV%2BYjHfQj60FD3rVaXmzTsoNxRhKJ72uIHVMGVQiAGgB%2BqAbSqfKHDQtVOmJJgkHug%3D%3D"}),
- }
-
- resp, err := q.DeleteMessageBatch(msgList)
- c.Assert(err, IsNil)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- for idx, _ := range msgList {
- c.Assert(resp.DeleteMessageBatchResult[idx].Id, Equals, fmt.Sprintf("msg%d", idx+1))
- }
-}
-
-func (s *S) TestDeleteMessageUsingReceiptHandle(c *C) {
- testServer.PrepareResponse(200, nil, TestDeleteMessageUsingReceiptXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
-
- msg := &Message{ReceiptHandle: "gfk0T0R0waama4fVFffkjRQrrvzMrOg0fTFk2LxT33EuB8wR0ZCFgKWyXGWFoqqpCIiprQUEhir%2F5LeGPpYTLzjqLQxyQYaQALeSNHb0us3uE84uujxpBhsDkZUQkjFFkNqBXn48xlMcVhTcI3YLH%2Bd%2BIqetIOHgBCZAPx6r%2B09dWaBXei6nbK5Ygih21DCDdAwFV68Jo8DXhb3ErEfoDqx7vyvC5nCpdwqv%2BJhU%2FTNGjNN8t51v5c%2FAXvQsAzyZVNapxUrHIt4NxRhKJ72uICcxruyE8eRXlxIVNgeNP8ZEDcw7zZU1Zw%3D%3D"}
-
- resp, err := q.DeleteMessageUsingReceiptHandle(msg.ReceiptHandle)
- c.Assert(err, IsNil)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "d6d86b7a-74d1-4439-b43f-196a1e29cd85")
-}
-
-func (s *S) TestReceiveMessage(c *C) {
- testServer.PrepareResponse(200, nil, TestReceiveMessageXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
- resp, err := q.ReceiveMessage(5)
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(len(resp.Messages), Not(Equals), 0)
- c.Assert(resp.Messages[0].MessageId, Equals, "5fea7756-0ea4-451a-a703-a558b933e274")
- c.Assert(resp.Messages[0].MD5OfBody, Equals, "fafb00f5732ab283681e124bf8747ed1")
- c.Assert(resp.Messages[0].ReceiptHandle, Equals, "MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+CwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0=")
- c.Assert(resp.Messages[0].Body, Equals, "This is a test message")
-
- c.Assert(len(resp.Messages[0].Attribute), Not(Equals), 0)
-
- expectedAttributeResults := []struct {
- Name string
- Value string
- }{
- {Name: "SenderId", Value: "195004372649"},
- {Name: "SentTimestamp", Value: "1238099229000"},
- {Name: "ApproximateReceiveCount", Value: "5"},
- {Name: "ApproximateFirstReceiveTimestamp", Value: "1250700979248"},
- }
-
- for i, expected := range expectedAttributeResults {
- c.Assert(resp.Messages[0].Attribute[i].Name, Equals, expected.Name)
- c.Assert(resp.Messages[0].Attribute[i].Value, Equals, expected.Value)
- }
-
- c.Assert(len(resp.Messages[0].MessageAttribute), Not(Equals), 0)
-
- expectedMessageAttributeResults := []struct {
- Name string
- Value struct {
- DataType string
- BinaryValue []byte
- StringValue string
-
- // Not yet implemented (Reserved for future use)
- BinaryListValues [][]byte
- StringListValues []string
- }
- }{
- {
- Name: "CustomAttribute",
- Value: struct {
- DataType string
- BinaryValue []byte
- StringValue string
-
- // Not yet implemented (Reserved for future use)
- BinaryListValues [][]byte
- StringListValues []string
- }{
- DataType: "String",
- StringValue: "Testing, testing, 1, 2, 3",
- },
- },
- {
- Name: "BinaryCustomAttribute",
- Value: struct {
- DataType string
- BinaryValue []byte
- StringValue string
-
- // Not yet implemented (Reserved for future use)
- BinaryListValues [][]byte
- StringListValues []string
- }{
- DataType: "Binary",
- BinaryValue: []byte("iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAABA0lEQVQ4T72UrQ4CMRCEewhyiiBPopBgcfAUSIICB88CDhRB8hTgsCBRyJMEdUFwZJpMs/3LHQlhVdPufJ1ut03UjyKJcR5zVc4umbW87eeqvVFBjTdJwP54D+4xGXVUCGiBxoOsJOCd9IKgRnnV8wAezrnRmwGcpKtCJ8UgJBNWLFNzVAOimyqIhElXGkQ3LmQ6fKrdqaW1cixhdKVBcEOBLEwViBugVv8B1elVuLYcoTea624drcl5LW4KTRsFhQpLtVzzQKGCh2DuHI8FvdVH7vGQKEPerHRjgegKMESsXgAgWBtu5D1a9BQWCXSrzx9BvjPPkRQR6IJcQNTRV/cvkj93DqUTWzVDIQAAAABJRU5ErkJggg=="),
- },
- },
- }
-
- for i, expected := range expectedMessageAttributeResults {
- c.Assert(resp.Messages[0].MessageAttribute[i].Name, Equals, expected.Name)
- c.Assert(resp.Messages[0].MessageAttribute[i].Value.DataType, Equals, expected.Value.DataType)
- c.Assert(string(resp.Messages[0].MessageAttribute[i].Value.BinaryValue), Equals, string(expected.Value.BinaryValue))
- c.Assert(resp.Messages[0].MessageAttribute[i].Value.StringValue, Equals, expected.Value.StringValue)
- }
-
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestChangeMessageVisibility(c *C) {
- testServer.PrepareResponse(200, nil, TestReceiveMessageXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
-
- resp1, err := q.ReceiveMessage(1)
- req := testServer.WaitRequest()
-
- testServer.PrepareResponse(200, nil, TestChangeMessageVisibilityXmlOK)
-
- resp, err := q.ChangeMessageVisibility(&resp1.Messages[0], 50)
- req = testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
- c.Assert(req.Header["Date"], Not(Equals), "")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "6a7a282a-d013-4a59-aba9-335b0fa48bed")
- c.Assert(err, IsNil)
-}
-
-func (s *S) TestGetQueueAttributes(c *C) {
- testServer.PrepareResponse(200, nil, TestGetQueueAttributesXmlOK)
-
- q := &Queue{s.sqs, testServer.URL + "/123456789012/testQueue/"}
-
- resp, err := q.GetQueueAttributes("All")
- req := testServer.WaitRequest()
-
- c.Assert(req.Method, Equals, "GET")
- c.Assert(req.URL.Path, Equals, "/123456789012/testQueue/")
-
- c.Assert(resp.ResponseMetadata.RequestId, Equals, "1ea71be5-b5a2-4f9d-b85a-945d8d08cd0b")
-
- c.Assert(len(resp.Attributes), Equals, 9)
-
- expectedResults := []struct {
- Name string
- Value string
- }{
- {Name: "ReceiveMessageWaitTimeSeconds", Value: "2"},
- {Name: "VisibilityTimeout", Value: "30"},
- {Name: "ApproximateNumberOfMessages", Value: "0"},
- {Name: "ApproximateNumberOfMessagesNotVisible", Value: "0"},
- {Name: "CreatedTimestamp", Value: "1286771522"},
- {Name: "LastModifiedTimestamp", Value: "1286771522"},
- {Name: "QueueArn", Value: "arn:aws:sqs:us-east-1:123456789012:qfoo"},
- {Name: "MaximumMessageSize", Value: "8192"},
- {Name: "MessageRetentionPeriod", Value: "345600"},
- }
-
- for i, expected := range expectedResults {
- c.Assert(resp.Attributes[i].Name, Equals, expected.Name)
- c.Assert(resp.Attributes[i].Value, Equals, expected.Value)
- }
-
- c.Assert(err, IsNil)
-}
diff --git a/vendor/github.com/goamz/goamz/sqs/suite_test.go b/vendor/github.com/goamz/goamz/sqs/suite_test.go
deleted file mode 100644
index 8de1bc04f..000000000
--- a/vendor/github.com/goamz/goamz/sqs/suite_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-package sqs
-
-import (
- "flag"
- "fmt"
- "net/http"
- "net/url"
- "os"
- "testing"
- "time"
-
- "github.com/goamz/goamz/aws"
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var integration = flag.Bool("i", false, "Enable integration tests")
-
-type SuiteI struct {
- auth aws.Auth
-}
-
-func (s *SuiteI) SetUpSuite(c *C) {
- if !*integration {
- c.Skip("Integration tests not enabled (-i flag)")
- }
- auth, err := aws.EnvAuth()
- if err != nil {
- c.Fatal(err.Error())
- }
- s.auth = auth
-}
-
-type HTTPSuite struct{}
-
-var testServer = NewTestHTTPServer("http://localhost:4455", 5e9)
-
-func (s *HTTPSuite) SetUpSuite(c *C) {
- testServer.Start()
-}
-
-func (s *HTTPSuite) TearDownTest(c *C) {
- testServer.FlushRequests()
-}
-
-type TestHTTPServer struct {
- URL string
- Timeout time.Duration
- started bool
- request chan *http.Request
- response chan *testResponse
- pending chan bool
-}
-
-type testResponse struct {
- Status int
- Headers map[string]string
- Body string
-}
-
-func NewTestHTTPServer(url string, timeout time.Duration) *TestHTTPServer {
- return &TestHTTPServer{URL: url, Timeout: timeout}
-}
-
-func (s *TestHTTPServer) Start() {
- if s.started {
- return
- }
- s.started = true
-
- s.request = make(chan *http.Request, 64)
- s.response = make(chan *testResponse, 64)
- s.pending = make(chan bool, 64)
-
- url, _ := url.Parse(s.URL)
- go func() {
- err := http.ListenAndServe(url.Host, s)
- if err != nil {
- panic(err)
- }
- }()
-
- s.PrepareResponse(202, nil, "Nothing.")
- for {
- // Wait for it to be up.
- resp, err := http.Get(s.URL)
- if err == nil && resp.StatusCode == 202 {
- break
- }
- fmt.Fprintf(os.Stderr, "\nWaiting for fake server to be up... ")
- time.Sleep(1e8)
- }
- fmt.Fprintf(os.Stderr, "done\n\n")
- s.WaitRequest() // Consume dummy request.
-}
-
-// FlushRequests discards requests which were not yet consumed by WaitRequest.
-func (s *TestHTTPServer) FlushRequests() {
- for {
- select {
- case <-s.request:
- default:
- return
- }
- }
-}
-
-func (s *TestHTTPServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
- s.request <- req
- var resp *testResponse
- select {
- case resp = <-s.response:
- case <-time.After(s.Timeout):
- fmt.Fprintf(os.Stderr, "ERROR: Timeout waiting for test to provide response\n")
- resp = &testResponse{500, nil, ""}
- }
- if resp.Headers != nil {
- h := w.Header()
- for k, v := range resp.Headers {
- h.Set(k, v)
- }
- }
- if resp.Status != 0 {
- w.WriteHeader(resp.Status)
- }
- w.Write([]byte(resp.Body))
-}
-
-func (s *TestHTTPServer) WaitRequest() *http.Request {
- select {
- case req := <-s.request:
- req.ParseForm()
- return req
- case <-time.After(s.Timeout):
- panic("Timeout waiting for goamz request")
- }
- panic("unreached")
-}
-
-func (s *TestHTTPServer) PrepareResponse(status int, headers map[string]string, body string) {
- s.response <- &testResponse{status, headers, body}
-}
diff --git a/vendor/github.com/goamz/goamz/sts/responses_test.go b/vendor/github.com/goamz/goamz/sts/responses_test.go
deleted file mode 100644
index b25f495e2..000000000
--- a/vendor/github.com/goamz/goamz/sts/responses_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package sts_test
-
-var AssumeRoleResponse = `
-<AssumeRoleResponse xmlns="https://sts.amazonaws.com/doc/
-2011-06-15/">
- <AssumeRoleResult>
- <Credentials>
- <SessionToken>
- AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQW
- LWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGd
- QrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU
- 9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz
- +scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==
- </SessionToken>
- <SecretAccessKey>
- wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
- </SecretAccessKey>
- <Expiration>2011-07-15T23:28:33.359Z</Expiration>
- <AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId>
- </Credentials>
- <AssumedRoleUser>
- <Arn>arn:aws:sts::123456789012:assumed-role/demo/Bob</Arn>
- <AssumedRoleId>ARO123EXAMPLE123:Bob</AssumedRoleId>
- </AssumedRoleUser>
- <PackedPolicySize>6</PackedPolicySize>
- </AssumeRoleResult>
- <ResponseMetadata>
- <RequestId>c6104cbe-af31-11e0-8154-cbc7ccf896c7</RequestId>
- </ResponseMetadata>
-</AssumeRoleResponse>
-`
-
-var GetFederationTokenResponse = `
-<GetFederationTokenResponse xmlns="https://sts.amazonaws.com/doc/
-2011-06-15/">
- <GetFederationTokenResult>
- <Credentials>
- <SessionToken>
- AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQW
- LWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGd
- QrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU
- 9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz
- +scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==
- </SessionToken>
- <SecretAccessKey>
- wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
- </SecretAccessKey>
- <Expiration>2011-07-15T23:28:33.359Z</Expiration>
- <AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId>
- </Credentials>
- <FederatedUser>
- <Arn>arn:aws:sts::123456789012:federated-user/Bob</Arn>
- <FederatedUserId>123456789012:Bob</FederatedUserId>
- </FederatedUser>
- <PackedPolicySize>6</PackedPolicySize>
- </GetFederationTokenResult>
- <ResponseMetadata>
- <RequestId>c6104cbe-af31-11e0-8154-cbc7ccf896c7</RequestId>
- </ResponseMetadata>
-</GetFederationTokenResponse>
-`
-
-var GetSessionTokenResponse = `
-<GetSessionTokenResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
- <GetSessionTokenResult>
- <Credentials>
- <SessionToken>
- AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/L
- To6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3z
- rkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtp
- Z3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE
- </SessionToken>
- <SecretAccessKey>
- wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
- </SecretAccessKey>
- <Expiration>2011-07-11T19:55:29.611Z</Expiration>
- <AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId>
- </Credentials>
- </GetSessionTokenResult>
- <ResponseMetadata>
- <RequestId>58c5dbae-abef-11e0-8cfe-09039844ac7d</RequestId>
- </ResponseMetadata>
-</GetSessionTokenResponse>
-`
diff --git a/vendor/github.com/goamz/goamz/sts/sts.go b/vendor/github.com/goamz/goamz/sts/sts.go
deleted file mode 100644
index 973969223..000000000
--- a/vendor/github.com/goamz/goamz/sts/sts.go
+++ /dev/null
@@ -1,273 +0,0 @@
-//
-// sts: This package provides types and functions to interact with the AWS STS API
-//
-// Depends on https://github.com/goamz/goamz
-//
-
-package sts
-
-import (
- "encoding/xml"
- "fmt"
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "strconv"
- "strings"
- "time"
-
- "github.com/goamz/goamz/aws"
-)
-
-// The STS type encapsulates operations within a specific EC2 region.
-type STS struct {
- aws.Auth
- aws.Region
- private byte // Reserve the right of using private data.
-}
-
-// New creates a new STS Client.
-// We can only use us-east for region because AWS..
-func New(auth aws.Auth, region aws.Region) *STS {
- // Make sure we can run the package tests
- if region.Name == "" {
- return &STS{auth, region, 0}
- }
- return &STS{auth, aws.Regions["us-east-1"], 0}
-}
-
-const debug = false
-
-// ----------------------------------------------------------------------------
-// Request dispatching logic.
-
-// Error encapsulates an error returned by the AWS STS API.
-//
-// See http://goo.gl/zDZbuQ for more details.
-type Error struct {
- // HTTP status code (200, 403, ...)
- StatusCode int
- // STS error code
- Code string
- // The human-oriented error message
- Message string
- RequestId string `xml:"RequestID"`
-}
-
-func (err *Error) Error() string {
- if err.Code == "" {
- return err.Message
- }
-
- return fmt.Sprintf("%s (%s)", err.Message, err.Code)
-}
-
-type xmlErrors struct {
- RequestId string `xml:"RequestId"`
- Errors []Error `xml:"Error"`
-}
-
-func (sts *STS) query(params map[string]string, resp interface{}) error {
- params["Version"] = "2011-06-15"
-
- data := strings.NewReader(multimap(params).Encode())
-
- hreq, err := http.NewRequest("POST", sts.Region.STSEndpoint+"/", data)
- if err != nil {
- return err
- }
-
- hreq.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
-
- token := sts.Auth.Token()
- if token != "" {
- hreq.Header.Set("X-Amz-Security-Token", token)
- }
-
- signer := aws.NewV4Signer(sts.Auth, "sts", sts.Region)
- signer.Sign(hreq)
-
- if debug {
- log.Printf("%v -> {\n", hreq)
- }
- r, err := http.DefaultClient.Do(hreq)
-
- if err != nil {
- log.Printf("Error calling Amazon")
- return err
- }
-
- defer r.Body.Close()
-
- if debug {
- dump, _ := httputil.DumpResponse(r, true)
- log.Printf("response:\n")
- log.Printf("%v\n}\n", string(dump))
- }
- if r.StatusCode != 200 {
- return buildError(r)
- }
- err = xml.NewDecoder(r.Body).Decode(resp)
- return err
-}
-
-func buildError(r *http.Response) error {
- var (
- err Error
- errors xmlErrors
- )
- xml.NewDecoder(r.Body).Decode(&errors)
- if len(errors.Errors) > 0 {
- err = errors.Errors[0]
- }
-
- err.RequestId = errors.RequestId
- err.StatusCode = r.StatusCode
- if err.Message == "" {
- err.Message = r.Status
- }
- return &err
-}
-
-func makeParams(action string) map[string]string {
- params := make(map[string]string)
- params["Action"] = action
- return params
-}
-
-func multimap(p map[string]string) url.Values {
- q := make(url.Values, len(p))
- for k, v := range p {
- q[k] = []string{v}
- }
- return q
-}
-
-// options for the AssumeRole function
-//
-// See http://goo.gl/Ld6Dbk for details
-type AssumeRoleParams struct {
- DurationSeconds int
- ExternalId string
- Policy string
- RoleArn string
- RoleSessionName string
-}
-
-type AssumedRoleUser struct {
- Arn string `xml:"Arn"`
- AssumedRoleId string `xml:"AssumedRoleId"`
-}
-
-type Credentials struct {
- AccessKeyId string `xml:"AccessKeyId"`
- Expiration time.Time `xml:"Expiration"`
- SecretAccessKey string `xml:"SecretAccessKey"`
- SessionToken string `xml:"SessionToken"`
-}
-
-type AssumeRoleResult struct {
- AssumedRoleUser AssumedRoleUser `xml:"AssumeRoleResult>AssumedRoleUser"`
- Credentials Credentials `xml:"AssumeRoleResult>Credentials"`
- PackedPolicySize int `xml:"AssumeRoleResult>PackedPolicySize"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// AssumeRole assumes the specified role
-//
-// See http://goo.gl/zDZbuQ for more details.
-func (sts *STS) AssumeRole(options *AssumeRoleParams) (resp *AssumeRoleResult, err error) {
- params := makeParams("AssumeRole")
-
- params["RoleArn"] = options.RoleArn
- params["RoleSessionName"] = options.RoleSessionName
-
- if options.DurationSeconds != 0 {
- params["DurationSeconds"] = strconv.Itoa(options.DurationSeconds)
- }
- if options.ExternalId != "" {
- params["ExternalId"] = options.ExternalId
- }
- if options.Policy != "" {
- params["Policy"] = options.Policy
- }
-
- resp = new(AssumeRoleResult)
- if err := sts.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// FederatedUser presents dentifiers for the federated user that is associated with the credentials.
-//
-// See http://goo.gl/uPtr7V for more details
-type FederatedUser struct {
- Arn string `xml:"Arn"`
- FederatedUserId string `xml:"FederatedUserId"`
-}
-
-// GetFederationToken wraps GetFederationToken response
-//
-// See http://goo.gl/Iujjeg for more details
-type GetFederationTokenResult struct {
- Credentials Credentials `xml:"GetFederationTokenResult>Credentials"`
- FederatedUser FederatedUser `xml:"GetFederationTokenResult>FederatedUser"`
- PackedPolicySize int `xml:"GetFederationTokenResult>PackedPolicySize"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// GetFederationToken returns a set of temporary credentials for an AWS account or IAM user
-//
-// See http://goo.gl/Iujjeg for more details
-func (sts *STS) GetFederationToken(name, policy string, durationSeconds int) (
- resp *GetFederationTokenResult, err error) {
- params := makeParams("GetFederationToken")
- params["Name"] = name
-
- if durationSeconds != 0 {
- params["DurationSeconds"] = strconv.Itoa(durationSeconds)
- }
- if policy != "" {
- params["Policy"] = policy
- }
-
- resp = new(GetFederationTokenResult)
- if err := sts.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// GetSessionToken wraps GetSessionToken response
-//
-// See http://goo.gl/v8s5Y for more details
-type GetSessionTokenResult struct {
- Credentials Credentials `xml:"GetSessionTokenResult>Credentials"`
- RequestId string `xml:"ResponseMetadata>RequestId"`
-}
-
-// GetSessionToken returns a set of temporary credentials for an AWS account or IAM user
-//
-// See http://goo.gl/v8s5Y for more details
-func (sts *STS) GetSessionToken(durationSeconds int, serialnNumber, tokenCode string) (
- resp *GetSessionTokenResult, err error) {
- params := makeParams("GetSessionToken")
-
- if durationSeconds != 0 {
- params["DurationSeconds"] = strconv.Itoa(durationSeconds)
- }
- if serialnNumber != "" {
- params["SerialNumber"] = serialnNumber
- }
- if tokenCode != "" {
- params["TokenCode"] = tokenCode
- }
-
- resp = new(GetSessionTokenResult)
- if err := sts.query(params, resp); err != nil {
- return nil, err
- }
- return resp, nil
-}
diff --git a/vendor/github.com/goamz/goamz/sts/sts_test.go b/vendor/github.com/goamz/goamz/sts/sts_test.go
deleted file mode 100644
index 354c6272f..000000000
--- a/vendor/github.com/goamz/goamz/sts/sts_test.go
+++ /dev/null
@@ -1,151 +0,0 @@
-package sts_test
-
-import (
- "testing"
- "time"
-
- . "gopkg.in/check.v1"
-
- "github.com/goamz/goamz/aws"
- "github.com/goamz/goamz/sts"
- "github.com/goamz/goamz/testutil"
-)
-
-func Test(t *testing.T) {
- TestingT(t)
-}
-
-var _ = Suite(&S{})
-
-type S struct {
- sts *sts.STS
-}
-
-var testServer = testutil.NewHTTPServer()
-
-var mockTest bool
-
-func (s *S) SetUpSuite(c *C) {
- testServer.Start()
- auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
- s.sts = sts.New(auth, aws.Region{STSEndpoint: testServer.URL})
-}
-
-func (s *S) TearDownTest(c *C) {
- testServer.Flush()
-}
-
-func (s *S) TestAssumeRole(c *C) {
- testServer.Response(200, nil, AssumeRoleResponse)
- request := &sts.AssumeRoleParams{
- DurationSeconds: 3600,
- ExternalId: "123ABC",
- Policy: `{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"*"}]}`,
- RoleArn: "arn:aws:iam::123456789012:role/demo",
- RoleSessionName: "Bob",
- }
- resp, err := s.sts.AssumeRole(request)
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2011-06-15")
- c.Assert(values.Get("Action"), Equals, "AssumeRole")
- c.Assert(values.Get("DurationSeconds"), Equals, "3600")
- c.Assert(values.Get("ExternalId"), Equals, "123ABC")
- c.Assert(values.Get("Policy"), Equals, `{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"*"}]}`)
- c.Assert(values.Get("RoleArn"), Equals, "arn:aws:iam::123456789012:role/demo")
- c.Assert(values.Get("RoleSessionName"), Equals, "Bob")
- // Response test
- exp, _ := time.Parse(time.RFC3339, "2011-07-15T23:28:33.359Z")
- c.Assert(resp.RequestId, Equals, "c6104cbe-af31-11e0-8154-cbc7ccf896c7")
- c.Assert(resp.PackedPolicySize, Equals, 6)
- c.Assert(resp.AssumedRoleUser, DeepEquals, sts.AssumedRoleUser{
- Arn: "arn:aws:sts::123456789012:assumed-role/demo/Bob",
- AssumedRoleId: "ARO123EXAMPLE123:Bob",
- })
- c.Assert(resp.Credentials, DeepEquals, sts.Credentials{
- SessionToken: `
- AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQW
- LWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGd
- QrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU
- 9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz
- +scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==
- `,
- SecretAccessKey: `
- wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
- `,
- AccessKeyId: "AKIAIOSFODNN7EXAMPLE",
- Expiration: exp,
- })
-
-}
-
-func (s *S) TestGetFederationToken(c *C) {
- testServer.Response(200, nil, GetFederationTokenResponse)
- resp, err := s.sts.GetFederationToken(
- "Bob",
- `{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"*"}]}`,
- 3600,
- )
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2011-06-15")
- c.Assert(values.Get("Action"), Equals, "GetFederationToken")
- c.Assert(values.Get("DurationSeconds"), Equals, "3600")
- c.Assert(values.Get("Policy"), Equals, `{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"*"}]}`)
- c.Assert(values.Get("Name"), Equals, "Bob")
- // Response test
- exp, _ := time.Parse(time.RFC3339, "2011-07-15T23:28:33.359Z")
- c.Assert(resp.RequestId, Equals, "c6104cbe-af31-11e0-8154-cbc7ccf896c7")
- c.Assert(resp.PackedPolicySize, Equals, 6)
- c.Assert(resp.FederatedUser, DeepEquals, sts.FederatedUser{
- Arn: "arn:aws:sts::123456789012:federated-user/Bob",
- FederatedUserId: "123456789012:Bob",
- })
- c.Assert(resp.Credentials, DeepEquals, sts.Credentials{
- SessionToken: `
- AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQW
- LWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGd
- QrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU
- 9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz
- +scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==
- `,
- SecretAccessKey: `
- wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
- `,
- AccessKeyId: "AKIAIOSFODNN7EXAMPLE",
- Expiration: exp,
- })
-
-}
-
-func (s *S) TestGetSessionToken(c *C) {
- testServer.Response(200, nil, GetSessionTokenResponse)
- resp, err := s.sts.GetSessionToken(3600, "YourMFADeviceSerialNumber", "123456")
- c.Assert(err, IsNil)
- values := testServer.WaitRequest().PostForm
- // Post request test
- c.Assert(values.Get("Version"), Equals, "2011-06-15")
- c.Assert(values.Get("Action"), Equals, "GetSessionToken")
- c.Assert(values.Get("DurationSeconds"), Equals, "3600")
- c.Assert(values.Get("SerialNumber"), Equals, "YourMFADeviceSerialNumber")
- c.Assert(values.Get("TokenCode"), Equals, "123456")
- // Response test
- exp, _ := time.Parse(time.RFC3339, "2011-07-11T19:55:29.611Z")
- c.Assert(resp.RequestId, Equals, "58c5dbae-abef-11e0-8cfe-09039844ac7d")
- c.Assert(resp.Credentials, DeepEquals, sts.Credentials{
- SessionToken: `
- AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/L
- To6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3z
- rkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtp
- Z3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE
- `,
- SecretAccessKey: `
- wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
- `,
- AccessKeyId: "AKIAIOSFODNN7EXAMPLE",
- Expiration: exp,
- })
-
-}
diff --git a/vendor/github.com/goamz/goamz/testutil/http.go b/vendor/github.com/goamz/goamz/testutil/http.go
deleted file mode 100644
index ccc570cdd..000000000
--- a/vendor/github.com/goamz/goamz/testutil/http.go
+++ /dev/null
@@ -1,180 +0,0 @@
-package testutil
-
-import (
- "bytes"
- "fmt"
- "io/ioutil"
- "net"
- "net/http"
- "net/url"
- "os"
- "time"
-)
-
-type HTTPServer struct {
- URL string
- Timeout time.Duration
- started bool
- request chan *http.Request
- response chan ResponseFunc
-}
-
-type Response struct {
- Status int
- Headers map[string]string
- Body string
-}
-
-var DefaultClient = &http.Client{
- Transport: &http.Transport{
- Proxy: http.ProxyFromEnvironment,
- },
-}
-
-func NewHTTPServer() *HTTPServer {
- return &HTTPServer{URL: "http://localhost:4444", Timeout: 5 * time.Second}
-}
-
-type ResponseFunc func(path string) Response
-
-func (s *HTTPServer) Start() {
- if s.started {
- return
- }
- s.started = true
- s.request = make(chan *http.Request, 1024)
- s.response = make(chan ResponseFunc, 1024)
- u, err := url.Parse(s.URL)
- if err != nil {
- panic(err)
- }
- l, err := net.Listen("tcp", u.Host)
- if err != nil {
- panic(err)
- }
- go http.Serve(l, s)
-
- s.Response(203, nil, "")
- for {
- // Wait for it to be up.
- resp, err := http.Get(s.URL)
- if err == nil && resp.StatusCode == 203 {
- break
- }
- time.Sleep(1e8)
- }
- s.WaitRequest() // Consume dummy request.
-}
-
-// Flush discards all pending requests and responses.
-func (s *HTTPServer) Flush() {
- for {
- select {
- case <-s.request:
- case <-s.response:
- default:
- return
- }
- }
-}
-
-func body(req *http.Request) string {
- data, err := ioutil.ReadAll(req.Body)
- if err != nil {
- panic(err)
- }
- return string(data)
-}
-
-func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
- req.ParseMultipartForm(1e6)
- data, err := ioutil.ReadAll(req.Body)
- if err != nil {
- panic(err)
- }
- req.Body = ioutil.NopCloser(bytes.NewBuffer(data))
- s.request <- req
- var resp Response
- select {
- case respFunc := <-s.response:
- resp = respFunc(req.URL.Path)
- case <-time.After(s.Timeout):
- const msg = "ERROR: Timeout waiting for test to prepare a response\n"
- fmt.Fprintf(os.Stderr, msg)
- resp = Response{500, nil, msg}
- }
- if resp.Headers != nil {
- h := w.Header()
- for k, v := range resp.Headers {
- h.Set(k, v)
- }
- }
- if resp.Status != 0 {
- w.WriteHeader(resp.Status)
- }
- w.Write([]byte(resp.Body))
-}
-
-// WaitRequests returns the next n requests made to the http server from
-// the queue. If not enough requests were previously made, it waits until
-// the timeout value for them to be made.
-func (s *HTTPServer) WaitRequests(n int) []*http.Request {
- reqs := make([]*http.Request, 0, n)
- for i := 0; i < n; i++ {
- select {
- case req := <-s.request:
- reqs = append(reqs, req)
- case <-time.After(s.Timeout):
- panic("Timeout waiting for request")
- }
- }
- return reqs
-}
-
-// WaitRequest returns the next request made to the http server from
-// the queue. If no requests were previously made, it waits until the
-// timeout value for one to be made.
-func (s *HTTPServer) WaitRequest() *http.Request {
- return s.WaitRequests(1)[0]
-}
-
-// ResponseFunc prepares the test server to respond the following n
-// requests using f to build each response.
-func (s *HTTPServer) ResponseFunc(n int, f ResponseFunc) {
- for i := 0; i < n; i++ {
- s.response <- f
- }
-}
-
-// ResponseMap maps request paths to responses.
-type ResponseMap map[string]Response
-
-// ResponseMap prepares the test server to respond the following n
-// requests using the m to obtain the responses.
-func (s *HTTPServer) ResponseMap(n int, m ResponseMap) {
- f := func(path string) Response {
- for rpath, resp := range m {
- if rpath == path {
- return resp
- }
- }
- body := "Path not found in response map: " + path
- return Response{Status: 500, Body: body}
- }
- s.ResponseFunc(n, f)
-}
-
-// Responses prepares the test server to respond the following n requests
-// using the provided response parameters.
-func (s *HTTPServer) Responses(n int, status int, headers map[string]string, body string) {
- f := func(path string) Response {
- return Response{status, headers, body}
- }
- s.ResponseFunc(n, f)
-}
-
-// Response prepares the test server to respond the following request
-// using the provided response parameters.
-func (s *HTTPServer) Response(status int, headers map[string]string, body string) {
- s.Responses(1, status, headers, body)
-}
diff --git a/vendor/github.com/goamz/goamz/testutil/suite.go b/vendor/github.com/goamz/goamz/testutil/suite.go
deleted file mode 100644
index f4519aa4e..000000000
--- a/vendor/github.com/goamz/goamz/testutil/suite.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package testutil
-
-import (
- "flag"
-
- "github.com/goamz/goamz/aws"
- . "gopkg.in/check.v1"
-)
-
-// Amazon must be used by all tested packages to determine whether to
-// run functional tests against the real AWS servers.
-var Amazon bool
-
-func init() {
- flag.BoolVar(&Amazon, "amazon", false, "Enable tests against amazon server")
-}
-
-type LiveSuite struct {
- auth aws.Auth
-}
-
-func (s *LiveSuite) SetUpSuite(c *C) {
- if !Amazon {
- c.Skip("amazon tests not enabled (-amazon flag)")
- }
- auth, err := aws.EnvAuth()
- if err != nil {
- c.Fatal(err.Error())
- }
- s.auth = auth
-}