Commit 83f789c1 authored by Dmitry Smirnov's avatar Dmitry Smirnov

Imported Upstream version 1.0.7+dfsg

parent bbdb97c7
vendor
dist
doc
.yardoc
Gemfile.lock
awstesting/integration/smoke/**/importmarker__.go
awstesting/integration/smoke/_test/
/vendor/bin/
/vendor/pkg/
/vendor/src/
......@@ -6,9 +6,16 @@ go:
- 1.4
- 1.5
- tip
# Use Go 1.5's vendoring experiment for 1.5 tests. 1.4 tests will use the tip of the dependancies repo.
env:
- GO15VENDOREXPERIMENT=1
install: "go get -v -t ./... && make deps"
script: make unit
install:
- make get-deps
script:
- make unit
matrix:
allow_failures:
......
LINTIGNOREDOT='internal/features.+should not use dot imports'
LINTIGNOREDOC='service/[^/]+/(api|service)\.go:.+(comment on exported|should have comment or be unexported)'
LINTIGNORECONST='service/[^/]+/(api|service)\.go:.+(type|struct field|const|func) ([^ ]+) should be ([^ ]+)'
LINTIGNOREDOT='awstesting/integration.+should not use dot imports'
LINTIGNOREDOC='service/[^/]+/(api|service|waiters)\.go:.+(comment on exported|should have comment or be unexported)'
LINTIGNORECONST='service/[^/]+/(api|service|waiters)\.go:.+(type|struct field|const|func) ([^ ]+) should be ([^ ]+)'
LINTIGNORESTUTTER='service/[^/]+/(api|service)\.go:.+(and that stutters)'
LINTIGNOREINFLECT='service/[^/]+/(api|service)\.go:.+method .+ should be '
LINTIGNOREDEPS='vendor/.+\.go'
SDK_WITH_VENDOR_PKGS=$(shell go list ./... | grep -v "/vendor/src")
SDK_ONLY_PKGS=$(shell go list ./... | grep -v "/vendor/")
all: generate unit
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " api_info to print a list of services and versions"
@echo " build to go build the SDK"
@echo " deps to go get the SDK dependencies"
@echo " docs to build SDK documentation"
@echo " generate to go generate and make services"
@echo " generate-protocol-test to generate protocol tests"
@echo " build to go build the SDK"
@echo " unit to run unit tests"
@echo " integration to run integration tests"
@echo " verify to verify tests"
@echo " lint to lint the SDK"
@echo " services to generate services"
@echo " unit to run unit tests"
@echo " vet to vet the SDK"
@echo " generate to go generate and make services"
@echo " gen-test to generate protocol tests"
@echo " gen-services to generate services"
@echo " get-deps to go get the SDK dependencies"
@echo " get-deps-unit to get the SDK's unit test dependencies"
@echo " get-deps-integ to get the SDK's integration test dependencies"
@echo " get-deps-verify to get the SDK's verification dependencies"
default: generate
generate: gen-test gen-endpoints gen-services
generate-protocol-test:
go generate ./internal/protocol/...
gen-test: gen-protocol-test
generate-test: generate-protocol-test
gen-services:
go generate ./service
generate:
go generate ./internal/endpoints
@make services
gen-protocol-test:
go generate ./private/protocol/...
services:
go generate ./service
gen-endpoints:
go generate ./private/endpoints
build:
@echo "go build SDK and vendor packages"
@go build $(SDK_WITH_VENDOR_PKGS)
unit: get-deps-unit build verify
@echo "go test SDK and vendor packages"
@go test $(SDK_WITH_VENDOR_PKGS)
integration: get-deps-integ
go test -tags=integration ./awstesting/integration/customizations/...
gucumber ./awstesting/integration/smoke
integration: deps
go test ./internal/test/integration/... -tags=integration
gucumber ./internal/features/smoke
verify: get-deps-verify lint vet
lint: deps
@echo "golint ./..."
lint:
@echo "go lint SDK and vendor packages"
@lint=`golint ./...`; \
lint=`echo "$$lint" | grep -E -v -e ${LINTIGNOREDOT} -e ${LINTIGNOREDOC} -e ${LINTIGNORECONST}`; \
lint=`echo "$$lint" | grep -E -v -e ${LINTIGNOREDOT} -e ${LINTIGNOREDOC} -e ${LINTIGNORECONST} -e ${LINTIGNORESTUTTER} -e ${LINTIGNOREINFLECT} -e ${LINTIGNOREDEPS}`; \
echo "$$lint"; \
if [ "$$lint" != "" ]; then exit 1; fi
unit: deps build lint
go test ./...
vet:
go tool vet -all -shadow $(shell ls -d */ | grep -v vendor)
build:
go build ./...
get-deps: get-deps-unit get-deps-integ get-deps-verify
@echo "go get SDK dependencies"
@go get -v $(SDK_ONLY_PKGS)
get-deps-unit:
@echo "go get SDK unit testing dependancies"
go get github.com/stretchr/testify
go get github.com/smartystreets/goconvey
get-deps-integ: get-deps-unit
@echo "go get SDK integration testing dependencies"
go get github.com/lsegal/gucumber/cmd/gucumber
get-deps-verify:
@echo "go get SDK verification utilities"
go get github.com/golang/lint/golint
bench:
@echo "go bench SDK packages"
@go test -run NONE -bench . -benchmem -tags 'bench' $(SDK_ONLY_PKGS)
bench-protocol:
@echo "go bench SDK protocol marshallers"
@go test -run NONE -bench . -benchmem -tags 'bench' ./private/protocol/...
docs:
@echo "generate SDK docs"
rm -rf doc && bundle install && bundle exec yard
deps:
@go get ./...
@go get github.com/lsegal/gucumber/cmd/gucumber
@go get github.com/golang/lint/golint
api_info:
@go run internal/model/cli/api-info/api-info.go
perf:
@go test -bench . -benchmem -tags 'perf' ./internal/test/perf/...
\ No newline at end of file
@go run private/model/cli/api-info/api-info.go
......@@ -9,31 +9,13 @@ aws-sdk-go is the official AWS SDK for the Go programming language.
Checkout our [release notes](https://github.com/aws/aws-sdk-go/releases) for information about the latest bug fixes, updates, and features added to the SDK.
**Release [v0.9.0rc1](http://aws.amazon.com/releasenotes/2948141298714307) introduced a breaking change to the SDK. See the release notes for details of the change and instructions to migrate to the latest SDK version.**
## Caution
The SDK is currently in the process of being developed, and not everything
may be working fully yet. Please be patient and report any bugs or problems
you experience. The APIs may change radically without much warning, so please
vendor your dependencies with Godep or similar.
Please do not confuse this for a stable, feature-complete library.
Note that while most AWS protocols are currently supported, not all services
available in this package are implemented fully, as some require extra
customizations to work with the SDK. If you've encountered such a scenario,
please open a [GitHub issue](https://github.com/aws/aws-sdk-go/issues)
so we can track work for the service.
## Installing
Install your specific service package with the following `go get` command.
For example, EC2 support might be installed with:
If you are using Go 1.5 with the `GO15VENDOREXPERIMENT=1` vendoring flag you can use the following to get the SDK as the SDK's runtime dependancies are vendored in the `vendor` folder.
$ go get github.com/aws/aws-sdk-go/service/ec2
$ go get -u github.com/aws/aws-sdk-go
You can also install the entire SDK by installing the root package, including all of the SDK's dependencies:
Otherwise you'll need to tell Go to get the SDK and all of its dependancies.
$ go get -u github.com/aws/aws-sdk-go/...
......@@ -59,10 +41,10 @@ AWS_ACCESS_KEY_ID=AKID1234567890
AWS_SECRET_ACCESS_KEY=MY-SECRET-KEY
```
## Using
## Using the Go SDK
To use a service in the SDK, create a service variable by calling the `New()`
function. Once you have a service, you can call API operations which each
function. Once you have a service client, you can call API operations which each
return response data and a possible error.
To list a set of instance IDs from EC2, you could run:
......@@ -74,6 +56,7 @@ import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
)
......@@ -81,7 +64,7 @@ func main() {
// Create an EC2 service object in the "us-west-2" region
// Note that you can also configure your region globally by
// exporting the AWS_REGION environment variable
svc := ec2.New(&aws.Config{Region: aws.String("us-west-2")})
svc := ec2.New(session.New(), &aws.Config{Region: aws.String("us-west-2")})
// Call the DescribeInstances Operation
resp, err := svc.DescribeInstances(nil)
......
This diff is collapsed.
......@@ -57,16 +57,13 @@ func rcopy(dst, src reflect.Value, root bool) {
}
}
case reflect.Struct:
if !root {
dst.Set(reflect.New(src.Type()).Elem())
}
t := dst.Type()
for i := 0; i < t.NumField(); i++ {
name := t.Field(i).Name
srcval := src.FieldByName(name)
if srcval.IsValid() {
rcopy(dst.FieldByName(name), srcval, false)
srcVal := src.FieldByName(name)
dstVal := dst.FieldByName(name)
if srcVal.IsValid() && dstVal.CanSet() {
rcopy(dstVal, srcVal, false)
}
}
case reflect.Slice:
......
......@@ -77,6 +77,28 @@ func TestCopy(t *testing.T) {
assert.NotEqual(t, f2.C, f1.C)
}
func TestCopyNestedWithUnexported(t *testing.T) {
type Bar struct {
a int
B int
}
type Foo struct {
A string
B Bar
}
f1 := &Foo{A: "string", B: Bar{a: 1, B: 2}}
var f2 Foo
awsutil.Copy(&f2, f1)
// Values match
assert.Equal(t, f2.A, f1.A)
assert.NotEqual(t, f2.B, f1.B)
assert.NotEqual(t, f2.B.a, f1.B.a)
assert.Equal(t, f2.B.B, f2.B.B)
}
func TestCopyIgnoreNilMembers(t *testing.T) {
type Foo struct {
A *string
......@@ -136,6 +158,8 @@ func TestCopyDifferentStructs(t *testing.T) {
C map[string]*int
SrcUnique string
SameNameDiffType int
unexportedPtr *int
ExportedPtr *int
}
type DstFoo struct {
A int
......@@ -143,6 +167,8 @@ func TestCopyDifferentStructs(t *testing.T) {
C map[string]*int
DstUnique int
SameNameDiffType string
unexportedPtr *int
ExportedPtr *int
}
// Create the initial value
......@@ -159,6 +185,8 @@ func TestCopyDifferentStructs(t *testing.T) {
},
SrcUnique: "unique",
SameNameDiffType: 1,
unexportedPtr: &int1,
ExportedPtr: &int2,
}
// Do the copy
......@@ -173,6 +201,10 @@ func TestCopyDifferentStructs(t *testing.T) {
assert.Equal(t, 1, f1.SameNameDiffType)
assert.Equal(t, 0, f2.DstUnique)
assert.Equal(t, "", f2.SameNameDiffType)
assert.Equal(t, int1, *f1.unexportedPtr)
assert.Nil(t, f2.unexportedPtr)
assert.Equal(t, int2, *f1.ExportedPtr)
assert.Equal(t, int2, *f2.ExportedPtr)
}
func ExampleCopyOf() {
......
package awsutil
import (
"reflect"
)
// DeepEqual returns if the two values are deeply equal like reflect.DeepEqual.
// In addition to this, this method will also dereference the input values if
// possible so the DeepEqual performed will not fail if one parameter is a
// pointer and the other is not.
//
// DeepEqual will not perform indirection of nested values of the input parameters.
func DeepEqual(a, b interface{}) bool {
ra := reflect.Indirect(reflect.ValueOf(a))
rb := reflect.Indirect(reflect.ValueOf(b))
if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid {
// If the elements are both nil, and of the same type the are equal
// If they are of different types they are not equal
return reflect.TypeOf(a) == reflect.TypeOf(b)
} else if raValid != rbValid {
// Both values must be valid to be equal
return false
}
return reflect.DeepEqual(ra.Interface(), rb.Interface())