chore(aws): upgrade aws dependencies

This commit is contained in:
2021-11-24 19:10:52 +01:00
parent 165108d1c3
commit b13ff06b36
229 changed files with 13263 additions and 1613 deletions

View File

@ -1,3 +1,16 @@
# Release (v1.9.0)
## Module Highlights
* `github.com/aws/smithy-go`: v1.9.0
* **Feature**: sync: OnceErr, can be used to concurrently record a signal when an error has occurred.
* **Bug Fix**: `transport/http`: CloseResponseBody and ErrorCloseResponseBody middleware have been updated to ensure that the body is fully drained before closing.
# Release v1.8.1
### Smithy Go Module
* **Bug Fix**: Fixed an issue that would cause the HTTP Content-Length to be set to 0 if the stream body was not set.
* Fixes [aws/aws-sdk-go-v2#1418](https://github.com/aws/aws-sdk-go-v2/issues/1418)
# Release v1.8.0
### Smithy Go Module

View File

@ -1,4 +1,17 @@
RELEASE_MANIFEST_FILE ?=
RELEASE_CHGLOG_DESC_FILE ?=
REPOTOOLS_VERSION ?= latest
REPOTOOLS_MODULE = github.com/awslabs/aws-go-multi-module-repository-tools
REPOTOOLS_CMD_CALCULATE_RELEASE = ${REPOTOOLS_MODULE}/cmd/calculaterelease@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_UPDATE_REQUIRES = ${REPOTOOLS_MODULE}/cmd/updaterequires@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_UPDATE_MODULE_METADATA = ${REPOTOOLS_MODULE}/cmd/updatemodulemeta@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_GENERATE_CHANGELOG = ${REPOTOOLS_MODULE}/cmd/generatechangelog@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_CHANGELOG = ${REPOTOOLS_MODULE}/cmd/changelog@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_TAG_RELEASE = ${REPOTOOLS_MODULE}/cmd/tagrelease@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_MODULE_VERSION = ${REPOTOOLS_MODULE}/cmd/moduleversion@${REPOTOOLS_VERSION}
smithy-publish-local:
cd codegen && ./gradlew publishToMavenLocal
@ -7,3 +20,38 @@ smithy-build:
smithy-clean:
cd codegen && ./gradlew clean
#####################
# Release Process #
#####################
.PHONY: preview-release pre-release-validation release
preview-release:
go run ${REPOTOOLS_CMD_CALCULATE_RELEASE}
pre-release-validation:
@if [[ -z "${RELEASE_MANIFEST_FILE}" ]]; then \
echo "RELEASE_MANIFEST_FILE is required to specify the file to write the release manifest" && false; \
fi
@if [[ -z "${RELEASE_CHGLOG_DESC_FILE}" ]]; then \
echo "RELEASE_CHGLOG_DESC_FILE is required to specify the file to write the release notes" && false; \
fi
release: pre-release-validation
go run ${REPOTOOLS_CMD_CALCULATE_RELEASE} -o ${RELEASE_MANIFEST_FILE}
go run ${REPOTOOLS_CMD_UPDATE_REQUIRES} -release ${RELEASE_MANIFEST_FILE}
go run ${REPOTOOLS_CMD_UPDATE_MODULE_METADATA} -release ${RELEASE_MANIFEST_FILE}
go run ${REPOTOOLS_CMD_GENERATE_CHANGELOG} -release ${RELEASE_MANIFEST_FILE} -o ${RELEASE_CHGLOG_DESC_FILE}
go run ${REPOTOOLS_CMD_CHANGELOG} rm -all
go run ${REPOTOOLS_CMD_TAG_RELEASE} -release ${RELEASE_MANIFEST_FILE}
module-version:
@go run ${REPOTOOLS_CMD_MODULE_VERSION} .
##############
# Repo Tools #
##############
.PHONY: install-changelog
install-changelog:
go install ${REPOTOOLS_MODULE}/cmd/changelog@${REPOTOOLS_VERSION}

View File

@ -0,0 +1,6 @@
// Code generated by internal/repotools/cmd/updatemodulemeta DO NOT EDIT.
package smithy
// goModuleVersion is the tagged release for this module
const goModuleVersion = "1.9.0"

View File

@ -31,30 +31,45 @@ type UUID struct {
}
// NewUUID returns an initialized UUID value that can be used to retrieve
// random UUID values.
// random UUID version 4 values.
func NewUUID(r io.Reader) *UUID {
return &UUID{randSrc: r}
}
// GetUUID returns a UUID random string sourced from the random reader the
// GetUUID returns a random UUID version 4 string representation sourced from the random reader the
// UUID was created with. Returns an error if unable to compute the UUID.
func (r *UUID) GetUUID() (string, error) {
var b [16]byte
if _, err := io.ReadFull(r.randSrc, b[:]); err != nil {
return "", err
}
return uuidVersion4(b), nil
r.makeUUIDv4(b[:])
return format(b), nil
}
// uuidVersion4 returns a random UUID version 4 from the byte slice provided.
func uuidVersion4(u [16]byte) string {
// https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29
// GetBytes returns a byte slice containing a random UUID version 4 sourced from the random reader the
// UUID was created with. Returns an error if unable to compute the UUID.
func (r *UUID) GetBytes() (u []byte, err error) {
u = make([]byte, 16)
if _, err = io.ReadFull(r.randSrc, u); err != nil {
return u, err
}
r.makeUUIDv4(u)
return u, nil
}
func (r *UUID) makeUUIDv4(u []byte) {
// 13th character is "4"
u[6] = (u[6] & 0x0f) | 0x40 // Version 4
// 17th character is "8", "9", "a", or "b"
u[8] = (u[8] & 0x3f) | 0x80 // Variant is 10
u[8] = (u[8] & 0x3f) | 0x80 // Variant most significant bits are 10x where x can be either 1 or 0
}
// Format returns the canonical text representation of a UUID.
// This implementation is optimized to not use fmt.
// Example: 82e42f16-b6cc-4d5b-95f5-d403c4befd3d
func format(u [16]byte) string {
// https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29
var scratch [36]byte

54
vendor/github.com/aws/smithy-go/sync/error.go generated vendored Normal file
View File

@ -0,0 +1,54 @@
package sync
import "sync"
// OnceErr wraps the behavior of recording an error
// once and signal on a channel when this has occurred.
// Signaling is done by closing of the channel.
//
// Type is safe for concurrent usage.
type OnceErr struct {
mu sync.RWMutex
err error
ch chan struct{}
}
// NewOnceErr return a new OnceErr
func NewOnceErr() *OnceErr {
return &OnceErr{
ch: make(chan struct{}, 1),
}
}
// Err acquires a read-lock and returns an
// error if one has been set.
func (e *OnceErr) Err() error {
e.mu.RLock()
err := e.err
e.mu.RUnlock()
return err
}
// SetError acquires a write-lock and will set
// the underlying error value if one has not been set.
func (e *OnceErr) SetError(err error) {
if err == nil {
return
}
e.mu.Lock()
if e.err == nil {
e.err = err
close(e.ch)
}
e.mu.Unlock()
}
// ErrorSet returns a channel that will be used to signal
// that an error has been set. This channel will be closed
// when the error value has been set for OnceErr.
func (e *OnceErr) ErrorSet() <-chan struct{} {
return e.ch
}

View File

@ -2,9 +2,10 @@ package http
import (
"context"
"fmt"
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/middleware"
"io"
"io/ioutil"
)
// AddErrorCloseResponseBodyMiddleware adds the middleware to automatically
@ -28,6 +29,8 @@ func (m *errorCloseResponseBodyMiddleware) HandleDeserialize(
out, metadata, err := next.HandleDeserialize(ctx, input)
if err != nil {
if resp, ok := out.RawResponse.(*Response); ok && resp != nil && resp.Body != nil {
// Consume the full body to prevent TCP connection resets on some platforms
_, _ = io.Copy(ioutil.Discard, resp.Body)
// Do not validate that the response closes successfully.
resp.Body.Close()
}
@ -60,8 +63,15 @@ func (m *closeResponseBody) HandleDeserialize(
}
if resp, ok := out.RawResponse.(*Response); ok {
if err = resp.Body.Close(); err != nil {
return out, metadata, fmt.Errorf("close response body failed, %w", err)
// Consume the full body to prevent TCP connection resets on some platforms
_, copyErr := io.Copy(ioutil.Discard, resp.Body)
if copyErr != nil {
middleware.GetLogger(ctx).Logf(logging.Warn, "failed to discard remaining HTTP response body, this may affect connection reuse")
}
closeErr := resp.Body.Close()
if closeErr != nil {
middleware.GetLogger(ctx).Logf(logging.Warn, "failed to close HTTP response body, this may affect connection reuse")
}
}

View File

@ -46,11 +46,13 @@ func (r *RequestResponseLogger) HandleDeserialize(
logger.Logf(logging.Debug, "Request\n%v", string(reqBytes))
smithyRequest, err = smithyRequest.SetStream(rc.Body)
if err != nil {
return out, metadata, err
if r.LogRequestWithBody {
smithyRequest, err = smithyRequest.SetStream(rc.Body)
if err != nil {
return out, metadata, err
}
in.Request = smithyRequest
}
in.Request = smithyRequest
}
out, metadata, err = next.HandleDeserialize(ctx, in)

View File

@ -0,0 +1,79 @@
package http
import (
"context"
"fmt"
"github.com/aws/smithy-go/middleware"
"strings"
)
// MinimumProtocolError is an error type indicating that the established connection did not meet the expected minimum
// HTTP protocol version.
type MinimumProtocolError struct {
proto string
expectedProtoMajor int
expectedProtoMinor int
}
// Error returns the error message.
func (m *MinimumProtocolError) Error() string {
return fmt.Sprintf("operation requires minimum HTTP protocol of HTTP/%d.%d, but was %s",
m.expectedProtoMajor, m.expectedProtoMinor, m.proto)
}
// RequireMinimumProtocol is a deserialization middleware that asserts that the established HTTP connection
// meets the minimum major ad minor version.
type RequireMinimumProtocol struct {
ProtoMajor int
ProtoMinor int
}
// AddRequireMinimumProtocol adds the RequireMinimumProtocol middleware to the stack using the provided minimum
// protocol major and minor version.
func AddRequireMinimumProtocol(stack *middleware.Stack, major, minor int) error {
return stack.Deserialize.Insert(&RequireMinimumProtocol{
ProtoMajor: major,
ProtoMinor: minor,
}, "OperationDeserializer", middleware.Before)
}
// ID returns the middleware identifier string.
func (r *RequireMinimumProtocol) ID() string {
return "RequireMinimumProtocol"
}
// HandleDeserialize asserts that the established connection is a HTTP connection with the minimum major and minor
// protocol version.
func (r *RequireMinimumProtocol) HandleDeserialize(
ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler,
) (
out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
) {
out, metadata, err = next.HandleDeserialize(ctx, in)
if err != nil {
return out, metadata, err
}
response, ok := out.RawResponse.(*Response)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type: %T", out.RawResponse)
}
if !strings.HasPrefix(response.Proto, "HTTP") {
return out, metadata, &MinimumProtocolError{
proto: response.Proto,
expectedProtoMajor: r.ProtoMajor,
expectedProtoMinor: r.ProtoMinor,
}
}
if response.ProtoMajor < r.ProtoMajor || response.ProtoMinor < r.ProtoMinor {
return out, metadata, &MinimumProtocolError{
proto: response.Proto,
expectedProtoMajor: r.ProtoMajor,
expectedProtoMinor: r.ProtoMinor,
}
}
return out, metadata, err
}

View File

@ -130,14 +130,20 @@ func (r *Request) SetStream(reader io.Reader) (rc *Request, err error) {
func (r *Request) Build(ctx context.Context) *http.Request {
req := r.Request.Clone(ctx)
if r.stream != nil {
req.Body = iointernal.NewSafeReadCloser(ioutil.NopCloser(r.stream))
} else {
// we update the content-length to 0,
// if request stream was not set.
if r.stream == nil && req.ContentLength == -1 {
req.ContentLength = 0
}
switch stream := r.stream.(type) {
case *io.PipeReader:
req.Body = ioutil.NopCloser(stream)
req.ContentLength = -1
default:
if r.stream != nil {
req.Body = iointernal.NewSafeReadCloser(ioutil.NopCloser(stream))
}
}
return req
}