Skip to content

Commit

Permalink
feature/GeneratedMarshaling: Rebase with master branch (#481)
Browse files Browse the repository at this point in the history
* Add generated service for wafregional and dynamodbstreams (#463)

Updates the wafregional and dynamodbstreams API clients to include all API operations, and types that were previously shared between waf and dynamodb API clients respectively. This update ensures that all API clients include all operations and types needed for that client, and shares no types with another client package.

To migrate your applications to use the updated wafregional and dynamodbstreams you'll need to update the package the impacted type is imported from to match the client the type is being used with.

* `aws`: Add context on credential providers, EC2Metadata client o… (#461)

This PR makes a breaking change to the aws sdk for go v2, by adding context as a required parameter to each operation on EC2Metadata client. We also modified the Retrieve method on Credential Provider and signer utility to take in a user provided context.

SDK operations that relied on credential providers have been updated to accommodate this change. Tests and examples have also been modified.

* `private/model`: Add shape name validation for structs and enums (#471)

* Adds `validateShapeName` utility to validate that the shape names for structs and enums adhere to a defined format. 
* Fixes bug which allowed service package structs, enums to start with non alphabetic character 
* Fixes the incorrect enum types in mediapackage service package, changing enum types __AdTriggersElement, __PeriodTriggersElement to AdTriggersElement, PeriodTriggersElement respectively.
* Adds unit tests to test the validateShapeName utility.

* internal/sdkio: add RingBuffer data structure to the sdk (#417)

Adds a RingBuffer data structure. RingBuffer acts as a revolving buffer of a predefined length. It implements io.ReadWriter interface.

* aws/ec2metadata`: modifies IMDS client to use shorter request timeout

The PR modifies EC2Metadata client to use request context within its operations. Reduces the dialer timeout and response header timeout on the EC2Metadata client to help reduce latency for known issues with EC2Metadata client running inside a container.

* aws: Endpoints Usage Refactor for aws.Request and aws.Metadata (#473)

* Support for Loading Service Specific Configuration from External Sources During Client Creation (#474)

* service/s3: Adds Support for S3 AccessPoints (#476)

* Simplify Service Client Configuration Resolving (#478)

* Add timestamp support for SDK's generated API smoke tests (#477)

* Release v0.19.0 (2020-01-30) (#480)

Breaking Change
---
* `service`: Add generated service for wafregional and dynamodbstreams #463
  * Updates the wafregional and dynamodbstreams API clients to include all API operations, and types that were previously shared between waf and dynamodb API clients respectively. This update ensures that all API clients include all operations and types needed for that client, and shares no types with another client package.
  * To migrate your applications to use the updated wafregional and dynamodbstreams you'll need to update the package the impacted type is imported from to match the client the type is being used with.
* `aws`: Context has been added to EC2Metadata operations.([#461](#461))
  * Also updates utilities that directly or indirectly depend on EC2Metadata client. Signer utilities, credential providers now take in context.
* `private/model`: Add utility for validating shape names for structs and enums for the service packages ([#471](#471))
  * Fixes bug which allowed service package structs, enums to start with non alphabetic character
  * Fixes the incorrect enum types in mediapackage service package, changing enum types __AdTriggersElement, __PeriodTriggersElement to AdTriggersElement, PeriodTriggersElement respectively.
* `aws`: Client, Metadata, and Request structures have been refactored to simplify the usage of resolved endpoints ([#473](#473))
  * `aws.Client.Endpoint` struct member has been removed, and `aws.Request.Endpoint` struct member has been added of type `aws.Endpoint`
  * `aws.Client.Region` structure member has been removed

Services
---
* Synced the V2 SDK with latest AWS service API definitions.

SDK Features
---
* `aws`: `PartitionID` has been added to `aws.Endpoint` structure, and is used by the endpoint resolver to indicate which AWS partition an endpoint was resolved for ([#473](#473))
* `aws/endpoints`: Updated resolvers to populate `PartitionID` for a resolved `aws.Endpoint` ([#473](#473))
* `service/s3`: Add support for Access Point resources
  * Adds support for using Access Point resource with Amazon S3 API operation calls. The Access Point resource are identified by an Amazon Resource Name (ARN).
  * To make operation calls to an S3 Access Point instead of a S3 Bucket, provide the Access Point ARN string as the value of the Bucket parameter. You can create an Access Point for your bucket with the Amazon S3 Control API. The Access Point ARN can be obtained from the S3 Control API. You should avoid building the ARN directly.

SDK Enhancements
---
* `internal/sdkio`: Adds RingBuffer data structure to the sdk [#417](#417)
  * Adds an implementation of RingBuffer data structure which acts as a revolving buffer of a predefined length. The RingBuffer implements io.ReadWriter interface.
  * Adds unit tests to test the behavior of the ring buffer.
* `aws/ec2metadata`: Adds support for EC2Metadata client to use secure tokens provided by the IMDS ([#453](#453))
  * Modifies EC2Metadata client to use request context within its operations ([#462](#462))
  * Reduces the default dialer timeout and response header timeout to help reduce latency for known issues with EC2Metadata client running inside a container
  * Modifies and adds tests to verify the behavior of the EC2Metadata client.
* `service/dynamodb/dynamodbattribute`: Adds clarifying docs on dynamodbattribute.UnixTime ([#464](#464))
* `example/service/sts/assumeRole`: added sts assume role example ([#224](#224))
  * Fixes [#157](#157) by adding an example for Amazon STS assume role to retrieve credentials.

SDK Bugs
---
* `service/dynamodb/dynamodbattribute`: Fixes a panic when decoding into a map with a key string type alias. ([#465](#465))
  * Fixes [#410](#410),  by adding support for keys that are string aliases.

Co-authored-by: Sean McGrail <[email protected]>
Co-authored-by: Jason Del Ponte <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2020
1 parent 1bc9601 commit 1cd370a
Show file tree
Hide file tree
Showing 1,096 changed files with 47,871 additions and 6,640 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
Release v0.19.0 (2020-01-30)
===

Breaking Change
---
* `service`: Add generated service for wafregional and dynamodbstreams #463
* Updates the wafregional and dynamodbstreams API clients to include all API operations, and types that were previously shared between waf and dynamodb API clients respectively. This update ensures that all API clients include all operations and types needed for that client, and shares no types with another client package.
* To migrate your applications to use the updated wafregional and dynamodbstreams you'll need to update the package the impacted type is imported from to match the client the type is being used with.
* `aws`: Context has been added to EC2Metadata operations.([#461](https://github.com/aws/aws-sdk-go-v2/pull/461))
* Also updates utilities that directly or indirectly depend on EC2Metadata client. Signer utilities, credential providers now take in context.
* `private/model`: Add utility for validating shape names for structs and enums for the service packages ([#471](https://github.com/aws/aws-sdk-go-v2/pull/471))
* Fixes bug which allowed service package structs, enums to start with non alphabetic character
* Fixes the incorrect enum types in mediapackage service package, changing enum types __AdTriggersElement, __PeriodTriggersElement to AdTriggersElement, PeriodTriggersElement respectively.
* `aws`: Client, Metadata, and Request structures have been refactored to simplify the usage of resolved endpoints ([#473](https://github.com/aws/aws-sdk-go-v2/pull/473))
* `aws.Client.Endpoint` struct member has been removed, and `aws.Request.Endpoint` struct member has been added of type `aws.Endpoint`
* `aws.Client.Region` structure member has been removed

Services
---
* Synced the V2 SDK with latest AWS service API definitions.

SDK Features
---
* `aws`: `PartitionID` has been added to `aws.Endpoint` structure, and is used by the endpoint resolver to indicate which AWS partition an endpoint was resolved for ([#473](https://github.com/aws/aws-sdk-go-v2/pull/473))
* `aws/endpoints`: Updated resolvers to populate `PartitionID` for a resolved `aws.Endpoint` ([#473](https://github.com/aws/aws-sdk-go-v2/pull/473))
* `service/s3`: Add support for Access Point resources
* Adds support for using Access Point resource with Amazon S3 API operation calls. The Access Point resource are identified by an Amazon Resource Name (ARN).
* To make operation calls to an S3 Access Point instead of a S3 Bucket, provide the Access Point ARN string as the value of the Bucket parameter. You can create an Access Point for your bucket with the Amazon S3 Control API. The Access Point ARN can be obtained from the S3 Control API. You should avoid building the ARN directly.

SDK Enhancements
---
* `internal/sdkio`: Adds RingBuffer data structure to the sdk [#417](https://github.com/aws/aws-sdk-go-v2/pull/417)
* Adds an implementation of RingBuffer data structure which acts as a revolving buffer of a predefined length. The RingBuffer implements io.ReadWriter interface.
* Adds unit tests to test the behavior of the ring buffer.
* `aws/ec2metadata`: Adds support for EC2Metadata client to use secure tokens provided by the IMDS ([#453](https://github.com/aws/aws-sdk-go-v2/pull/453))
* Modifies EC2Metadata client to use request context within its operations ([#462](https://github.com/aws/aws-sdk-go-v2/pull/462))
* Reduces the default dialer timeout and response header timeout to help reduce latency for known issues with EC2Metadata client running inside a container
* Modifies and adds tests to verify the behavior of the EC2Metadata client.
* `service/dynamodb/dynamodbattribute`: Adds clarifying docs on dynamodbattribute.UnixTime ([#464](https://github.com/aws/aws-sdk-go-v2/pull/464))
* `example/service/sts/assumeRole`: added sts assume role example ([#224](https://github.com/aws/aws-sdk-go-v2/pull/224))
* Fixes [#157](https://github.com/aws/aws-sdk-go-v2/issues/157) by adding an example for Amazon STS assume role to retrieve credentials.

SDK Bugs
---
* `service/dynamodb/dynamodbattribute`: Fixes a panic when decoding into a map with a key string type alias. ([#465](https://github.com/aws/aws-sdk-go-v2/pull/465))
* Fixes [#410](https://github.com/aws/aws-sdk-go-v2/issues/410), by adding support for keys that are string aliases.

Release v0.18.0 (2019-12-12)
===

Expand Down
10 changes: 3 additions & 7 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Breaking Change
---

Services
---

Expand All @@ -6,13 +9,6 @@ SDK Features

SDK Enhancements
---
* `aws/ec2metadata`: Adds support for EC2Metadata client to use secure tokens provided by the IMDS ([#453](https://github.com/aws/aws-sdk-go-v2/pull/453))
* Modifies and adds tests to verify the behavior of the EC2Metadata client.
* `service/dynamodb/dynamodbattribute`: Adds clarifying docs on dynamodbattribute.UnixTime ([#464](https://github.com/aws/aws-sdk-go-v2/pull/464))
* `example/service/sts/assumeRole`: added sts assume role example ([#224](https://github.com/aws/aws-sdk-go-v2/pull/224))
* Fixes [#157](https://github.com/aws/aws-sdk-go-v2/issues/157) by adding an example for Amazon STS assume role to retrieve credentials.

SDK Bugs
---
* `service/dynamodb/dynamodbattribute`: Fixes a panic when decoding into a map with a key string type alias. ([#465](https://github.com/aws/aws-sdk-go/pull/465))
* Fixes [#410](https://github.com/aws/aws-sdk-go-v2/issues/410), by adding support for keys that are string aliases.
6 changes: 6 additions & 0 deletions aws/arn/arn.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ func Parse(arn string) (ARN, error) {
}, nil
}

// IsARN returns whether the given string is an arn
// by looking for whether the string starts with arn:
func IsARN(arn string) bool {
return strings.HasPrefix(arn, arnPrefix) && strings.Count(arn, ":") >= arnSections-1
}

// String returns the canonical representation of the ARN
func (arn ARN) String() string {
return arnPrefix +
Expand Down
41 changes: 41 additions & 0 deletions aws/arn/arn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,44 @@ func TestParseARN(t *testing.T) {
})
}
}

func TestIsARN(t *testing.T) {

cases := map[string]struct {
In string
Expect bool
// Params
}{
"valid ARN slash resource": {
In: "arn:aws:service:us-west-2:123456789012:restype/resvalue",
Expect: true,
},
"valid ARN colon resource": {
In: "arn:aws:service:us-west-2:123456789012:restype:resvalue",
Expect: true,
},
"valid ARN resource": {
In: "arn:aws:service:us-west-2:123456789012:*",
Expect: true,
},
"empty sections": {
In: "arn:::::",
Expect: true,
},
"invalid ARN": {
In: "some random string",
},
"invalid ARN missing resource": {
In: "arn:aws:service:us-west-2:123456789012",
},
}

for name, c := range cases {
t.Run(name, func(t *testing.T) {
actual := IsARN(c.In)
if e, a := c.Expect, actual; e != a {
t.Errorf("expect %s valid %v, got %v", c.In, e, a)
}
})
}
}
5 changes: 3 additions & 2 deletions aws/chain_provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aws

import (
"context"
"github.com/aws/aws-sdk-go-v2/aws/awserr"
)

Expand Down Expand Up @@ -60,10 +61,10 @@ func NewChainProvider(providers []CredentialsProvider) *ChainProvider {
//
// If a provider is found it will be cached and any calls to IsExpired()
// will return the expired state of the cached provider.
func (c *ChainProvider) retrieveFn() (Credentials, error) {
func (c *ChainProvider) retrieveFn(ctx context.Context) (Credentials, error) {
var errs []error
for _, p := range c.Providers {
creds, err := p.Retrieve()
creds, err := p.Retrieve(ctx)
if err == nil {
return creds, nil
}
Expand Down
11 changes: 6 additions & 5 deletions aws/chain_provider_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aws

import (
"context"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -30,7 +31,7 @@ func TestChainProvider_WithNames(t *testing.T) {
},
)

creds, err := p.Retrieve()
creds, err := p.Retrieve(context.Background())
if err != nil {
t.Fatalf("expect no error")
}
Expand Down Expand Up @@ -65,7 +66,7 @@ func TestChainProvider_Retrieve(t *testing.T) {
},
)

creds, err := p.Retrieve()
creds, err := p.Retrieve(context.Background())
if err != nil {
t.Fatalf("expect no error")
}
Expand All @@ -87,7 +88,7 @@ func TestChainProvider_IsExpired(t *testing.T) {
},
)

creds, err := p.Retrieve()
creds, err := p.Retrieve(context.Background())
if err != nil {
t.Fatalf("expect no error")
}
Expand All @@ -99,7 +100,7 @@ func TestChainProvider_IsExpired(t *testing.T) {
func TestChainProvider_WithNoProvider(t *testing.T) {
p := NewChainProvider([]CredentialsProvider{})

_, err := p.Retrieve()
_, err := p.Retrieve(context.Background())
if e, a := "no valid providers", err.Error(); !strings.Contains(a, e) {
t.Errorf("expect %q error in %q", e, a)
}
Expand All @@ -117,7 +118,7 @@ func TestChainProvider_WithNoValidProvider(t *testing.T) {
},
)

_, err := p.Retrieve()
_, err := p.Retrieve(context.Background())
if e, a := "no valid providers", err.Error(); !strings.Contains(a, e) {
t.Errorf("expect %q error in %q", e, a)
}
Expand Down
3 changes: 0 additions & 3 deletions aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Metadata struct {
EndpointsID string
APIVersion string

Endpoint string
SigningName string
SigningRegion string

Expand All @@ -24,7 +23,6 @@ type Metadata struct {
type Client struct {
Metadata Metadata
Config Config
Region string
Credentials CredentialsProvider
EndpointResolver EndpointResolver
Handlers Handlers
Expand All @@ -42,7 +40,6 @@ func NewClient(cfg Config, metadata Metadata) *Client {
// TODO remove config when request refactored
Config: cfg,

Region: cfg.Region,
Credentials: cfg.Credentials,
EndpointResolver: cfg.EndpointResolver,
Handlers: cfg.Handlers.Copy(),
Expand Down
4 changes: 4 additions & 0 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ type Config struct {
// Disabling this feature is useful when you want to use local endpoints
// for testing that do not support the modeled host prefix pattern.
DisableEndpointHostPrefix bool

// ConfigSources are the sources that were used to construct the Config.
// Allows for additional configuration can be loaded by clients.
ConfigSources []interface{}
}

// NewConfig returns a new Config pointer that can be chained with builder
Expand Down
11 changes: 5 additions & 6 deletions aws/credentials.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aws

import (
"context"
"math"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -76,15 +77,13 @@ func (v Credentials) HasKeys() bool {
type CredentialsProvider interface {
// Retrieve returns nil if it successfully retrieved the value.
// Error is returned if the value were not obtainable, or empty.
Retrieve() (Credentials, error)

// TODO should Retrieve take a context?
Retrieve(ctx context.Context) (Credentials, error)
}

// SafeCredentialsProvider provides caching and concurrency safe credentials
// retrieval via the RetrieveFn.
type SafeCredentialsProvider struct {
RetrieveFn func() (Credentials, error)
RetrieveFn func(ctx context.Context) (Credentials, error)

creds atomic.Value
m sync.Mutex
Expand All @@ -95,7 +94,7 @@ type SafeCredentialsProvider struct {
// credentials have not been retrieved yet, or expired RetrieveFn will be called.
//
// Returns and error if RetrieveFn returns an error.
func (p *SafeCredentialsProvider) Retrieve() (Credentials, error) {
func (p *SafeCredentialsProvider) Retrieve(ctx context.Context) (Credentials, error) {
if creds := p.getCreds(); creds != nil {
return *creds, nil
}
Expand All @@ -108,7 +107,7 @@ func (p *SafeCredentialsProvider) Retrieve() (Credentials, error) {
return *creds, nil
}

creds, err := p.RetrieveFn()
creds, err := p.RetrieveFn(ctx)
if err != nil {
return Credentials{}, err
}
Expand Down
9 changes: 5 additions & 4 deletions aws/credentials_bench_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aws

import (
"context"
"fmt"
"strconv"
"sync"
Expand All @@ -9,7 +10,7 @@ import (
)

func BenchmarkSafeCredentialsProvider_Retrieve(b *testing.B) {
retrieveFn := func() (Credentials, error) {
retrieveFn := func(ctx context.Context) (Credentials, error) {
return Credentials{
AccessKeyID: "key",
SecretAccessKey: "secret",
Expand All @@ -28,7 +29,7 @@ func BenchmarkSafeCredentialsProvider_Retrieve(b *testing.B) {
for i := 0; i < c; i++ {
go func() {
for j := 0; j < b.N; j++ {
v, err := p.Retrieve()
v, err := p.Retrieve(context.Background())
if err != nil {
b.Fatalf("expect no error %v, %v", v, err)
}
Expand All @@ -44,7 +45,7 @@ func BenchmarkSafeCredentialsProvider_Retrieve(b *testing.B) {
}

func BenchmarkSafeCredentialsProvider_Retrieve_Invalidate(b *testing.B) {
retrieveFn := func() (Credentials, error) {
retrieveFn := func(ctx context.Context) (Credentials, error) {
time.Sleep(time.Millisecond)
return Credentials{
AccessKeyID: "key",
Expand All @@ -66,7 +67,7 @@ func BenchmarkSafeCredentialsProvider_Retrieve_Invalidate(b *testing.B) {
for i := 0; i < c; i++ {
go func(id int) {
for j := 0; j < b.N; j++ {
v, err := p.Retrieve()
v, err := p.Retrieve(context.Background())
if err != nil {
b.Fatalf("expect no error %v, %v", v, err)
}
Expand Down
Loading

0 comments on commit 1cd370a

Please sign in to comment.