fix: update lego.
This commit is contained in:
parent
b893374dc1
commit
c17de070fb
432 changed files with 182 additions and 259514 deletions
35
vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/build.go
generated
vendored
35
vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/build.go
generated
vendored
|
@ -1,35 +0,0 @@
|
|||
// Package ec2query provides serialization of AWS EC2 requests and responses.
|
||||
package ec2query
|
||||
|
||||
//go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/ec2.json build_test.go
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/query/queryutil"
|
||||
)
|
||||
|
||||
// BuildHandler is a named request handler for building ec2query protocol requests
|
||||
var BuildHandler = request.NamedHandler{Name: "awssdk.ec2query.Build", Fn: Build}
|
||||
|
||||
// Build builds a request for the EC2 protocol.
|
||||
func Build(r *request.Request) {
|
||||
body := url.Values{
|
||||
"Action": {r.Operation.Name},
|
||||
"Version": {r.ClientInfo.APIVersion},
|
||||
}
|
||||
if err := queryutil.Parse(body, r.Params, true); err != nil {
|
||||
r.Error = awserr.New("SerializationError", "failed encoding EC2 Query request", err)
|
||||
}
|
||||
|
||||
if !r.IsPresigned() {
|
||||
r.HTTPRequest.Method = "POST"
|
||||
r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
|
||||
r.SetBufferBody([]byte(body.Encode()))
|
||||
} else { // This is a pre-signed request
|
||||
r.HTTPRequest.Method = "GET"
|
||||
r.HTTPRequest.URL.RawQuery = body.Encode()
|
||||
}
|
||||
}
|
63
vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/unmarshal.go
generated
vendored
63
vendor/github.com/aws/aws-sdk-go/private/protocol/ec2query/unmarshal.go
generated
vendored
|
@ -1,63 +0,0 @@
|
|||
package ec2query
|
||||
|
||||
//go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/ec2.json unmarshal_test.go
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"io"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil"
|
||||
)
|
||||
|
||||
// UnmarshalHandler is a named request handler for unmarshaling ec2query protocol requests
|
||||
var UnmarshalHandler = request.NamedHandler{Name: "awssdk.ec2query.Unmarshal", Fn: Unmarshal}
|
||||
|
||||
// UnmarshalMetaHandler is a named request handler for unmarshaling ec2query protocol request metadata
|
||||
var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.ec2query.UnmarshalMeta", Fn: UnmarshalMeta}
|
||||
|
||||
// UnmarshalErrorHandler is a named request handler for unmarshaling ec2query protocol request errors
|
||||
var UnmarshalErrorHandler = request.NamedHandler{Name: "awssdk.ec2query.UnmarshalError", Fn: UnmarshalError}
|
||||
|
||||
// Unmarshal unmarshals a response body for the EC2 protocol.
|
||||
func Unmarshal(r *request.Request) {
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
if r.DataFilled() {
|
||||
decoder := xml.NewDecoder(r.HTTPResponse.Body)
|
||||
err := xmlutil.UnmarshalXML(r.Data, decoder, "")
|
||||
if err != nil {
|
||||
r.Error = awserr.New("SerializationError", "failed decoding EC2 Query response", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalMeta unmarshals response headers for the EC2 protocol.
|
||||
func UnmarshalMeta(r *request.Request) {
|
||||
// TODO implement unmarshaling of request IDs
|
||||
}
|
||||
|
||||
type xmlErrorResponse struct {
|
||||
XMLName xml.Name `xml:"Response"`
|
||||
Code string `xml:"Errors>Error>Code"`
|
||||
Message string `xml:"Errors>Error>Message"`
|
||||
RequestID string `xml:"RequestID"`
|
||||
}
|
||||
|
||||
// UnmarshalError unmarshals a response error for the EC2 protocol.
|
||||
func UnmarshalError(r *request.Request) {
|
||||
defer r.HTTPResponse.Body.Close()
|
||||
|
||||
resp := &xmlErrorResponse{}
|
||||
err := xml.NewDecoder(r.HTTPResponse.Body).Decode(resp)
|
||||
if err != nil && err != io.EOF {
|
||||
r.Error = awserr.New("SerializationError", "failed decoding EC2 Query error response", err)
|
||||
} else {
|
||||
r.Error = awserr.NewRequestFailure(
|
||||
awserr.New(resp.Code, resp.Message, nil),
|
||||
r.HTTPResponse.StatusCode,
|
||||
resp.RequestID,
|
||||
)
|
||||
}
|
||||
}
|
12998
vendor/github.com/aws/aws-sdk-go/service/dynamodb/api.go
generated
vendored
12998
vendor/github.com/aws/aws-sdk-go/service/dynamodb/api.go
generated
vendored
File diff suppressed because it is too large
Load diff
109
vendor/github.com/aws/aws-sdk-go/service/dynamodb/customizations.go
generated
vendored
109
vendor/github.com/aws/aws-sdk-go/service/dynamodb/customizations.go
generated
vendored
|
@ -1,109 +0,0 @@
|
|||
package dynamodb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"hash/crc32"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
)
|
||||
|
||||
type retryer struct {
|
||||
client.DefaultRetryer
|
||||
}
|
||||
|
||||
func (d retryer) RetryRules(r *request.Request) time.Duration {
|
||||
delay := time.Duration(math.Pow(2, float64(r.RetryCount))) * 50
|
||||
return delay * time.Millisecond
|
||||
}
|
||||
|
||||
func init() {
|
||||
initClient = func(c *client.Client) {
|
||||
if c.Config.Retryer == nil {
|
||||
// Only override the retryer with a custom one if the config
|
||||
// does not already contain a retryer
|
||||
setCustomRetryer(c)
|
||||
}
|
||||
|
||||
c.Handlers.Build.PushBack(disableCompression)
|
||||
c.Handlers.Unmarshal.PushFront(validateCRC32)
|
||||
}
|
||||
}
|
||||
|
||||
func setCustomRetryer(c *client.Client) {
|
||||
maxRetries := aws.IntValue(c.Config.MaxRetries)
|
||||
if c.Config.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries {
|
||||
maxRetries = 10
|
||||
}
|
||||
|
||||
c.Retryer = retryer{
|
||||
DefaultRetryer: client.DefaultRetryer{
|
||||
NumMaxRetries: maxRetries,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func drainBody(b io.ReadCloser, length int64) (out *bytes.Buffer, err error) {
|
||||
if length < 0 {
|
||||
length = 0
|
||||
}
|
||||
buf := bytes.NewBuffer(make([]byte, 0, length))
|
||||
|
||||
if _, err = buf.ReadFrom(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = b.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func disableCompression(r *request.Request) {
|
||||
r.HTTPRequest.Header.Set("Accept-Encoding", "identity")
|
||||
}
|
||||
|
||||
func validateCRC32(r *request.Request) {
|
||||
if r.Error != nil {
|
||||
return // already have an error, no need to verify CRC
|
||||
}
|
||||
|
||||
// Checksum validation is off, skip
|
||||
if aws.BoolValue(r.Config.DisableComputeChecksums) {
|
||||
return
|
||||
}
|
||||
|
||||
// Try to get CRC from response
|
||||
header := r.HTTPResponse.Header.Get("X-Amz-Crc32")
|
||||
if header == "" {
|
||||
return // No header, skip
|
||||
}
|
||||
|
||||
expected, err := strconv.ParseUint(header, 10, 32)
|
||||
if err != nil {
|
||||
return // Could not determine CRC value, skip
|
||||
}
|
||||
|
||||
buf, err := drainBody(r.HTTPResponse.Body, r.HTTPResponse.ContentLength)
|
||||
if err != nil { // failed to read the response body, skip
|
||||
return
|
||||
}
|
||||
|
||||
// Reset body for subsequent reads
|
||||
r.HTTPResponse.Body = ioutil.NopCloser(bytes.NewReader(buf.Bytes()))
|
||||
|
||||
// Compute the CRC checksum
|
||||
crc := crc32.ChecksumIEEE(buf.Bytes())
|
||||
|
||||
if crc != uint32(expected) {
|
||||
// CRC does not match, set a retryable error
|
||||
r.Retryable = aws.Bool(true)
|
||||
r.Error = awserr.New("CRC32CheckFailed", "CRC32 integrity check failed", nil)
|
||||
}
|
||||
}
|
45
vendor/github.com/aws/aws-sdk-go/service/dynamodb/doc.go
generated
vendored
45
vendor/github.com/aws/aws-sdk-go/service/dynamodb/doc.go
generated
vendored
|
@ -1,45 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package dynamodb provides the client and types for making API
|
||||
// requests to Amazon DynamoDB.
|
||||
//
|
||||
// Amazon DynamoDB is a fully managed NoSQL database service that provides fast
|
||||
// and predictable performance with seamless scalability. DynamoDB lets you
|
||||
// offload the administrative burdens of operating and scaling a distributed
|
||||
// database, so that you don't have to worry about hardware provisioning, setup
|
||||
// and configuration, replication, software patching, or cluster scaling.
|
||||
//
|
||||
// With DynamoDB, you can create database tables that can store and retrieve
|
||||
// any amount of data, and serve any level of request traffic. You can scale
|
||||
// up or scale down your tables' throughput capacity without downtime or performance
|
||||
// degradation, and use the AWS Management Console to monitor resource utilization
|
||||
// and performance metrics.
|
||||
//
|
||||
// DynamoDB automatically spreads the data and traffic for your tables over
|
||||
// a sufficient number of servers to handle your throughput and storage requirements,
|
||||
// while maintaining consistent and fast performance. All of your data is stored
|
||||
// on solid state disks (SSDs) and automatically replicated across multiple
|
||||
// Availability Zones in an AWS region, providing built-in high availability
|
||||
// and data durability.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/dynamodb-2012-08-10 for more information on this service.
|
||||
//
|
||||
// See dynamodb package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact Amazon DynamoDB with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
// See the SDK's documentation for more information on how to use the SDK.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/
|
||||
//
|
||||
// See aws.Config documentation for more information on configuring SDK clients.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
|
||||
//
|
||||
// See the Amazon DynamoDB client DynamoDB for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/#New
|
||||
package dynamodb
|
27
vendor/github.com/aws/aws-sdk-go/service/dynamodb/doc_custom.go
generated
vendored
27
vendor/github.com/aws/aws-sdk-go/service/dynamodb/doc_custom.go
generated
vendored
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
AttributeValue Marshaling and Unmarshaling Helpers
|
||||
|
||||
Utility helpers to marshal and unmarshal AttributeValue to and
|
||||
from Go types can be found in the dynamodbattribute sub package. This package
|
||||
provides has specialized functions for the common ways of working with
|
||||
AttributeValues. Such as map[string]*AttributeValue, []*AttributeValue, and
|
||||
directly with *AttributeValue. This is helpful for marshaling Go types for API
|
||||
operations such as PutItem, and unmarshaling Query and Scan APIs' responses.
|
||||
|
||||
See the dynamodbattribute package documentation for more information.
|
||||
https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/dynamodbattribute/
|
||||
|
||||
Expression Builders
|
||||
|
||||
The expression package provides utility types and functions to build DynamoDB
|
||||
expression for type safe construction of API ExpressionAttributeNames, and
|
||||
ExpressionAttribute Values.
|
||||
|
||||
The package represents the various DynamoDB Expressions as structs named
|
||||
accordingly. For example, ConditionBuilder represents a DynamoDB Condition
|
||||
Expression, an UpdateBuilder represents a DynamoDB Update Expression, and so on.
|
||||
|
||||
See the expression package documentation for more information.
|
||||
https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/expression/
|
||||
*/
|
||||
package dynamodb
|
443
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/converter.go
generated
vendored
443
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/converter.go
generated
vendored
|
@ -1,443 +0,0 @@
|
|||
package dynamodbattribute
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/dynamodb"
|
||||
)
|
||||
|
||||
// ConvertToMap accepts a map[string]interface{} or struct and converts it to a
|
||||
// map[string]*dynamodb.AttributeValue.
|
||||
//
|
||||
// If in contains any structs, it is first JSON encoded/decoded it to convert it
|
||||
// to a map[string]interface{}, so `json` struct tags are respected.
|
||||
//
|
||||
// Deprecated: Use MarshalMap instead
|
||||
func ConvertToMap(in interface{}) (item map[string]*dynamodb.AttributeValue, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if e, ok := r.(runtime.Error); ok {
|
||||
err = e
|
||||
} else if s, ok := r.(string); ok {
|
||||
err = fmt.Errorf(s)
|
||||
} else {
|
||||
err = r.(error)
|
||||
}
|
||||
item = nil
|
||||
}
|
||||
}()
|
||||
|
||||
if in == nil {
|
||||
return nil, awserr.New("SerializationError",
|
||||
"in must be a map[string]interface{} or struct, got <nil>", nil)
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(in)
|
||||
if v.Kind() != reflect.Struct && !(v.Kind() == reflect.Map && v.Type().Key().Kind() == reflect.String) {
|
||||
return nil, awserr.New("SerializationError",
|
||||
fmt.Sprintf("in must be a map[string]interface{} or struct, got %s",
|
||||
v.Type().String()),
|
||||
nil)
|
||||
}
|
||||
|
||||
if isTyped(reflect.TypeOf(in)) {
|
||||
var out map[string]interface{}
|
||||
in = convertToUntyped(in, out)
|
||||
}
|
||||
|
||||
item = make(map[string]*dynamodb.AttributeValue)
|
||||
for k, v := range in.(map[string]interface{}) {
|
||||
item[k] = convertTo(v)
|
||||
}
|
||||
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// ConvertFromMap accepts a map[string]*dynamodb.AttributeValue and converts it to a
|
||||
// map[string]interface{} or struct.
|
||||
//
|
||||
// If v points to a struct, the result is first converted it to a
|
||||
// map[string]interface{}, then JSON encoded/decoded it to convert to a struct,
|
||||
// so `json` struct tags are respected.
|
||||
//
|
||||
// Deprecated: Use UnmarshalMap instead
|
||||
func ConvertFromMap(item map[string]*dynamodb.AttributeValue, v interface{}) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if e, ok := r.(runtime.Error); ok {
|
||||
err = e
|
||||
} else if s, ok := r.(string); ok {
|
||||
err = fmt.Errorf(s)
|
||||
} else {
|
||||
err = r.(error)
|
||||
}
|
||||
item = nil
|
||||
}
|
||||
}()
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.Kind() != reflect.Ptr || rv.IsNil() {
|
||||
return awserr.New("SerializationError",
|
||||
fmt.Sprintf("v must be a non-nil pointer to a map[string]interface{} or struct, got %s",
|
||||
rv.Type()),
|
||||
nil)
|
||||
}
|
||||
if rv.Elem().Kind() != reflect.Struct && !(rv.Elem().Kind() == reflect.Map && rv.Elem().Type().Key().Kind() == reflect.String) {
|
||||
return awserr.New("SerializationError",
|
||||
fmt.Sprintf("v must be a non-nil pointer to a map[string]interface{} or struct, got %s",
|
||||
rv.Type()),
|
||||
nil)
|
||||
}
|
||||
|
||||
m := make(map[string]interface{})
|
||||
for k, v := range item {
|
||||
m[k] = convertFrom(v)
|
||||
}
|
||||
|
||||
if isTyped(reflect.TypeOf(v)) {
|
||||
err = convertToTyped(m, v)
|
||||
} else {
|
||||
rv.Elem().Set(reflect.ValueOf(m))
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// ConvertToList accepts an array or slice and converts it to a
|
||||
// []*dynamodb.AttributeValue.
|
||||
//
|
||||
// Converting []byte fields to dynamodb.AttributeValue are only currently supported
|
||||
// if the input is a map[string]interface{} type. []byte within typed structs are not
|
||||
// converted correctly and are converted into base64 strings. This is a known bug,
|
||||
// and will be fixed in a later release.
|
||||
//
|
||||
// If in contains any structs, it is first JSON encoded/decoded it to convert it
|
||||
// to a []interface{}, so `json` struct tags are respected.
|
||||
//
|
||||
// Deprecated: Use MarshalList instead
|
||||
func ConvertToList(in interface{}) (item []*dynamodb.AttributeValue, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if e, ok := r.(runtime.Error); ok {
|
||||
err = e
|
||||
} else if s, ok := r.(string); ok {
|
||||
err = fmt.Errorf(s)
|
||||
} else {
|
||||
err = r.(error)
|
||||
}
|
||||
item = nil
|
||||
}
|
||||
}()
|
||||
|
||||
if in == nil {
|
||||
return nil, awserr.New("SerializationError",
|
||||
"in must be an array or slice, got <nil>",
|
||||
nil)
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(in)
|
||||
if v.Kind() != reflect.Array && v.Kind() != reflect.Slice {
|
||||
return nil, awserr.New("SerializationError",
|
||||
fmt.Sprintf("in must be an array or slice, got %s",
|
||||
v.Type().String()),
|
||||
nil)
|
||||
}
|
||||
|
||||
if isTyped(reflect.TypeOf(in)) {
|
||||
var out []interface{}
|
||||
in = convertToUntyped(in, out)
|
||||
}
|
||||
|
||||
item = make([]*dynamodb.AttributeValue, 0, len(in.([]interface{})))
|
||||
for _, v := range in.([]interface{}) {
|
||||
item = append(item, convertTo(v))
|
||||
}
|
||||
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// ConvertFromList accepts a []*dynamodb.AttributeValue and converts it to an array or
|
||||
// slice.
|
||||
//
|
||||
// If v contains any structs, the result is first converted it to a
|
||||
// []interface{}, then JSON encoded/decoded it to convert to a typed array or
|
||||
// slice, so `json` struct tags are respected.
|
||||
//
|
||||
// Deprecated: Use UnmarshalList instead
|
||||
func ConvertFromList(item []*dynamodb.AttributeValue, v interface{}) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if e, ok := r.(runtime.Error); ok {
|
||||
err = e
|
||||
} else if s, ok := r.(string); ok {
|
||||
err = fmt.Errorf(s)
|
||||
} else {
|
||||
err = r.(error)
|
||||
}
|
||||
item = nil
|
||||
}
|
||||
}()
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.Kind() != reflect.Ptr || rv.IsNil() {
|
||||
return awserr.New("SerializationError",
|
||||
fmt.Sprintf("v must be a non-nil pointer to an array or slice, got %s",
|
||||
rv.Type()),
|
||||
nil)
|
||||
}
|
||||
if rv.Elem().Kind() != reflect.Array && rv.Elem().Kind() != reflect.Slice {
|
||||
return awserr.New("SerializationError",
|
||||
fmt.Sprintf("v must be a non-nil pointer to an array or slice, got %s",
|
||||
rv.Type()),
|
||||
nil)
|
||||
}
|
||||
|
||||
l := make([]interface{}, 0, len(item))
|
||||
for _, v := range item {
|
||||
l = append(l, convertFrom(v))
|
||||
}
|
||||
|
||||
if isTyped(reflect.TypeOf(v)) {
|
||||
err = convertToTyped(l, v)
|
||||
} else {
|
||||
rv.Elem().Set(reflect.ValueOf(l))
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// ConvertTo accepts any interface{} and converts it to a *dynamodb.AttributeValue.
|
||||
//
|
||||
// If in contains any structs, it is first JSON encoded/decoded it to convert it
|
||||
// to a interface{}, so `json` struct tags are respected.
|
||||
//
|
||||
// Deprecated: Use Marshal instead
|
||||
func ConvertTo(in interface{}) (item *dynamodb.AttributeValue, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if e, ok := r.(runtime.Error); ok {
|
||||
err = e
|
||||
} else if s, ok := r.(string); ok {
|
||||
err = fmt.Errorf(s)
|
||||
} else {
|
||||
err = r.(error)
|
||||
}
|
||||
item = nil
|
||||
}
|
||||
}()
|
||||
|
||||
if in != nil && isTyped(reflect.TypeOf(in)) {
|
||||
var out interface{}
|
||||
in = convertToUntyped(in, out)
|
||||
}
|
||||
|
||||
item = convertTo(in)
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// ConvertFrom accepts a *dynamodb.AttributeValue and converts it to any interface{}.
|
||||
//
|
||||
// If v contains any structs, the result is first converted it to a interface{},
|
||||
// then JSON encoded/decoded it to convert to a struct, so `json` struct tags
|
||||
// are respected.
|
||||
//
|
||||
// Deprecated: Use Unmarshal instead
|
||||
func ConvertFrom(item *dynamodb.AttributeValue, v interface{}) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if e, ok := r.(runtime.Error); ok {
|
||||
err = e
|
||||
} else if s, ok := r.(string); ok {
|
||||
err = fmt.Errorf(s)
|
||||
} else {
|
||||
err = r.(error)
|
||||
}
|
||||
item = nil
|
||||
}
|
||||
}()
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.Kind() != reflect.Ptr || rv.IsNil() {
|
||||
return awserr.New("SerializationError",
|
||||
fmt.Sprintf("v must be a non-nil pointer to an interface{} or struct, got %s",
|
||||
rv.Type()),
|
||||
nil)
|
||||
}
|
||||
if rv.Elem().Kind() != reflect.Interface && rv.Elem().Kind() != reflect.Struct {
|
||||
return awserr.New("SerializationError",
|
||||
fmt.Sprintf("v must be a non-nil pointer to an interface{} or struct, got %s",
|
||||
rv.Type()),
|
||||
nil)
|
||||
}
|
||||
|
||||
res := convertFrom(item)
|
||||
|
||||
if isTyped(reflect.TypeOf(v)) {
|
||||
err = convertToTyped(res, v)
|
||||
} else if res != nil {
|
||||
rv.Elem().Set(reflect.ValueOf(res))
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func isTyped(v reflect.Type) bool {
|
||||
switch v.Kind() {
|
||||
case reflect.Struct:
|
||||
return true
|
||||
case reflect.Array, reflect.Slice:
|
||||
if isTyped(v.Elem()) {
|
||||
return true
|
||||
}
|
||||
case reflect.Map:
|
||||
if isTyped(v.Key()) {
|
||||
return true
|
||||
}
|
||||
if isTyped(v.Elem()) {
|
||||
return true
|
||||
}
|
||||
case reflect.Ptr:
|
||||
return isTyped(v.Elem())
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func convertToUntyped(in, out interface{}) interface{} {
|
||||
b, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
decoder := json.NewDecoder(bytes.NewReader(b))
|
||||
decoder.UseNumber()
|
||||
err = decoder.Decode(&out)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func convertToTyped(in, out interface{}) error {
|
||||
b, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
decoder := json.NewDecoder(bytes.NewReader(b))
|
||||
return decoder.Decode(&out)
|
||||
}
|
||||
|
||||
func convertTo(in interface{}) *dynamodb.AttributeValue {
|
||||
a := &dynamodb.AttributeValue{}
|
||||
|
||||
if in == nil {
|
||||
a.NULL = new(bool)
|
||||
*a.NULL = true
|
||||
return a
|
||||
}
|
||||
|
||||
if m, ok := in.(map[string]interface{}); ok {
|
||||
a.M = make(map[string]*dynamodb.AttributeValue)
|
||||
for k, v := range m {
|
||||
a.M[k] = convertTo(v)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(in)
|
||||
switch v.Kind() {
|
||||
case reflect.Bool:
|
||||
a.BOOL = new(bool)
|
||||
*a.BOOL = v.Bool()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
a.N = new(string)
|
||||
*a.N = strconv.FormatInt(v.Int(), 10)
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
a.N = new(string)
|
||||
*a.N = strconv.FormatUint(v.Uint(), 10)
|
||||
case reflect.Float32, reflect.Float64:
|
||||
a.N = new(string)
|
||||
*a.N = strconv.FormatFloat(v.Float(), 'f', -1, 64)
|
||||
case reflect.String:
|
||||
if n, ok := in.(json.Number); ok {
|
||||
a.N = new(string)
|
||||
*a.N = n.String()
|
||||
} else {
|
||||
a.S = new(string)
|
||||
*a.S = v.String()
|
||||
}
|
||||
case reflect.Slice:
|
||||
switch v.Type() {
|
||||
case reflect.TypeOf(([]byte)(nil)):
|
||||
a.B = v.Bytes()
|
||||
default:
|
||||
a.L = make([]*dynamodb.AttributeValue, v.Len())
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
a.L[i] = convertTo(v.Index(i).Interface())
|
||||
}
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("the type %s is not supported", v.Type().String()))
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func convertFrom(a *dynamodb.AttributeValue) interface{} {
|
||||
if a.S != nil {
|
||||
return *a.S
|
||||
}
|
||||
|
||||
if a.N != nil {
|
||||
// Number is tricky b/c we don't know which numeric type to use. Here we
|
||||
// simply try the different types from most to least restrictive.
|
||||
if n, err := strconv.ParseInt(*a.N, 10, 64); err == nil {
|
||||
return int(n)
|
||||
}
|
||||
if n, err := strconv.ParseUint(*a.N, 10, 64); err == nil {
|
||||
return uint(n)
|
||||
}
|
||||
n, err := strconv.ParseFloat(*a.N, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
if a.BOOL != nil {
|
||||
return *a.BOOL
|
||||
}
|
||||
|
||||
if a.NULL != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if a.M != nil {
|
||||
m := make(map[string]interface{})
|
||||
for k, v := range a.M {
|
||||
m[k] = convertFrom(v)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
if a.L != nil {
|
||||
l := make([]interface{}, len(a.L))
|
||||
for index, v := range a.L {
|
||||
l[index] = convertFrom(v)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
if a.B != nil {
|
||||
return a.B
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("%#v is not a supported dynamodb.AttributeValue", a))
|
||||
}
|
761
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/decode.go
generated
vendored
761
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/decode.go
generated
vendored
|
@ -1,761 +0,0 @@
|
|||
package dynamodbattribute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/dynamodb"
|
||||
)
|
||||
|
||||
// An Unmarshaler is an interface to provide custom unmarshaling of
|
||||
// AttributeValues. Use this to provide custom logic determining
|
||||
// how AttributeValues should be unmarshaled.
|
||||
// type ExampleUnmarshaler struct {
|
||||
// Value int
|
||||
// }
|
||||
//
|
||||
// func (u *exampleUnmarshaler) UnmarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error {
|
||||
// if av.N == nil {
|
||||
// return nil
|
||||
// }
|
||||
//
|
||||
// n, err := strconv.ParseInt(*av.N, 10, 0)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// u.Value = n
|
||||
// return nil
|
||||
// }
|
||||
type Unmarshaler interface {
|
||||
UnmarshalDynamoDBAttributeValue(*dynamodb.AttributeValue) error
|
||||
}
|
||||
|
||||
// Unmarshal will unmarshal DynamoDB AttributeValues to Go value types.
|
||||
// Both generic interface{} and concrete types are valid unmarshal
|
||||
// destination types.
|
||||
//
|
||||
// Unmarshal will allocate maps, slices, and pointers as needed to
|
||||
// unmarshal the AttributeValue into the provided type value.
|
||||
//
|
||||
// When unmarshaling AttributeValues into structs Unmarshal matches
|
||||
// the field names of the struct to the AttributeValue Map keys.
|
||||
// Initially it will look for exact field name matching, but will
|
||||
// fall back to case insensitive if not exact match is found.
|
||||
//
|
||||
// With the exception of omitempty, omitemptyelem, binaryset, numberset
|
||||
// and stringset all struct tags used by Marshal are also used by
|
||||
// Unmarshal.
|
||||
//
|
||||
// When decoding AttributeValues to interfaces Unmarshal will use the
|
||||
// following types.
|
||||
//
|
||||
// []byte, AV Binary (B)
|
||||
// [][]byte, AV Binary Set (BS)
|
||||
// bool, AV Boolean (BOOL)
|
||||
// []interface{}, AV List (L)
|
||||
// map[string]interface{}, AV Map (M)
|
||||
// float64, AV Number (N)
|
||||
// Number, AV Number (N) with UseNumber set
|
||||
// []float64, AV Number Set (NS)
|
||||
// []Number, AV Number Set (NS) with UseNumber set
|
||||
// string, AV String (S)
|
||||
// []string, AV String Set (SS)
|
||||
//
|
||||
// If the Decoder option, UseNumber is set numbers will be unmarshaled
|
||||
// as Number values instead of float64. Use this to maintain the original
|
||||
// string formating of the number as it was represented in the AttributeValue.
|
||||
// In addition provides additional opportunities to parse the number
|
||||
// string based on individual use cases.
|
||||
//
|
||||
// When unmarshaling any error that occurs will halt the unmarshal
|
||||
// and return the error.
|
||||
//
|
||||
// The output value provided must be a non-nil pointer
|
||||
func Unmarshal(av *dynamodb.AttributeValue, out interface{}) error {
|
||||
return NewDecoder().Decode(av, out)
|
||||
}
|
||||
|
||||
// UnmarshalMap is an alias for Unmarshal which unmarshals from
|
||||
// a map of AttributeValues.
|
||||
//
|
||||
// The output value provided must be a non-nil pointer
|
||||
func UnmarshalMap(m map[string]*dynamodb.AttributeValue, out interface{}) error {
|
||||
return NewDecoder().Decode(&dynamodb.AttributeValue{M: m}, out)
|
||||
}
|
||||
|
||||
// UnmarshalList is an alias for Unmarshal func which unmarshals
|
||||
// a slice of AttributeValues.
|
||||
//
|
||||
// The output value provided must be a non-nil pointer
|
||||
func UnmarshalList(l []*dynamodb.AttributeValue, out interface{}) error {
|
||||
return NewDecoder().Decode(&dynamodb.AttributeValue{L: l}, out)
|
||||
}
|
||||
|
||||
// UnmarshalListOfMaps is an alias for Unmarshal func which unmarshals a
|
||||
// slice of maps of attribute values.
|
||||
//
|
||||
// This is useful for when you need to unmarshal the Items from a DynamoDB
|
||||
// Query API call.
|
||||
//
|
||||
// The output value provided must be a non-nil pointer
|
||||
func UnmarshalListOfMaps(l []map[string]*dynamodb.AttributeValue, out interface{}) error {
|
||||
items := make([]*dynamodb.AttributeValue, len(l))
|
||||
for i, m := range l {
|
||||
items[i] = &dynamodb.AttributeValue{M: m}
|
||||
}
|
||||
|
||||
return UnmarshalList(items, out)
|
||||
}
|
||||
|
||||
// A Decoder provides unmarshaling AttributeValues to Go value types.
|
||||
type Decoder struct {
|
||||
MarshalOptions
|
||||
|
||||
// Instructs the decoder to decode AttributeValue Numbers as
|
||||
// Number type instead of float64 when the destination type
|
||||
// is interface{}. Similar to encoding/json.Number
|
||||
UseNumber bool
|
||||
}
|
||||
|
||||
// NewDecoder creates a new Decoder with default configuration. Use
|
||||
// the `opts` functional options to override the default configuration.
|
||||
func NewDecoder(opts ...func(*Decoder)) *Decoder {
|
||||
d := &Decoder{
|
||||
MarshalOptions: MarshalOptions{
|
||||
SupportJSONTags: true,
|
||||
},
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(d)
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
// Decode will unmarshal an AttributeValue into a Go value type. An error
|
||||
// will be return if the decoder is unable to unmarshal the AttributeValue
|
||||
// to the provide Go value type.
|
||||
//
|
||||
// The output value provided must be a non-nil pointer
|
||||
func (d *Decoder) Decode(av *dynamodb.AttributeValue, out interface{}, opts ...func(*Decoder)) error {
|
||||
v := reflect.ValueOf(out)
|
||||
if v.Kind() != reflect.Ptr || v.IsNil() || !v.IsValid() {
|
||||
return &InvalidUnmarshalError{Type: reflect.TypeOf(out)}
|
||||
}
|
||||
|
||||
return d.decode(av, v, tag{})
|
||||
}
|
||||
|
||||
var stringInterfaceMapType = reflect.TypeOf(map[string]interface{}(nil))
|
||||
var byteSliceType = reflect.TypeOf([]byte(nil))
|
||||
var byteSliceSlicetype = reflect.TypeOf([][]byte(nil))
|
||||
var numberType = reflect.TypeOf(Number(""))
|
||||
var timeType = reflect.TypeOf(time.Time{})
|
||||
|
||||
func (d *Decoder) decode(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
|
||||
var u Unmarshaler
|
||||
if av == nil || av.NULL != nil {
|
||||
u, v = indirect(v, true)
|
||||
if u != nil {
|
||||
return u.UnmarshalDynamoDBAttributeValue(av)
|
||||
}
|
||||
return d.decodeNull(v)
|
||||
}
|
||||
|
||||
u, v = indirect(v, false)
|
||||
if u != nil {
|
||||
return u.UnmarshalDynamoDBAttributeValue(av)
|
||||
}
|
||||
|
||||
switch {
|
||||
case len(av.B) != 0:
|
||||
return d.decodeBinary(av.B, v)
|
||||
case av.BOOL != nil:
|
||||
return d.decodeBool(av.BOOL, v)
|
||||
case len(av.BS) != 0:
|
||||
return d.decodeBinarySet(av.BS, v)
|
||||
case len(av.L) != 0:
|
||||
return d.decodeList(av.L, v)
|
||||
case len(av.M) != 0:
|
||||
return d.decodeMap(av.M, v)
|
||||
case av.N != nil:
|
||||
return d.decodeNumber(av.N, v, fieldTag)
|
||||
case len(av.NS) != 0:
|
||||
return d.decodeNumberSet(av.NS, v)
|
||||
case av.S != nil:
|
||||
return d.decodeString(av.S, v, fieldTag)
|
||||
case len(av.SS) != 0:
|
||||
return d.decodeStringSet(av.SS, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeBinary(b []byte, v reflect.Value) error {
|
||||
if v.Kind() == reflect.Interface {
|
||||
buf := make([]byte, len(b))
|
||||
copy(buf, b)
|
||||
v.Set(reflect.ValueOf(buf))
|
||||
return nil
|
||||
}
|
||||
|
||||
if v.Kind() != reflect.Slice && v.Kind() != reflect.Array {
|
||||
return &UnmarshalTypeError{Value: "binary", Type: v.Type()}
|
||||
}
|
||||
|
||||
if v.Type() == byteSliceType {
|
||||
// Optimization for []byte types
|
||||
if v.IsNil() || v.Cap() < len(b) {
|
||||
v.Set(reflect.MakeSlice(byteSliceType, len(b), len(b)))
|
||||
} else if v.Len() != len(b) {
|
||||
v.SetLen(len(b))
|
||||
}
|
||||
copy(v.Interface().([]byte), b)
|
||||
return nil
|
||||
}
|
||||
|
||||
switch v.Type().Elem().Kind() {
|
||||
case reflect.Uint8:
|
||||
// Fallback to reflection copy for type aliased of []byte type
|
||||
if v.Kind() != reflect.Array && (v.IsNil() || v.Cap() < len(b)) {
|
||||
v.Set(reflect.MakeSlice(v.Type(), len(b), len(b)))
|
||||
} else if v.Len() != len(b) {
|
||||
v.SetLen(len(b))
|
||||
}
|
||||
for i := 0; i < len(b); i++ {
|
||||
v.Index(i).SetUint(uint64(b[i]))
|
||||
}
|
||||
default:
|
||||
if v.Kind() == reflect.Array {
|
||||
switch v.Type().Elem().Kind() {
|
||||
case reflect.Uint8:
|
||||
reflect.Copy(v, reflect.ValueOf(b))
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "binary", Type: v.Type()}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
return &UnmarshalTypeError{Value: "binary", Type: v.Type()}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeBool(b *bool, v reflect.Value) error {
|
||||
switch v.Kind() {
|
||||
case reflect.Bool, reflect.Interface:
|
||||
v.Set(reflect.ValueOf(*b).Convert(v.Type()))
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "bool", Type: v.Type()}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeBinarySet(bs [][]byte, v reflect.Value) error {
|
||||
isArray := false
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Slice:
|
||||
// Make room for the slice elements if needed
|
||||
if v.IsNil() || v.Cap() < len(bs) {
|
||||
// What about if ignoring nil/empty values?
|
||||
v.Set(reflect.MakeSlice(v.Type(), 0, len(bs)))
|
||||
}
|
||||
case reflect.Array:
|
||||
// Limited to capacity of existing array.
|
||||
isArray = true
|
||||
case reflect.Interface:
|
||||
set := make([][]byte, len(bs))
|
||||
for i, b := range bs {
|
||||
if err := d.decodeBinary(b, reflect.ValueOf(&set[i]).Elem()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
v.Set(reflect.ValueOf(set))
|
||||
return nil
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "binary set", Type: v.Type()}
|
||||
}
|
||||
|
||||
for i := 0; i < v.Cap() && i < len(bs); i++ {
|
||||
if !isArray {
|
||||
v.SetLen(i + 1)
|
||||
}
|
||||
u, elem := indirect(v.Index(i), false)
|
||||
if u != nil {
|
||||
return u.UnmarshalDynamoDBAttributeValue(&dynamodb.AttributeValue{BS: bs})
|
||||
}
|
||||
if err := d.decodeBinary(bs[i], elem); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeNumber(n *string, v reflect.Value, fieldTag tag) error {
|
||||
switch v.Kind() {
|
||||
case reflect.Interface:
|
||||
i, err := d.decodeNumberToInterface(n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(i))
|
||||
return nil
|
||||
case reflect.String:
|
||||
if v.Type() == numberType { // Support Number value type
|
||||
v.Set(reflect.ValueOf(Number(*n)))
|
||||
return nil
|
||||
}
|
||||
v.Set(reflect.ValueOf(*n))
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
i, err := strconv.ParseInt(*n, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if v.OverflowInt(i) {
|
||||
return &UnmarshalTypeError{
|
||||
Value: fmt.Sprintf("number overflow, %s", *n),
|
||||
Type: v.Type(),
|
||||
}
|
||||
}
|
||||
v.SetInt(i)
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
i, err := strconv.ParseUint(*n, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if v.OverflowUint(i) {
|
||||
return &UnmarshalTypeError{
|
||||
Value: fmt.Sprintf("number overflow, %s", *n),
|
||||
Type: v.Type(),
|
||||
}
|
||||
}
|
||||
v.SetUint(i)
|
||||
case reflect.Float32, reflect.Float64:
|
||||
i, err := strconv.ParseFloat(*n, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if v.OverflowFloat(i) {
|
||||
return &UnmarshalTypeError{
|
||||
Value: fmt.Sprintf("number overflow, %s", *n),
|
||||
Type: v.Type(),
|
||||
}
|
||||
}
|
||||
v.SetFloat(i)
|
||||
default:
|
||||
if v.Type().ConvertibleTo(timeType) && fieldTag.AsUnixTime {
|
||||
t, err := decodeUnixTime(*n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(t).Convert(v.Type()))
|
||||
return nil
|
||||
}
|
||||
return &UnmarshalTypeError{Value: "number", Type: v.Type()}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeNumberToInterface(n *string) (interface{}, error) {
|
||||
if d.UseNumber {
|
||||
return Number(*n), nil
|
||||
}
|
||||
|
||||
// Default to float64 for all numbers
|
||||
return strconv.ParseFloat(*n, 64)
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeNumberSet(ns []*string, v reflect.Value) error {
|
||||
isArray := false
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Slice:
|
||||
// Make room for the slice elements if needed
|
||||
if v.IsNil() || v.Cap() < len(ns) {
|
||||
// What about if ignoring nil/empty values?
|
||||
v.Set(reflect.MakeSlice(v.Type(), 0, len(ns)))
|
||||
}
|
||||
case reflect.Array:
|
||||
// Limited to capacity of existing array.
|
||||
isArray = true
|
||||
case reflect.Interface:
|
||||
if d.UseNumber {
|
||||
set := make([]Number, len(ns))
|
||||
for i, n := range ns {
|
||||
if err := d.decodeNumber(n, reflect.ValueOf(&set[i]).Elem(), tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
v.Set(reflect.ValueOf(set))
|
||||
} else {
|
||||
set := make([]float64, len(ns))
|
||||
for i, n := range ns {
|
||||
if err := d.decodeNumber(n, reflect.ValueOf(&set[i]).Elem(), tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
v.Set(reflect.ValueOf(set))
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "number set", Type: v.Type()}
|
||||
}
|
||||
|
||||
for i := 0; i < v.Cap() && i < len(ns); i++ {
|
||||
if !isArray {
|
||||
v.SetLen(i + 1)
|
||||
}
|
||||
u, elem := indirect(v.Index(i), false)
|
||||
if u != nil {
|
||||
return u.UnmarshalDynamoDBAttributeValue(&dynamodb.AttributeValue{NS: ns})
|
||||
}
|
||||
if err := d.decodeNumber(ns[i], elem, tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeList(avList []*dynamodb.AttributeValue, v reflect.Value) error {
|
||||
isArray := false
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Slice:
|
||||
// Make room for the slice elements if needed
|
||||
if v.IsNil() || v.Cap() < len(avList) {
|
||||
// What about if ignoring nil/empty values?
|
||||
v.Set(reflect.MakeSlice(v.Type(), 0, len(avList)))
|
||||
}
|
||||
case reflect.Array:
|
||||
// Limited to capacity of existing array.
|
||||
isArray = true
|
||||
case reflect.Interface:
|
||||
s := make([]interface{}, len(avList))
|
||||
for i, av := range avList {
|
||||
if err := d.decode(av, reflect.ValueOf(&s[i]).Elem(), tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
v.Set(reflect.ValueOf(s))
|
||||
return nil
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "list", Type: v.Type()}
|
||||
}
|
||||
|
||||
// If v is not a slice, array
|
||||
for i := 0; i < v.Cap() && i < len(avList); i++ {
|
||||
if !isArray {
|
||||
v.SetLen(i + 1)
|
||||
}
|
||||
|
||||
if err := d.decode(avList[i], v.Index(i), tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeMap(avMap map[string]*dynamodb.AttributeValue, v reflect.Value) error {
|
||||
switch v.Kind() {
|
||||
case reflect.Map:
|
||||
t := v.Type()
|
||||
if t.Key().Kind() != reflect.String {
|
||||
return &UnmarshalTypeError{Value: "map string key", Type: t.Key()}
|
||||
}
|
||||
if v.IsNil() {
|
||||
v.Set(reflect.MakeMap(t))
|
||||
}
|
||||
case reflect.Struct:
|
||||
case reflect.Interface:
|
||||
v.Set(reflect.MakeMap(stringInterfaceMapType))
|
||||
v = v.Elem()
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "map", Type: v.Type()}
|
||||
}
|
||||
|
||||
if v.Kind() == reflect.Map {
|
||||
for k, av := range avMap {
|
||||
key := reflect.ValueOf(k)
|
||||
elem := reflect.New(v.Type().Elem()).Elem()
|
||||
if err := d.decode(av, elem, tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
v.SetMapIndex(key, elem)
|
||||
}
|
||||
} else if v.Kind() == reflect.Struct {
|
||||
fields := unionStructFields(v.Type(), d.MarshalOptions)
|
||||
for k, av := range avMap {
|
||||
if f, ok := fieldByName(fields, k); ok {
|
||||
fv := fieldByIndex(v, f.Index, func(v *reflect.Value) bool {
|
||||
v.Set(reflect.New(v.Type().Elem()))
|
||||
return true // to continue the loop.
|
||||
})
|
||||
if err := d.decode(av, fv, f.tag); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeNull(v reflect.Value) error {
|
||||
if v.IsValid() && v.CanSet() {
|
||||
v.Set(reflect.Zero(v.Type()))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeString(s *string, v reflect.Value, fieldTag tag) error {
|
||||
if fieldTag.AsString {
|
||||
return d.decodeNumber(s, v, fieldTag)
|
||||
}
|
||||
|
||||
// To maintain backwards compatibility with ConvertFrom family of methods which
|
||||
// converted strings to time.Time structs
|
||||
if v.Type().ConvertibleTo(timeType) {
|
||||
t, err := time.Parse(time.RFC3339, *s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Set(reflect.ValueOf(t).Convert(v.Type()))
|
||||
return nil
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.String:
|
||||
v.SetString(*s)
|
||||
case reflect.Interface:
|
||||
// Ensure type aliasing is handled properly
|
||||
v.Set(reflect.ValueOf(*s).Convert(v.Type()))
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "string", Type: v.Type()}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) decodeStringSet(ss []*string, v reflect.Value) error {
|
||||
isArray := false
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Slice:
|
||||
// Make room for the slice elements if needed
|
||||
if v.IsNil() || v.Cap() < len(ss) {
|
||||
v.Set(reflect.MakeSlice(v.Type(), 0, len(ss)))
|
||||
}
|
||||
case reflect.Array:
|
||||
// Limited to capacity of existing array.
|
||||
isArray = true
|
||||
case reflect.Interface:
|
||||
set := make([]string, len(ss))
|
||||
for i, s := range ss {
|
||||
if err := d.decodeString(s, reflect.ValueOf(&set[i]).Elem(), tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
v.Set(reflect.ValueOf(set))
|
||||
return nil
|
||||
default:
|
||||
return &UnmarshalTypeError{Value: "string set", Type: v.Type()}
|
||||
}
|
||||
|
||||
for i := 0; i < v.Cap() && i < len(ss); i++ {
|
||||
if !isArray {
|
||||
v.SetLen(i + 1)
|
||||
}
|
||||
u, elem := indirect(v.Index(i), false)
|
||||
if u != nil {
|
||||
return u.UnmarshalDynamoDBAttributeValue(&dynamodb.AttributeValue{SS: ss})
|
||||
}
|
||||
if err := d.decodeString(ss[i], elem, tag{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func decodeUnixTime(n string) (time.Time, error) {
|
||||
v, err := strconv.ParseInt(n, 10, 64)
|
||||
if err != nil {
|
||||
return time.Time{}, &UnmarshalError{
|
||||
Err: err, Value: n, Type: timeType,
|
||||
}
|
||||
}
|
||||
|
||||
return time.Unix(v, 0), nil
|
||||
}
|
||||
|
||||
// indirect will walk a value's interface or pointer value types. Returning
|
||||
// the final value or the value a unmarshaler is defined on.
|
||||
//
|
||||
// Based on the enoding/json type reflect value type indirection in Go Stdlib
|
||||
// https://golang.org/src/encoding/json/decode.go indirect func.
|
||||
func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, reflect.Value) {
|
||||
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
|
||||
v = v.Addr()
|
||||
}
|
||||
for {
|
||||
if v.Kind() == reflect.Interface && !v.IsNil() {
|
||||
e := v.Elem()
|
||||
if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) {
|
||||
v = e
|
||||
continue
|
||||
}
|
||||
}
|
||||
if v.Kind() != reflect.Ptr {
|
||||
break
|
||||
}
|
||||
if v.Elem().Kind() != reflect.Ptr && decodingNull && v.CanSet() {
|
||||
break
|
||||
}
|
||||
if v.IsNil() {
|
||||
v.Set(reflect.New(v.Type().Elem()))
|
||||
}
|
||||
if v.Type().NumMethod() > 0 {
|
||||
if u, ok := v.Interface().(Unmarshaler); ok {
|
||||
return u, reflect.Value{}
|
||||
}
|
||||
}
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
return nil, v
|
||||
}
|
||||
|
||||
// A Number represents a Attributevalue number literal.
|
||||
type Number string
|
||||
|
||||
// Float64 attempts to cast the number ot a float64, returning
|
||||
// the result of the case or error if the case failed.
|
||||
func (n Number) Float64() (float64, error) {
|
||||
return strconv.ParseFloat(string(n), 64)
|
||||
}
|
||||
|
||||
// Int64 attempts to cast the number ot a int64, returning
|
||||
// the result of the case or error if the case failed.
|
||||
func (n Number) Int64() (int64, error) {
|
||||
return strconv.ParseInt(string(n), 10, 64)
|
||||
}
|
||||
|
||||
// Uint64 attempts to cast the number ot a uint64, returning
|
||||
// the result of the case or error if the case failed.
|
||||
func (n Number) Uint64() (uint64, error) {
|
||||
return strconv.ParseUint(string(n), 10, 64)
|
||||
}
|
||||
|
||||
// String returns the raw number represented as a string
|
||||
func (n Number) String() string {
|
||||
return string(n)
|
||||
}
|
||||
|
||||
type emptyOrigError struct{}
|
||||
|
||||
func (e emptyOrigError) OrigErr() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// An UnmarshalTypeError is an error type representing a error
|
||||
// unmarshaling the AttributeValue's element to a Go value type.
|
||||
// Includes details about the AttributeValue type and Go value type.
|
||||
type UnmarshalTypeError struct {
|
||||
emptyOrigError
|
||||
Value string
|
||||
Type reflect.Type
|
||||
}
|
||||
|
||||
// Error returns the string representation of the error.
|
||||
// satisfying the error interface
|
||||
func (e *UnmarshalTypeError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", e.Code(), e.Message())
|
||||
}
|
||||
|
||||
// Code returns the code of the error, satisfying the awserr.Error
|
||||
// interface.
|
||||
func (e *UnmarshalTypeError) Code() string {
|
||||
return "UnmarshalTypeError"
|
||||
}
|
||||
|
||||
// Message returns the detailed message of the error, satisfying
|
||||
// the awserr.Error interface.
|
||||
func (e *UnmarshalTypeError) Message() string {
|
||||
return "cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String()
|
||||
}
|
||||
|
||||
// An InvalidUnmarshalError is an error type representing an invalid type
|
||||
// encountered while unmarshaling a AttributeValue to a Go value type.
|
||||
type InvalidUnmarshalError struct {
|
||||
emptyOrigError
|
||||
Type reflect.Type
|
||||
}
|
||||
|
||||
// Error returns the string representation of the error.
|
||||
// satisfying the error interface
|
||||
func (e *InvalidUnmarshalError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", e.Code(), e.Message())
|
||||
}
|
||||
|
||||
// Code returns the code of the error, satisfying the awserr.Error
|
||||
// interface.
|
||||
func (e *InvalidUnmarshalError) Code() string {
|
||||
return "InvalidUnmarshalError"
|
||||
}
|
||||
|
||||
// Message returns the detailed message of the error, satisfying
|
||||
// the awserr.Error interface.
|
||||
func (e *InvalidUnmarshalError) Message() string {
|
||||
if e.Type == nil {
|
||||
return "cannot unmarshal to nil value"
|
||||
}
|
||||
if e.Type.Kind() != reflect.Ptr {
|
||||
return "cannot unmarshal to non-pointer value, got " + e.Type.String()
|
||||
}
|
||||
return "cannot unmarshal to nil value, " + e.Type.String()
|
||||
}
|
||||
|
||||
// An UnmarshalError wraps an error that occured while unmarshaling a DynamoDB
|
||||
// AttributeValue element into a Go type. This is different from UnmarshalTypeError
|
||||
// in that it wraps the underlying error that occured.
|
||||
type UnmarshalError struct {
|
||||
Err error
|
||||
Value string
|
||||
Type reflect.Type
|
||||
}
|
||||
|
||||
// Error returns the string representation of the error.
|
||||
// satisfying the error interface.
|
||||
func (e *UnmarshalError) Error() string {
|
||||
return fmt.Sprintf("%s: %s\ncaused by: %v", e.Code(), e.Message(), e.Err)
|
||||
}
|
||||
|
||||
// OrigErr returns the original error that caused this issue.
|
||||
func (e UnmarshalError) OrigErr() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
// Code returns the code of the error, satisfying the awserr.Error
|
||||
// interface.
|
||||
func (e *UnmarshalError) Code() string {
|
||||
return "UnmarshalError"
|
||||
}
|
||||
|
||||
// Message returns the detailed message of the error, satisfying
|
||||
// the awserr.Error interface.
|
||||
func (e *UnmarshalError) Message() string {
|
||||
return fmt.Sprintf("cannot unmarshal %q into %s.",
|
||||
e.Value, e.Type.String())
|
||||
}
|
95
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/doc.go
generated
vendored
95
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/doc.go
generated
vendored
|
@ -1,95 +0,0 @@
|
|||
// Package dynamodbattribute provides marshaling and unmarshaling utilities to
|
||||
// convert between Go types and dynamodb.AttributeValues.
|
||||
//
|
||||
// These utilities allow you to marshal slices, maps, structs, and scalar values
|
||||
// to and from dynamodb.AttributeValue. These are useful when marshaling
|
||||
// Go value tyes to dynamodb.AttributeValue for DynamoDB requests, or
|
||||
// unmarshaling the dynamodb.AttributeValue back into a Go value type.
|
||||
//
|
||||
// AttributeValue Marshaling
|
||||
//
|
||||
// To marshal a Go type to a dynamodbAttributeValue you can use the Marshal
|
||||
// functions in the dynamodbattribute package. There are specialized versions
|
||||
// of these functions for collections of Attributevalue, such as maps and lists.
|
||||
//
|
||||
// The following example uses MarshalMap to convert the Record Go type to a
|
||||
// dynamodb.AttributeValue type and use the value to make a PutItem API request.
|
||||
//
|
||||
// type Record struct {
|
||||
// ID string
|
||||
// URLs []string
|
||||
// }
|
||||
//
|
||||
// //...
|
||||
//
|
||||
// r := Record{
|
||||
// ID: "ABC123",
|
||||
// URLs: []string{
|
||||
// "https://example.com/first/link",
|
||||
// "https://example.com/second/url",
|
||||
// },
|
||||
// }
|
||||
// av, err := dynamodbattribute.MarshalMap(r)
|
||||
// if err != nil {
|
||||
// panic(fmt.Sprintf("failed to DynamoDB marshal Record, %v", err))
|
||||
// }
|
||||
//
|
||||
// _, err = svc.PutItem(&dynamodb.PutItemInput{
|
||||
// TableName: aws.String(myTableName),
|
||||
// Item: av,
|
||||
// })
|
||||
// if err != nil {
|
||||
// panic(fmt.Sprintf("failed to put Record to DynamoDB, %v", err))
|
||||
// }
|
||||
//
|
||||
// AttributeValue Unmarshaling
|
||||
//
|
||||
// To unmarshal a dynamodb.AttributeValue to a Go type you can use the Unmarshal
|
||||
// functions in the dynamodbattribute package. There are specialized versions
|
||||
// of these functions for collections of Attributevalue, such as maps and lists.
|
||||
//
|
||||
// The following example will unmarshal the DynamoDB's Scan API operation. The
|
||||
// Items returned by the operation will be unmarshaled into the slice of Records
|
||||
// Go type.
|
||||
//
|
||||
// type Record struct {
|
||||
// ID string
|
||||
// URLs []string
|
||||
// }
|
||||
//
|
||||
// //...
|
||||
//
|
||||
// var records []Record
|
||||
//
|
||||
// // Use the ScanPages method to perform the scan with pagination. Use
|
||||
// // just Scan method to make the API call without pagination.
|
||||
// err := svc.ScanPages(&dynamodb.ScanInput{
|
||||
// TableName: aws.String(myTableName),
|
||||
// }, func(page *dynamodb.ScanOutput, last bool) bool {
|
||||
// recs := []Record{}
|
||||
//
|
||||
// err := dynamodbattribute.UnmarshalListOfMaps(page.Items, &recs)
|
||||
// if err != nil {
|
||||
// panic(fmt.Sprintf("failed to unmarshal Dynamodb Scan Items, %v", err))
|
||||
// }
|
||||
//
|
||||
// records = append(records, recs...)
|
||||
//
|
||||
// return true // keep paging
|
||||
// })
|
||||
//
|
||||
// The ConvertTo, ConvertToList, ConvertToMap, ConvertFrom, ConvertFromMap
|
||||
// and ConvertFromList methods have been deprecated. The Marshal and Unmarshal
|
||||
// functions should be used instead. The ConvertTo|From marshallers do not
|
||||
// support BinarySet, NumberSet, nor StringSets, and will incorrect marshal
|
||||
// binary data fields in structs as base64 strings.
|
||||
//
|
||||
// The Marshal and Unmarshal functions correct this behavior, and removes
|
||||
// the reliance on encoding.json. `json` struct tags are still supported. In
|
||||
// addition support for a new struct tag `dynamodbav` was added. Support for
|
||||
// the json.Marshaler and json.Unmarshaler interfaces have been removed and
|
||||
// replaced with have been replaced with dynamodbattribute.Marshaler and
|
||||
// dynamodbattribute.Unmarshaler interfaces.
|
||||
//
|
||||
// `time.Time` is marshaled as RFC3339 format.
|
||||
package dynamodbattribute
|
641
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/encode.go
generated
vendored
641
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/encode.go
generated
vendored
|
@ -1,641 +0,0 @@
|
|||
package dynamodbattribute
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/dynamodb"
|
||||
)
|
||||
|
||||
// An UnixTime provides aliasing of time.Time into a type that when marshaled
|
||||
// and unmarshaled with DynamoDB AttributeValues it will be done so as number
|
||||
// instead of string in seconds since January 1, 1970 UTC.
|
||||
//
|
||||
// This type is useful as an alternative to the struct tag `unixtime` when you
|
||||
// want to have your time value marshaled as Unix time in seconds intead of
|
||||
// the default time.RFC3339.
|
||||
//
|
||||
// Important to note that zero value time as unixtime is not 0 seconds
|
||||
// from January 1, 1970 UTC, but -62135596800. Which is seconds between
|
||||
// January 1, 0001 UTC, and January 1, 0001 UTC.
|
||||
type UnixTime time.Time
|
||||
|
||||
// MarshalDynamoDBAttributeValue implements the Marshaler interface so that
|
||||
// the UnixTime can be marshaled from to a DynamoDB AttributeValue number
|
||||
// value encoded in the number of seconds since January 1, 1970 UTC.
|
||||
func (e UnixTime) MarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error {
|
||||
t := time.Time(e)
|
||||
s := strconv.FormatInt(t.Unix(), 10)
|
||||
av.N = &s
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalDynamoDBAttributeValue implements the Unmarshaler interface so that
|
||||
// the UnixTime can be unmarshaled from a DynamoDB AttributeValue number representing
|
||||
// the number of seconds since January 1, 1970 UTC.
|
||||
//
|
||||
// If an error parsing the AttributeValue number occurs UnmarshalError will be
|
||||
// returned.
|
||||
func (e *UnixTime) UnmarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error {
|
||||
t, err := decodeUnixTime(aws.StringValue(av.N))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*e = UnixTime(t)
|
||||
return nil
|
||||
}
|
||||
|
||||
// A Marshaler is an interface to provide custom marshaling of Go value types
|
||||
// to AttributeValues. Use this to provide custom logic determining how a
|
||||
// Go Value type should be marshaled.
|
||||
//
|
||||
// type ExampleMarshaler struct {
|
||||
// Value int
|
||||
// }
|
||||
// func (m *ExampleMarshaler) MarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error {
|
||||
// n := fmt.Sprintf("%v", m.Value)
|
||||
// av.N = &n
|
||||
// return nil
|
||||
// }
|
||||
//
|
||||
type Marshaler interface {
|
||||
MarshalDynamoDBAttributeValue(*dynamodb.AttributeValue) error
|
||||
}
|
||||
|
||||
// Marshal will serialize the passed in Go value type into a DynamoDB AttributeValue
|
||||
// type. This value can be used in DynamoDB API operations to simplify marshaling
|
||||
// your Go value types into AttributeValues.
|
||||
//
|
||||
// Marshal will recursively transverse the passed in value marshaling its
|
||||
// contents into a AttributeValue. Marshal supports basic scalars
|
||||
// (int,uint,float,bool,string), maps, slices, and structs. Anonymous
|
||||
// nested types are flattened based on Go anonymous type visibility.
|
||||
//
|
||||
// Marshaling slices to AttributeValue will default to a List for all
|
||||
// types except for []byte and [][]byte. []byte will be marshaled as
|
||||
// Binary data (B), and [][]byte will be marshaled as binary data set
|
||||
// (BS).
|
||||
//
|
||||
// `dynamodbav` struct tag can be used to control how the value will be
|
||||
// marshaled into a AttributeValue.
|
||||
//
|
||||
// // Field is ignored
|
||||
// Field int `dynamodbav:"-"`
|
||||
//
|
||||
// // Field AttributeValue map key "myName"
|
||||
// Field int `dynamodbav:"myName"`
|
||||
//
|
||||
// // Field AttributeValue map key "myName", and
|
||||
// // Field is omitted if it is empty
|
||||
// Field int `dynamodbav:"myName,omitempty"`
|
||||
//
|
||||
// // Field AttributeValue map key "Field", and
|
||||
// // Field is omitted if it is empty
|
||||
// Field int `dynamodbav:",omitempty"`
|
||||
//
|
||||
// // Field's elems will be omitted if empty
|
||||
// // only valid for slices, and maps.
|
||||
// Field []string `dynamodbav:",omitemptyelem"`
|
||||
//
|
||||
// // Field will be marshaled as a AttributeValue string
|
||||
// // only value for number types, (int,uint,float)
|
||||
// Field int `dynamodbav:",string"`
|
||||
//
|
||||
// // Field will be marshaled as a binary set
|
||||
// Field [][]byte `dynamodbav:",binaryset"`
|
||||
//
|
||||
// // Field will be marshaled as a number set
|
||||
// Field []int `dynamodbav:",numberset"`
|
||||
//
|
||||
// // Field will be marshaled as a string set
|
||||
// Field []string `dynamodbav:",stringset"`
|
||||
//
|
||||
// // Field will be marshaled as Unix time number in seconds.
|
||||
// // This tag is only valid with time.Time typed struct fields.
|
||||
// // Important to note that zero value time as unixtime is not 0 seconds
|
||||
// // from January 1, 1970 UTC, but -62135596800. Which is seconds between
|
||||
// // January 1, 0001 UTC, and January 1, 0001 UTC.
|
||||
// Field time.Time `dynamodbav:",unixtime"`
|
||||
//
|
||||
// The omitempty tag is only used during Marshaling and is ignored for
|
||||
// Unmarshal. Any zero value or a value when marshaled results in a
|
||||
// AttributeValue NULL will be added to AttributeValue Maps during struct
|
||||
// marshal. The omitemptyelem tag works the same as omitempty except it
|
||||
// applies to maps and slices instead of struct fields, and will not be
|
||||
// included in the marshaled AttributeValue Map, List, or Set.
|
||||
//
|
||||
// For convenience and backwards compatibility with ConvertTo functions
|
||||
// json struct tags are supported by the Marshal and Unmarshal. If
|
||||
// both json and dynamodbav struct tags are provided the json tag will
|
||||
// be ignored in favor of dynamodbav.
|
||||
//
|
||||
// All struct fields and with anonymous fields, are marshaled unless the
|
||||
// any of the following conditions are meet.
|
||||
//
|
||||
// - the field is not exported
|
||||
// - json or dynamodbav field tag is "-"
|
||||
// - json or dynamodbav field tag specifies "omitempty", and is empty.
|
||||
//
|
||||
// Pointer and interfaces values encode as the value pointed to or contained
|
||||
// in the interface. A nil value encodes as the AttributeValue NULL value.
|
||||
//
|
||||
// Channel, complex, and function values are not encoded and will be skipped
|
||||
// when walking the value to be marshaled.
|
||||
//
|
||||
// When marshaling any error that occurs will halt the marshal and return
|
||||
// the error.
|
||||
//
|
||||
// Marshal cannot represent cyclic data structures and will not handle them.
|
||||
// Passing cyclic structures to Marshal will result in an infinite recursion.
|
||||
func Marshal(in interface{}) (*dynamodb.AttributeValue, error) {
|
||||
return NewEncoder().Encode(in)
|
||||
}
|
||||
|
||||
// MarshalMap is an alias for Marshal func which marshals Go value
|
||||
// type to a map of AttributeValues.
|
||||
//
|
||||
// This is useful for DynamoDB APIs such as PutItem.
|
||||
func MarshalMap(in interface{}) (map[string]*dynamodb.AttributeValue, error) {
|
||||
av, err := NewEncoder().Encode(in)
|
||||
if err != nil || av == nil || av.M == nil {
|
||||
return map[string]*dynamodb.AttributeValue{}, err
|
||||
}
|
||||
|
||||
return av.M, nil
|
||||
}
|
||||
|
||||
// MarshalList is an alias for Marshal func which marshals Go value
|
||||
// type to a slice of AttributeValues.
|
||||
func MarshalList(in interface{}) ([]*dynamodb.AttributeValue, error) {
|
||||
av, err := NewEncoder().Encode(in)
|
||||
if err != nil || av == nil || av.L == nil {
|
||||
return []*dynamodb.AttributeValue{}, err
|
||||
}
|
||||
|
||||
return av.L, nil
|
||||
}
|
||||
|
||||
// A MarshalOptions is a collection of options shared between marshaling
|
||||
// and unmarshaling
|
||||
type MarshalOptions struct {
|
||||
// States that the encoding/json struct tags should be supported.
|
||||
// if a `dynamodbav` struct tag is also provided the encoding/json
|
||||
// tag will be ignored.
|
||||
//
|
||||
// Enabled by default.
|
||||
SupportJSONTags bool
|
||||
}
|
||||
|
||||
// An Encoder provides marshaling Go value types to AttributeValues.
|
||||
type Encoder struct {
|
||||
MarshalOptions
|
||||
|
||||
// Empty strings, "", will be marked as NULL AttributeValue types.
|
||||
// Empty strings are not valid values for DynamoDB. Will not apply
|
||||
// to lists, sets, or maps. Use the struct tag `omitemptyelem`
|
||||
// to skip empty (zero) values in lists, sets and maps.
|
||||
//
|
||||
// Enabled by default.
|
||||
NullEmptyString bool
|
||||
}
|
||||
|
||||
// NewEncoder creates a new Encoder with default configuration. Use
|
||||
// the `opts` functional options to override the default configuration.
|
||||
func NewEncoder(opts ...func(*Encoder)) *Encoder {
|
||||
e := &Encoder{
|
||||
MarshalOptions: MarshalOptions{
|
||||
SupportJSONTags: true,
|
||||
},
|
||||
NullEmptyString: true,
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(e)
|
||||
}
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
// Encode will marshal a Go value type to an AttributeValue. Returning
|
||||
// the AttributeValue constructed or error.
|
||||
func (e *Encoder) Encode(in interface{}) (*dynamodb.AttributeValue, error) {
|
||||
av := &dynamodb.AttributeValue{}
|
||||
if err := e.encode(av, reflect.ValueOf(in), tag{}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return av, nil
|
||||
}
|
||||
|
||||
func fieldByIndex(v reflect.Value, index []int,
|
||||
OnEmbeddedNilStruct func(*reflect.Value) bool) reflect.Value {
|
||||
fv := v
|
||||
for i, x := range index {
|
||||
if i > 0 {
|
||||
if fv.Kind() == reflect.Ptr && fv.Type().Elem().Kind() == reflect.Struct {
|
||||
if fv.IsNil() && !OnEmbeddedNilStruct(&fv) {
|
||||
break
|
||||
}
|
||||
fv = fv.Elem()
|
||||
}
|
||||
}
|
||||
fv = fv.Field(x)
|
||||
}
|
||||
return fv
|
||||
}
|
||||
|
||||
func (e *Encoder) encode(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
|
||||
// We should check for omitted values first before dereferencing.
|
||||
if fieldTag.OmitEmpty && emptyValue(v) {
|
||||
encodeNull(av)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Handle both pointers and interface conversion into types
|
||||
v = valueElem(v)
|
||||
|
||||
if v.Kind() != reflect.Invalid {
|
||||
if used, err := tryMarshaler(av, v); used {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Invalid:
|
||||
encodeNull(av)
|
||||
case reflect.Struct:
|
||||
return e.encodeStruct(av, v, fieldTag)
|
||||
case reflect.Map:
|
||||
return e.encodeMap(av, v, fieldTag)
|
||||
case reflect.Slice, reflect.Array:
|
||||
return e.encodeSlice(av, v, fieldTag)
|
||||
case reflect.Chan, reflect.Func, reflect.UnsafePointer:
|
||||
// do nothing for unsupported types
|
||||
default:
|
||||
return e.encodeScalar(av, v, fieldTag)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encodeStruct(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
|
||||
// To maintain backwards compatibility with ConvertTo family of methods which
|
||||
// converted time.Time structs to strings
|
||||
if v.Type().ConvertibleTo(timeType) {
|
||||
var t time.Time
|
||||
t = v.Convert(timeType).Interface().(time.Time)
|
||||
if fieldTag.AsUnixTime {
|
||||
return UnixTime(t).MarshalDynamoDBAttributeValue(av)
|
||||
}
|
||||
s := t.Format(time.RFC3339Nano)
|
||||
av.S = &s
|
||||
return nil
|
||||
}
|
||||
|
||||
av.M = map[string]*dynamodb.AttributeValue{}
|
||||
fields := unionStructFields(v.Type(), e.MarshalOptions)
|
||||
for _, f := range fields {
|
||||
if f.Name == "" {
|
||||
return &InvalidMarshalError{msg: "map key cannot be empty"}
|
||||
}
|
||||
|
||||
found := true
|
||||
fv := fieldByIndex(v, f.Index, func(v *reflect.Value) bool {
|
||||
found = false
|
||||
return false // to break the loop.
|
||||
})
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
elem := &dynamodb.AttributeValue{}
|
||||
err := e.encode(elem, fv, f.tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
skip, err := keepOrOmitEmpty(f.OmitEmpty, elem, err)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if skip {
|
||||
continue
|
||||
}
|
||||
|
||||
av.M[f.Name] = elem
|
||||
}
|
||||
if len(av.M) == 0 {
|
||||
encodeNull(av)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encodeMap(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
|
||||
av.M = map[string]*dynamodb.AttributeValue{}
|
||||
for _, key := range v.MapKeys() {
|
||||
keyName := fmt.Sprint(key.Interface())
|
||||
if keyName == "" {
|
||||
return &InvalidMarshalError{msg: "map key cannot be empty"}
|
||||
}
|
||||
|
||||
elemVal := v.MapIndex(key)
|
||||
elem := &dynamodb.AttributeValue{}
|
||||
err := e.encode(elem, elemVal, tag{})
|
||||
skip, err := keepOrOmitEmpty(fieldTag.OmitEmptyElem, elem, err)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if skip {
|
||||
continue
|
||||
}
|
||||
|
||||
av.M[keyName] = elem
|
||||
}
|
||||
if len(av.M) == 0 {
|
||||
encodeNull(av)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encodeSlice(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
|
||||
switch v.Type().Elem().Kind() {
|
||||
case reflect.Uint8:
|
||||
slice := reflect.MakeSlice(byteSliceType, v.Len(), v.Len())
|
||||
reflect.Copy(slice, v)
|
||||
|
||||
b := slice.Bytes()
|
||||
if len(b) == 0 {
|
||||
encodeNull(av)
|
||||
return nil
|
||||
}
|
||||
av.B = append([]byte{}, b...)
|
||||
default:
|
||||
var elemFn func(dynamodb.AttributeValue) error
|
||||
|
||||
if fieldTag.AsBinSet || v.Type() == byteSliceSlicetype { // Binary Set
|
||||
av.BS = make([][]byte, 0, v.Len())
|
||||
elemFn = func(elem dynamodb.AttributeValue) error {
|
||||
if elem.B == nil {
|
||||
return &InvalidMarshalError{msg: "binary set must only contain non-nil byte slices"}
|
||||
}
|
||||
av.BS = append(av.BS, elem.B)
|
||||
return nil
|
||||
}
|
||||
} else if fieldTag.AsNumSet { // Number Set
|
||||
av.NS = make([]*string, 0, v.Len())
|
||||
elemFn = func(elem dynamodb.AttributeValue) error {
|
||||
if elem.N == nil {
|
||||
return &InvalidMarshalError{msg: "number set must only contain non-nil string numbers"}
|
||||
}
|
||||
av.NS = append(av.NS, elem.N)
|
||||
return nil
|
||||
}
|
||||
} else if fieldTag.AsStrSet { // String Set
|
||||
av.SS = make([]*string, 0, v.Len())
|
||||
elemFn = func(elem dynamodb.AttributeValue) error {
|
||||
if elem.S == nil {
|
||||
return &InvalidMarshalError{msg: "string set must only contain non-nil strings"}
|
||||
}
|
||||
av.SS = append(av.SS, elem.S)
|
||||
return nil
|
||||
}
|
||||
} else { // List
|
||||
av.L = make([]*dynamodb.AttributeValue, 0, v.Len())
|
||||
elemFn = func(elem dynamodb.AttributeValue) error {
|
||||
av.L = append(av.L, &elem)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if n, err := e.encodeList(v, fieldTag, elemFn); err != nil {
|
||||
return err
|
||||
} else if n == 0 {
|
||||
encodeNull(av)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encodeList(v reflect.Value, fieldTag tag, elemFn func(dynamodb.AttributeValue) error) (int, error) {
|
||||
count := 0
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
elem := dynamodb.AttributeValue{}
|
||||
err := e.encode(&elem, v.Index(i), tag{OmitEmpty: fieldTag.OmitEmptyElem})
|
||||
skip, err := keepOrOmitEmpty(fieldTag.OmitEmptyElem, &elem, err)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
} else if skip {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := elemFn(elem); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
count++
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encodeScalar(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
|
||||
if v.Type() == numberType {
|
||||
s := v.String()
|
||||
if fieldTag.AsString {
|
||||
av.S = &s
|
||||
} else {
|
||||
av.N = &s
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Bool:
|
||||
av.BOOL = new(bool)
|
||||
*av.BOOL = v.Bool()
|
||||
case reflect.String:
|
||||
if err := e.encodeString(av, v); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
// Fallback to encoding numbers, will return invalid type if not supported
|
||||
if err := e.encodeNumber(av, v); err != nil {
|
||||
return err
|
||||
}
|
||||
if fieldTag.AsString && av.NULL == nil && av.N != nil {
|
||||
av.S = av.N
|
||||
av.N = nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encodeNumber(av *dynamodb.AttributeValue, v reflect.Value) error {
|
||||
if used, err := tryMarshaler(av, v); used {
|
||||
return err
|
||||
}
|
||||
|
||||
var out string
|
||||
switch v.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
out = encodeInt(v.Int())
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
out = encodeUint(v.Uint())
|
||||
case reflect.Float32, reflect.Float64:
|
||||
out = encodeFloat(v.Float())
|
||||
default:
|
||||
return &unsupportedMarshalTypeError{Type: v.Type()}
|
||||
}
|
||||
|
||||
av.N = &out
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encodeString(av *dynamodb.AttributeValue, v reflect.Value) error {
|
||||
if used, err := tryMarshaler(av, v); used {
|
||||
return err
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.String:
|
||||
s := v.String()
|
||||
if len(s) == 0 && e.NullEmptyString {
|
||||
encodeNull(av)
|
||||
} else {
|
||||
av.S = &s
|
||||
}
|
||||
default:
|
||||
return &unsupportedMarshalTypeError{Type: v.Type()}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeInt(i int64) string {
|
||||
return strconv.FormatInt(i, 10)
|
||||
}
|
||||
func encodeUint(u uint64) string {
|
||||
return strconv.FormatUint(u, 10)
|
||||
}
|
||||
func encodeFloat(f float64) string {
|
||||
return strconv.FormatFloat(f, 'f', -1, 64)
|
||||
}
|
||||
func encodeNull(av *dynamodb.AttributeValue) {
|
||||
t := true
|
||||
*av = dynamodb.AttributeValue{NULL: &t}
|
||||
}
|
||||
|
||||
func valueElem(v reflect.Value) reflect.Value {
|
||||
switch v.Kind() {
|
||||
case reflect.Interface, reflect.Ptr:
|
||||
for v.Kind() == reflect.Interface || v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func emptyValue(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 tryMarshaler(av *dynamodb.AttributeValue, v reflect.Value) (bool, error) {
|
||||
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
|
||||
v = v.Addr()
|
||||
}
|
||||
|
||||
if v.Type().NumMethod() == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if m, ok := v.Interface().(Marshaler); ok {
|
||||
return true, m.MarshalDynamoDBAttributeValue(av)
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func keepOrOmitEmpty(omitEmpty bool, av *dynamodb.AttributeValue, err error) (bool, error) {
|
||||
if err != nil {
|
||||
if _, ok := err.(*unsupportedMarshalTypeError); ok {
|
||||
return true, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
if av.NULL != nil && omitEmpty {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// An InvalidMarshalError is an error type representing an error
|
||||
// occurring when marshaling a Go value type to an AttributeValue.
|
||||
type InvalidMarshalError struct {
|
||||
emptyOrigError
|
||||
msg string
|
||||
}
|
||||
|
||||
// Error returns the string representation of the error.
|
||||
// satisfying the error interface
|
||||
func (e *InvalidMarshalError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", e.Code(), e.Message())
|
||||
}
|
||||
|
||||
// Code returns the code of the error, satisfying the awserr.Error
|
||||
// interface.
|
||||
func (e *InvalidMarshalError) Code() string {
|
||||
return "InvalidMarshalError"
|
||||
}
|
||||
|
||||
// Message returns the detailed message of the error, satisfying
|
||||
// the awserr.Error interface.
|
||||
func (e *InvalidMarshalError) Message() string {
|
||||
return e.msg
|
||||
}
|
||||
|
||||
// An unsupportedMarshalTypeError represents a Go value type
|
||||
// which cannot be marshaled into an AttributeValue and should
|
||||
// be skipped by the marshaler.
|
||||
type unsupportedMarshalTypeError struct {
|
||||
emptyOrigError
|
||||
Type reflect.Type
|
||||
}
|
||||
|
||||
// Error returns the string representation of the error.
|
||||
// satisfying the error interface
|
||||
func (e *unsupportedMarshalTypeError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", e.Code(), e.Message())
|
||||
}
|
||||
|
||||
// Code returns the code of the error, satisfying the awserr.Error
|
||||
// interface.
|
||||
func (e *unsupportedMarshalTypeError) Code() string {
|
||||
return "unsupportedMarshalTypeError"
|
||||
}
|
||||
|
||||
// Message returns the detailed message of the error, satisfying
|
||||
// the awserr.Error interface.
|
||||
func (e *unsupportedMarshalTypeError) Message() string {
|
||||
return "Go value type " + e.Type.String() + " is not supported"
|
||||
}
|
269
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/field.go
generated
vendored
269
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/field.go
generated
vendored
|
@ -1,269 +0,0 @@
|
|||
package dynamodbattribute
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type field struct {
|
||||
tag
|
||||
|
||||
Name string
|
||||
NameFromTag bool
|
||||
|
||||
Index []int
|
||||
Type reflect.Type
|
||||
}
|
||||
|
||||
func fieldByName(fields []field, name string) (field, bool) {
|
||||
foldExists := false
|
||||
foldField := field{}
|
||||
|
||||
for _, f := range fields {
|
||||
if f.Name == name {
|
||||
return f, true
|
||||
}
|
||||
if !foldExists && strings.EqualFold(f.Name, name) {
|
||||
foldField = f
|
||||
foldExists = true
|
||||
}
|
||||
}
|
||||
|
||||
return foldField, foldExists
|
||||
}
|
||||
|
||||
func buildField(pIdx []int, i int, sf reflect.StructField, fieldTag tag) field {
|
||||
f := field{
|
||||
Name: sf.Name,
|
||||
Type: sf.Type,
|
||||
tag: fieldTag,
|
||||
}
|
||||
if len(fieldTag.Name) != 0 {
|
||||
f.NameFromTag = true
|
||||
f.Name = fieldTag.Name
|
||||
}
|
||||
|
||||
f.Index = make([]int, len(pIdx)+1)
|
||||
copy(f.Index, pIdx)
|
||||
f.Index[len(pIdx)] = i
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func unionStructFields(t reflect.Type, opts MarshalOptions) []field {
|
||||
fields := enumFields(t, opts)
|
||||
|
||||
sort.Sort(fieldsByName(fields))
|
||||
|
||||
fields = visibleFields(fields)
|
||||
|
||||
return fields
|
||||
}
|
||||
|
||||
// enumFields will recursively iterate through a structure and its nested
|
||||
// anonymous fields.
|
||||
//
|
||||
// Based on the enoding/json struct field enumeration of the Go Stdlib
|
||||
// https://golang.org/src/encoding/json/encode.go typeField func.
|
||||
func enumFields(t reflect.Type, opts MarshalOptions) []field {
|
||||
// Fields to explore
|
||||
current := []field{}
|
||||
next := []field{{Type: t}}
|
||||
|
||||
// count of queued names
|
||||
count := map[reflect.Type]int{}
|
||||
nextCount := map[reflect.Type]int{}
|
||||
|
||||
visited := map[reflect.Type]struct{}{}
|
||||
fields := []field{}
|
||||
|
||||
for len(next) > 0 {
|
||||
current, next = next, current[:0]
|
||||
count, nextCount = nextCount, map[reflect.Type]int{}
|
||||
|
||||
for _, f := range current {
|
||||
if _, ok := visited[f.Type]; ok {
|
||||
continue
|
||||
}
|
||||
visited[f.Type] = struct{}{}
|
||||
|
||||
for i := 0; i < f.Type.NumField(); i++ {
|
||||
sf := f.Type.Field(i)
|
||||
if sf.PkgPath != "" && !sf.Anonymous {
|
||||
// Ignore unexported and non-anonymous fields
|
||||
// unexported but anonymous field may still be used if
|
||||
// the type has exported nested fields
|
||||
continue
|
||||
}
|
||||
|
||||
fieldTag := tag{}
|
||||
fieldTag.parseAVTag(sf.Tag)
|
||||
if opts.SupportJSONTags && fieldTag == (tag{}) {
|
||||
fieldTag.parseJSONTag(sf.Tag)
|
||||
}
|
||||
|
||||
if fieldTag.Ignore {
|
||||
continue
|
||||
}
|
||||
|
||||
ft := sf.Type
|
||||
if ft.Name() == "" && ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
}
|
||||
|
||||
structField := buildField(f.Index, i, sf, fieldTag)
|
||||
structField.Type = ft
|
||||
|
||||
if !sf.Anonymous || ft.Kind() != reflect.Struct {
|
||||
fields = append(fields, structField)
|
||||
if count[f.Type] > 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, structField)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Record new anon struct to explore next round
|
||||
nextCount[ft]++
|
||||
if nextCount[ft] == 1 {
|
||||
next = append(next, structField)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
||||
// visibleFields will return a slice of fields which are visible based on
|
||||
// Go's standard visiblity rules with the exception of ties being broken
|
||||
// by depth and struct tag naming.
|
||||
//
|
||||
// Based on the enoding/json field filtering of the Go Stdlib
|
||||
// https://golang.org/src/encoding/json/encode.go typeField func.
|
||||
func visibleFields(fields []field) []field {
|
||||
// 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(fieldsByIndex(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.
|
||||
//
|
||||
// Based on the enoding/json field filtering of the Go Stdlib
|
||||
// https://golang.org/src/encoding/json/encode.go dominantField func.
|
||||
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.NameFromTag {
|
||||
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
|
||||
}
|
||||
|
||||
// fieldsByName sorts field by name, breaking ties with depth,
|
||||
// then breaking ties with "name came from json tag", then
|
||||
// breaking ties with index sequence.
|
||||
//
|
||||
// Based on the enoding/json field filtering of the Go Stdlib
|
||||
// https://golang.org/src/encoding/json/encode.go fieldsByName type.
|
||||
type fieldsByName []field
|
||||
|
||||
func (x fieldsByName) Len() int { return len(x) }
|
||||
|
||||
func (x fieldsByName) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
||||
|
||||
func (x fieldsByName) 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].NameFromTag != x[j].NameFromTag {
|
||||
return x[i].NameFromTag
|
||||
}
|
||||
return fieldsByIndex(x).Less(i, j)
|
||||
}
|
||||
|
||||
// fieldsByIndex sorts field by index sequence.
|
||||
//
|
||||
// Based on the enoding/json field filtering of the Go Stdlib
|
||||
// https://golang.org/src/encoding/json/encode.go fieldsByIndex type.
|
||||
type fieldsByIndex []field
|
||||
|
||||
func (x fieldsByIndex) Len() int { return len(x) }
|
||||
|
||||
func (x fieldsByIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
||||
|
||||
func (x fieldsByIndex) 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)
|
||||
}
|
68
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/tag.go
generated
vendored
68
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute/tag.go
generated
vendored
|
@ -1,68 +0,0 @@
|
|||
package dynamodbattribute
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type tag struct {
|
||||
Name string
|
||||
Ignore bool
|
||||
OmitEmpty bool
|
||||
OmitEmptyElem bool
|
||||
AsString bool
|
||||
AsBinSet, AsNumSet, AsStrSet bool
|
||||
AsUnixTime bool
|
||||
}
|
||||
|
||||
func (t *tag) parseAVTag(structTag reflect.StructTag) {
|
||||
tagStr := structTag.Get("dynamodbav")
|
||||
if len(tagStr) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
t.parseTagStr(tagStr)
|
||||
}
|
||||
|
||||
func (t *tag) parseJSONTag(structTag reflect.StructTag) {
|
||||
tagStr := structTag.Get("json")
|
||||
if len(tagStr) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
t.parseTagStr(tagStr)
|
||||
}
|
||||
|
||||
func (t *tag) parseTagStr(tagStr string) {
|
||||
parts := strings.Split(tagStr, ",")
|
||||
if len(parts) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if name := parts[0]; name == "-" {
|
||||
t.Name = ""
|
||||
t.Ignore = true
|
||||
} else {
|
||||
t.Name = name
|
||||
t.Ignore = false
|
||||
}
|
||||
|
||||
for _, opt := range parts[1:] {
|
||||
switch opt {
|
||||
case "omitempty":
|
||||
t.OmitEmpty = true
|
||||
case "omitemptyelem":
|
||||
t.OmitEmptyElem = true
|
||||
case "string":
|
||||
t.AsString = true
|
||||
case "binaryset":
|
||||
t.AsBinSet = true
|
||||
case "numberset":
|
||||
t.AsNumSet = true
|
||||
case "stringset":
|
||||
t.AsStrSet = true
|
||||
case "unixtime":
|
||||
t.AsUnixTime = true
|
||||
}
|
||||
}
|
||||
}
|
214
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface/interface.go
generated
vendored
214
vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface/interface.go
generated
vendored
|
@ -1,214 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package dynamodbiface provides an interface to enable mocking the Amazon DynamoDB service client
|
||||
// for testing your code.
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters.
|
||||
package dynamodbiface
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/dynamodb"
|
||||
)
|
||||
|
||||
// DynamoDBAPI provides an interface to enable mocking the
|
||||
// dynamodb.DynamoDB service client's API operation,
|
||||
// paginators, and waiters. This make unit testing your code that calls out
|
||||
// to the SDK's service client's calls easier.
|
||||
//
|
||||
// The best way to use this interface is so the SDK's service client's calls
|
||||
// can be stubbed out for unit testing your code with the SDK without needing
|
||||
// to inject custom request handlers into the SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // Amazon DynamoDB.
|
||||
// func myFunc(svc dynamodbiface.DynamoDBAPI) bool {
|
||||
// // Make svc.BatchGetItem request
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// sess := session.New()
|
||||
// svc := dynamodb.New(sess)
|
||||
//
|
||||
// myFunc(svc)
|
||||
// }
|
||||
//
|
||||
// In your _test.go file:
|
||||
//
|
||||
// // Define a mock struct to be used in your unit tests of myFunc.
|
||||
// type mockDynamoDBClient struct {
|
||||
// dynamodbiface.DynamoDBAPI
|
||||
// }
|
||||
// func (m *mockDynamoDBClient) BatchGetItem(input *dynamodb.BatchGetItemInput) (*dynamodb.BatchGetItemOutput, error) {
|
||||
// // mock response/functionality
|
||||
// }
|
||||
//
|
||||
// func TestMyFunc(t *testing.T) {
|
||||
// // Setup Test
|
||||
// mockSvc := &mockDynamoDBClient{}
|
||||
//
|
||||
// myfunc(mockSvc)
|
||||
//
|
||||
// // Verify myFunc's functionality
|
||||
// }
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters. Its suggested to use the pattern above for testing, or using
|
||||
// tooling to generate mocks to satisfy the interfaces.
|
||||
type DynamoDBAPI interface {
|
||||
BatchGetItem(*dynamodb.BatchGetItemInput) (*dynamodb.BatchGetItemOutput, error)
|
||||
BatchGetItemWithContext(aws.Context, *dynamodb.BatchGetItemInput, ...request.Option) (*dynamodb.BatchGetItemOutput, error)
|
||||
BatchGetItemRequest(*dynamodb.BatchGetItemInput) (*request.Request, *dynamodb.BatchGetItemOutput)
|
||||
|
||||
BatchGetItemPages(*dynamodb.BatchGetItemInput, func(*dynamodb.BatchGetItemOutput, bool) bool) error
|
||||
BatchGetItemPagesWithContext(aws.Context, *dynamodb.BatchGetItemInput, func(*dynamodb.BatchGetItemOutput, bool) bool, ...request.Option) error
|
||||
|
||||
BatchWriteItem(*dynamodb.BatchWriteItemInput) (*dynamodb.BatchWriteItemOutput, error)
|
||||
BatchWriteItemWithContext(aws.Context, *dynamodb.BatchWriteItemInput, ...request.Option) (*dynamodb.BatchWriteItemOutput, error)
|
||||
BatchWriteItemRequest(*dynamodb.BatchWriteItemInput) (*request.Request, *dynamodb.BatchWriteItemOutput)
|
||||
|
||||
CreateBackup(*dynamodb.CreateBackupInput) (*dynamodb.CreateBackupOutput, error)
|
||||
CreateBackupWithContext(aws.Context, *dynamodb.CreateBackupInput, ...request.Option) (*dynamodb.CreateBackupOutput, error)
|
||||
CreateBackupRequest(*dynamodb.CreateBackupInput) (*request.Request, *dynamodb.CreateBackupOutput)
|
||||
|
||||
CreateGlobalTable(*dynamodb.CreateGlobalTableInput) (*dynamodb.CreateGlobalTableOutput, error)
|
||||
CreateGlobalTableWithContext(aws.Context, *dynamodb.CreateGlobalTableInput, ...request.Option) (*dynamodb.CreateGlobalTableOutput, error)
|
||||
CreateGlobalTableRequest(*dynamodb.CreateGlobalTableInput) (*request.Request, *dynamodb.CreateGlobalTableOutput)
|
||||
|
||||
CreateTable(*dynamodb.CreateTableInput) (*dynamodb.CreateTableOutput, error)
|
||||
CreateTableWithContext(aws.Context, *dynamodb.CreateTableInput, ...request.Option) (*dynamodb.CreateTableOutput, error)
|
||||
CreateTableRequest(*dynamodb.CreateTableInput) (*request.Request, *dynamodb.CreateTableOutput)
|
||||
|
||||
DeleteBackup(*dynamodb.DeleteBackupInput) (*dynamodb.DeleteBackupOutput, error)
|
||||
DeleteBackupWithContext(aws.Context, *dynamodb.DeleteBackupInput, ...request.Option) (*dynamodb.DeleteBackupOutput, error)
|
||||
DeleteBackupRequest(*dynamodb.DeleteBackupInput) (*request.Request, *dynamodb.DeleteBackupOutput)
|
||||
|
||||
DeleteItem(*dynamodb.DeleteItemInput) (*dynamodb.DeleteItemOutput, error)
|
||||
DeleteItemWithContext(aws.Context, *dynamodb.DeleteItemInput, ...request.Option) (*dynamodb.DeleteItemOutput, error)
|
||||
DeleteItemRequest(*dynamodb.DeleteItemInput) (*request.Request, *dynamodb.DeleteItemOutput)
|
||||
|
||||
DeleteTable(*dynamodb.DeleteTableInput) (*dynamodb.DeleteTableOutput, error)
|
||||
DeleteTableWithContext(aws.Context, *dynamodb.DeleteTableInput, ...request.Option) (*dynamodb.DeleteTableOutput, error)
|
||||
DeleteTableRequest(*dynamodb.DeleteTableInput) (*request.Request, *dynamodb.DeleteTableOutput)
|
||||
|
||||
DescribeBackup(*dynamodb.DescribeBackupInput) (*dynamodb.DescribeBackupOutput, error)
|
||||
DescribeBackupWithContext(aws.Context, *dynamodb.DescribeBackupInput, ...request.Option) (*dynamodb.DescribeBackupOutput, error)
|
||||
DescribeBackupRequest(*dynamodb.DescribeBackupInput) (*request.Request, *dynamodb.DescribeBackupOutput)
|
||||
|
||||
DescribeContinuousBackups(*dynamodb.DescribeContinuousBackupsInput) (*dynamodb.DescribeContinuousBackupsOutput, error)
|
||||
DescribeContinuousBackupsWithContext(aws.Context, *dynamodb.DescribeContinuousBackupsInput, ...request.Option) (*dynamodb.DescribeContinuousBackupsOutput, error)
|
||||
DescribeContinuousBackupsRequest(*dynamodb.DescribeContinuousBackupsInput) (*request.Request, *dynamodb.DescribeContinuousBackupsOutput)
|
||||
|
||||
DescribeGlobalTable(*dynamodb.DescribeGlobalTableInput) (*dynamodb.DescribeGlobalTableOutput, error)
|
||||
DescribeGlobalTableWithContext(aws.Context, *dynamodb.DescribeGlobalTableInput, ...request.Option) (*dynamodb.DescribeGlobalTableOutput, error)
|
||||
DescribeGlobalTableRequest(*dynamodb.DescribeGlobalTableInput) (*request.Request, *dynamodb.DescribeGlobalTableOutput)
|
||||
|
||||
DescribeGlobalTableSettings(*dynamodb.DescribeGlobalTableSettingsInput) (*dynamodb.DescribeGlobalTableSettingsOutput, error)
|
||||
DescribeGlobalTableSettingsWithContext(aws.Context, *dynamodb.DescribeGlobalTableSettingsInput, ...request.Option) (*dynamodb.DescribeGlobalTableSettingsOutput, error)
|
||||
DescribeGlobalTableSettingsRequest(*dynamodb.DescribeGlobalTableSettingsInput) (*request.Request, *dynamodb.DescribeGlobalTableSettingsOutput)
|
||||
|
||||
DescribeLimits(*dynamodb.DescribeLimitsInput) (*dynamodb.DescribeLimitsOutput, error)
|
||||
DescribeLimitsWithContext(aws.Context, *dynamodb.DescribeLimitsInput, ...request.Option) (*dynamodb.DescribeLimitsOutput, error)
|
||||
DescribeLimitsRequest(*dynamodb.DescribeLimitsInput) (*request.Request, *dynamodb.DescribeLimitsOutput)
|
||||
|
||||
DescribeTable(*dynamodb.DescribeTableInput) (*dynamodb.DescribeTableOutput, error)
|
||||
DescribeTableWithContext(aws.Context, *dynamodb.DescribeTableInput, ...request.Option) (*dynamodb.DescribeTableOutput, error)
|
||||
DescribeTableRequest(*dynamodb.DescribeTableInput) (*request.Request, *dynamodb.DescribeTableOutput)
|
||||
|
||||
DescribeTimeToLive(*dynamodb.DescribeTimeToLiveInput) (*dynamodb.DescribeTimeToLiveOutput, error)
|
||||
DescribeTimeToLiveWithContext(aws.Context, *dynamodb.DescribeTimeToLiveInput, ...request.Option) (*dynamodb.DescribeTimeToLiveOutput, error)
|
||||
DescribeTimeToLiveRequest(*dynamodb.DescribeTimeToLiveInput) (*request.Request, *dynamodb.DescribeTimeToLiveOutput)
|
||||
|
||||
GetItem(*dynamodb.GetItemInput) (*dynamodb.GetItemOutput, error)
|
||||
GetItemWithContext(aws.Context, *dynamodb.GetItemInput, ...request.Option) (*dynamodb.GetItemOutput, error)
|
||||
GetItemRequest(*dynamodb.GetItemInput) (*request.Request, *dynamodb.GetItemOutput)
|
||||
|
||||
ListBackups(*dynamodb.ListBackupsInput) (*dynamodb.ListBackupsOutput, error)
|
||||
ListBackupsWithContext(aws.Context, *dynamodb.ListBackupsInput, ...request.Option) (*dynamodb.ListBackupsOutput, error)
|
||||
ListBackupsRequest(*dynamodb.ListBackupsInput) (*request.Request, *dynamodb.ListBackupsOutput)
|
||||
|
||||
ListGlobalTables(*dynamodb.ListGlobalTablesInput) (*dynamodb.ListGlobalTablesOutput, error)
|
||||
ListGlobalTablesWithContext(aws.Context, *dynamodb.ListGlobalTablesInput, ...request.Option) (*dynamodb.ListGlobalTablesOutput, error)
|
||||
ListGlobalTablesRequest(*dynamodb.ListGlobalTablesInput) (*request.Request, *dynamodb.ListGlobalTablesOutput)
|
||||
|
||||
ListTables(*dynamodb.ListTablesInput) (*dynamodb.ListTablesOutput, error)
|
||||
ListTablesWithContext(aws.Context, *dynamodb.ListTablesInput, ...request.Option) (*dynamodb.ListTablesOutput, error)
|
||||
ListTablesRequest(*dynamodb.ListTablesInput) (*request.Request, *dynamodb.ListTablesOutput)
|
||||
|
||||
ListTablesPages(*dynamodb.ListTablesInput, func(*dynamodb.ListTablesOutput, bool) bool) error
|
||||
ListTablesPagesWithContext(aws.Context, *dynamodb.ListTablesInput, func(*dynamodb.ListTablesOutput, bool) bool, ...request.Option) error
|
||||
|
||||
ListTagsOfResource(*dynamodb.ListTagsOfResourceInput) (*dynamodb.ListTagsOfResourceOutput, error)
|
||||
ListTagsOfResourceWithContext(aws.Context, *dynamodb.ListTagsOfResourceInput, ...request.Option) (*dynamodb.ListTagsOfResourceOutput, error)
|
||||
ListTagsOfResourceRequest(*dynamodb.ListTagsOfResourceInput) (*request.Request, *dynamodb.ListTagsOfResourceOutput)
|
||||
|
||||
PutItem(*dynamodb.PutItemInput) (*dynamodb.PutItemOutput, error)
|
||||
PutItemWithContext(aws.Context, *dynamodb.PutItemInput, ...request.Option) (*dynamodb.PutItemOutput, error)
|
||||
PutItemRequest(*dynamodb.PutItemInput) (*request.Request, *dynamodb.PutItemOutput)
|
||||
|
||||
Query(*dynamodb.QueryInput) (*dynamodb.QueryOutput, error)
|
||||
QueryWithContext(aws.Context, *dynamodb.QueryInput, ...request.Option) (*dynamodb.QueryOutput, error)
|
||||
QueryRequest(*dynamodb.QueryInput) (*request.Request, *dynamodb.QueryOutput)
|
||||
|
||||
QueryPages(*dynamodb.QueryInput, func(*dynamodb.QueryOutput, bool) bool) error
|
||||
QueryPagesWithContext(aws.Context, *dynamodb.QueryInput, func(*dynamodb.QueryOutput, bool) bool, ...request.Option) error
|
||||
|
||||
RestoreTableFromBackup(*dynamodb.RestoreTableFromBackupInput) (*dynamodb.RestoreTableFromBackupOutput, error)
|
||||
RestoreTableFromBackupWithContext(aws.Context, *dynamodb.RestoreTableFromBackupInput, ...request.Option) (*dynamodb.RestoreTableFromBackupOutput, error)
|
||||
RestoreTableFromBackupRequest(*dynamodb.RestoreTableFromBackupInput) (*request.Request, *dynamodb.RestoreTableFromBackupOutput)
|
||||
|
||||
RestoreTableToPointInTime(*dynamodb.RestoreTableToPointInTimeInput) (*dynamodb.RestoreTableToPointInTimeOutput, error)
|
||||
RestoreTableToPointInTimeWithContext(aws.Context, *dynamodb.RestoreTableToPointInTimeInput, ...request.Option) (*dynamodb.RestoreTableToPointInTimeOutput, error)
|
||||
RestoreTableToPointInTimeRequest(*dynamodb.RestoreTableToPointInTimeInput) (*request.Request, *dynamodb.RestoreTableToPointInTimeOutput)
|
||||
|
||||
Scan(*dynamodb.ScanInput) (*dynamodb.ScanOutput, error)
|
||||
ScanWithContext(aws.Context, *dynamodb.ScanInput, ...request.Option) (*dynamodb.ScanOutput, error)
|
||||
ScanRequest(*dynamodb.ScanInput) (*request.Request, *dynamodb.ScanOutput)
|
||||
|
||||
ScanPages(*dynamodb.ScanInput, func(*dynamodb.ScanOutput, bool) bool) error
|
||||
ScanPagesWithContext(aws.Context, *dynamodb.ScanInput, func(*dynamodb.ScanOutput, bool) bool, ...request.Option) error
|
||||
|
||||
TagResource(*dynamodb.TagResourceInput) (*dynamodb.TagResourceOutput, error)
|
||||
TagResourceWithContext(aws.Context, *dynamodb.TagResourceInput, ...request.Option) (*dynamodb.TagResourceOutput, error)
|
||||
TagResourceRequest(*dynamodb.TagResourceInput) (*request.Request, *dynamodb.TagResourceOutput)
|
||||
|
||||
UntagResource(*dynamodb.UntagResourceInput) (*dynamodb.UntagResourceOutput, error)
|
||||
UntagResourceWithContext(aws.Context, *dynamodb.UntagResourceInput, ...request.Option) (*dynamodb.UntagResourceOutput, error)
|
||||
UntagResourceRequest(*dynamodb.UntagResourceInput) (*request.Request, *dynamodb.UntagResourceOutput)
|
||||
|
||||
UpdateContinuousBackups(*dynamodb.UpdateContinuousBackupsInput) (*dynamodb.UpdateContinuousBackupsOutput, error)
|
||||
UpdateContinuousBackupsWithContext(aws.Context, *dynamodb.UpdateContinuousBackupsInput, ...request.Option) (*dynamodb.UpdateContinuousBackupsOutput, error)
|
||||
UpdateContinuousBackupsRequest(*dynamodb.UpdateContinuousBackupsInput) (*request.Request, *dynamodb.UpdateContinuousBackupsOutput)
|
||||
|
||||
UpdateGlobalTable(*dynamodb.UpdateGlobalTableInput) (*dynamodb.UpdateGlobalTableOutput, error)
|
||||
UpdateGlobalTableWithContext(aws.Context, *dynamodb.UpdateGlobalTableInput, ...request.Option) (*dynamodb.UpdateGlobalTableOutput, error)
|
||||
UpdateGlobalTableRequest(*dynamodb.UpdateGlobalTableInput) (*request.Request, *dynamodb.UpdateGlobalTableOutput)
|
||||
|
||||
UpdateGlobalTableSettings(*dynamodb.UpdateGlobalTableSettingsInput) (*dynamodb.UpdateGlobalTableSettingsOutput, error)
|
||||
UpdateGlobalTableSettingsWithContext(aws.Context, *dynamodb.UpdateGlobalTableSettingsInput, ...request.Option) (*dynamodb.UpdateGlobalTableSettingsOutput, error)
|
||||
UpdateGlobalTableSettingsRequest(*dynamodb.UpdateGlobalTableSettingsInput) (*request.Request, *dynamodb.UpdateGlobalTableSettingsOutput)
|
||||
|
||||
UpdateItem(*dynamodb.UpdateItemInput) (*dynamodb.UpdateItemOutput, error)
|
||||
UpdateItemWithContext(aws.Context, *dynamodb.UpdateItemInput, ...request.Option) (*dynamodb.UpdateItemOutput, error)
|
||||
UpdateItemRequest(*dynamodb.UpdateItemInput) (*request.Request, *dynamodb.UpdateItemOutput)
|
||||
|
||||
UpdateTable(*dynamodb.UpdateTableInput) (*dynamodb.UpdateTableOutput, error)
|
||||
UpdateTableWithContext(aws.Context, *dynamodb.UpdateTableInput, ...request.Option) (*dynamodb.UpdateTableOutput, error)
|
||||
UpdateTableRequest(*dynamodb.UpdateTableInput) (*request.Request, *dynamodb.UpdateTableOutput)
|
||||
|
||||
UpdateTimeToLive(*dynamodb.UpdateTimeToLiveInput) (*dynamodb.UpdateTimeToLiveOutput, error)
|
||||
UpdateTimeToLiveWithContext(aws.Context, *dynamodb.UpdateTimeToLiveInput, ...request.Option) (*dynamodb.UpdateTimeToLiveOutput, error)
|
||||
UpdateTimeToLiveRequest(*dynamodb.UpdateTimeToLiveInput) (*request.Request, *dynamodb.UpdateTimeToLiveOutput)
|
||||
|
||||
WaitUntilTableExists(*dynamodb.DescribeTableInput) error
|
||||
WaitUntilTableExistsWithContext(aws.Context, *dynamodb.DescribeTableInput, ...request.WaiterOption) error
|
||||
|
||||
WaitUntilTableNotExists(*dynamodb.DescribeTableInput) error
|
||||
WaitUntilTableNotExistsWithContext(aws.Context, *dynamodb.DescribeTableInput, ...request.WaiterOption) error
|
||||
}
|
||||
|
||||
var _ DynamoDBAPI = (*dynamodb.DynamoDB)(nil)
|
149
vendor/github.com/aws/aws-sdk-go/service/dynamodb/errors.go
generated
vendored
149
vendor/github.com/aws/aws-sdk-go/service/dynamodb/errors.go
generated
vendored
|
@ -1,149 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package dynamodb
|
||||
|
||||
const (
|
||||
|
||||
// ErrCodeBackupInUseException for service response error code
|
||||
// "BackupInUseException".
|
||||
//
|
||||
// There is another ongoing conflicting backup control plane operation on the
|
||||
// table. The backups is either being created, deleted or restored to a table.
|
||||
ErrCodeBackupInUseException = "BackupInUseException"
|
||||
|
||||
// ErrCodeBackupNotFoundException for service response error code
|
||||
// "BackupNotFoundException".
|
||||
//
|
||||
// Backup not found for the given BackupARN.
|
||||
ErrCodeBackupNotFoundException = "BackupNotFoundException"
|
||||
|
||||
// ErrCodeConditionalCheckFailedException for service response error code
|
||||
// "ConditionalCheckFailedException".
|
||||
//
|
||||
// A condition specified in the operation could not be evaluated.
|
||||
ErrCodeConditionalCheckFailedException = "ConditionalCheckFailedException"
|
||||
|
||||
// ErrCodeContinuousBackupsUnavailableException for service response error code
|
||||
// "ContinuousBackupsUnavailableException".
|
||||
//
|
||||
// Backups have not yet been enabled for this table.
|
||||
ErrCodeContinuousBackupsUnavailableException = "ContinuousBackupsUnavailableException"
|
||||
|
||||
// ErrCodeGlobalTableAlreadyExistsException for service response error code
|
||||
// "GlobalTableAlreadyExistsException".
|
||||
//
|
||||
// The specified global table already exists.
|
||||
ErrCodeGlobalTableAlreadyExistsException = "GlobalTableAlreadyExistsException"
|
||||
|
||||
// ErrCodeGlobalTableNotFoundException for service response error code
|
||||
// "GlobalTableNotFoundException".
|
||||
//
|
||||
// The specified global table does not exist.
|
||||
ErrCodeGlobalTableNotFoundException = "GlobalTableNotFoundException"
|
||||
|
||||
// ErrCodeIndexNotFoundException for service response error code
|
||||
// "IndexNotFoundException".
|
||||
//
|
||||
// The operation tried to access a nonexistent index.
|
||||
ErrCodeIndexNotFoundException = "IndexNotFoundException"
|
||||
|
||||
// ErrCodeInternalServerError for service response error code
|
||||
// "InternalServerError".
|
||||
//
|
||||
// An error occurred on the server side.
|
||||
ErrCodeInternalServerError = "InternalServerError"
|
||||
|
||||
// ErrCodeInvalidRestoreTimeException for service response error code
|
||||
// "InvalidRestoreTimeException".
|
||||
//
|
||||
// An invalid restore time was specified. RestoreDateTime must be between EarliestRestorableDateTime
|
||||
// and LatestRestorableDateTime.
|
||||
ErrCodeInvalidRestoreTimeException = "InvalidRestoreTimeException"
|
||||
|
||||
// ErrCodeItemCollectionSizeLimitExceededException for service response error code
|
||||
// "ItemCollectionSizeLimitExceededException".
|
||||
//
|
||||
// An item collection is too large. This exception is only returned for tables
|
||||
// that have one or more local secondary indexes.
|
||||
ErrCodeItemCollectionSizeLimitExceededException = "ItemCollectionSizeLimitExceededException"
|
||||
|
||||
// ErrCodeLimitExceededException for service response error code
|
||||
// "LimitExceededException".
|
||||
//
|
||||
// Up to 50 CreateBackup operations are allowed per second, per account. There
|
||||
// is no limit to the number of daily on-demand backups that can be taken.
|
||||
//
|
||||
// Up to 10 simultaneous table operations are allowed per account. These operations
|
||||
// include CreateTable, UpdateTable, DeleteTable,UpdateTimeToLive, RestoreTableFromBackup,
|
||||
// and RestoreTableToPointInTime.
|
||||
//
|
||||
// For tables with secondary indexes, only one of those tables can be in the
|
||||
// CREATING state at any point in time. Do not attempt to create more than one
|
||||
// such table simultaneously.
|
||||
//
|
||||
// The total limit of tables in the ACTIVE state is 250.
|
||||
ErrCodeLimitExceededException = "LimitExceededException"
|
||||
|
||||
// ErrCodePointInTimeRecoveryUnavailableException for service response error code
|
||||
// "PointInTimeRecoveryUnavailableException".
|
||||
//
|
||||
// Point in time recovery has not yet been enabled for this source table.
|
||||
ErrCodePointInTimeRecoveryUnavailableException = "PointInTimeRecoveryUnavailableException"
|
||||
|
||||
// ErrCodeProvisionedThroughputExceededException for service response error code
|
||||
// "ProvisionedThroughputExceededException".
|
||||
//
|
||||
// Your request rate is too high. The AWS SDKs for DynamoDB automatically retry
|
||||
// requests that receive this exception. Your request is eventually successful,
|
||||
// unless your retry queue is too large to finish. Reduce the frequency of requests
|
||||
// and use exponential backoff. For more information, go to Error Retries and
|
||||
// Exponential Backoff (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff)
|
||||
// in the Amazon DynamoDB Developer Guide.
|
||||
ErrCodeProvisionedThroughputExceededException = "ProvisionedThroughputExceededException"
|
||||
|
||||
// ErrCodeReplicaAlreadyExistsException for service response error code
|
||||
// "ReplicaAlreadyExistsException".
|
||||
//
|
||||
// The specified replica is already part of the global table.
|
||||
ErrCodeReplicaAlreadyExistsException = "ReplicaAlreadyExistsException"
|
||||
|
||||
// ErrCodeReplicaNotFoundException for service response error code
|
||||
// "ReplicaNotFoundException".
|
||||
//
|
||||
// The specified replica is no longer part of the global table.
|
||||
ErrCodeReplicaNotFoundException = "ReplicaNotFoundException"
|
||||
|
||||
// ErrCodeResourceInUseException for service response error code
|
||||
// "ResourceInUseException".
|
||||
//
|
||||
// The operation conflicts with the resource's availability. For example, you
|
||||
// attempted to recreate an existing table, or tried to delete a table currently
|
||||
// in the CREATING state.
|
||||
ErrCodeResourceInUseException = "ResourceInUseException"
|
||||
|
||||
// ErrCodeResourceNotFoundException for service response error code
|
||||
// "ResourceNotFoundException".
|
||||
//
|
||||
// The operation tried to access a nonexistent table or index. The resource
|
||||
// might not be specified correctly, or its status might not be ACTIVE.
|
||||
ErrCodeResourceNotFoundException = "ResourceNotFoundException"
|
||||
|
||||
// ErrCodeTableAlreadyExistsException for service response error code
|
||||
// "TableAlreadyExistsException".
|
||||
//
|
||||
// A target table with the specified name already exists.
|
||||
ErrCodeTableAlreadyExistsException = "TableAlreadyExistsException"
|
||||
|
||||
// ErrCodeTableInUseException for service response error code
|
||||
// "TableInUseException".
|
||||
//
|
||||
// A target table with the specified name is either being created or deleted.
|
||||
ErrCodeTableInUseException = "TableInUseException"
|
||||
|
||||
// ErrCodeTableNotFoundException for service response error code
|
||||
// "TableNotFoundException".
|
||||
//
|
||||
// A source table with the name TableName does not currently exist within the
|
||||
// subscriber's account.
|
||||
ErrCodeTableNotFoundException = "TableNotFoundException"
|
||||
)
|
95
vendor/github.com/aws/aws-sdk-go/service/dynamodb/service.go
generated
vendored
95
vendor/github.com/aws/aws-sdk-go/service/dynamodb/service.go
generated
vendored
|
@ -1,95 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package dynamodb
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/signer/v4"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
|
||||
)
|
||||
|
||||
// DynamoDB provides the API operation methods for making requests to
|
||||
// Amazon DynamoDB. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// DynamoDB methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type DynamoDB struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
// Used for custom client initialization logic
|
||||
var initClient func(*client.Client)
|
||||
|
||||
// Used for custom request initialization logic
|
||||
var initRequest func(*request.Request)
|
||||
|
||||
// Service information constants
|
||||
const (
|
||||
ServiceName = "dynamodb" // Service endpoint prefix API calls made to.
|
||||
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
|
||||
)
|
||||
|
||||
// New creates a new instance of the DynamoDB client with a session.
|
||||
// If additional configuration is needed for the client instance use the optional
|
||||
// aws.Config parameter to add your extra config.
|
||||
//
|
||||
// Example:
|
||||
// // Create a DynamoDB client from just a session.
|
||||
// svc := dynamodb.New(mySession)
|
||||
//
|
||||
// // Create a DynamoDB client with additional configuration
|
||||
// svc := dynamodb.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *DynamoDB {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
// newClient creates, initializes and returns a new service client instance.
|
||||
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *DynamoDB {
|
||||
svc := &DynamoDB{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2012-08-10",
|
||||
JSONVersion: "1.0",
|
||||
TargetPrefix: "DynamoDB_20120810",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a DynamoDB operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *DynamoDB) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
// Run custom request initialization if present
|
||||
if initRequest != nil {
|
||||
initRequest(req)
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
107
vendor/github.com/aws/aws-sdk-go/service/dynamodb/waiters.go
generated
vendored
107
vendor/github.com/aws/aws-sdk-go/service/dynamodb/waiters.go
generated
vendored
|
@ -1,107 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package dynamodb
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
)
|
||||
|
||||
// WaitUntilTableExists uses the DynamoDB API operation
|
||||
// DescribeTable to wait for a condition to be met before returning.
|
||||
// If the condition is not met within the max attempt window, an error will
|
||||
// be returned.
|
||||
func (c *DynamoDB) WaitUntilTableExists(input *DescribeTableInput) error {
|
||||
return c.WaitUntilTableExistsWithContext(aws.BackgroundContext(), input)
|
||||
}
|
||||
|
||||
// WaitUntilTableExistsWithContext is an extended version of WaitUntilTableExists.
|
||||
// With the support for passing in a context and options to configure the
|
||||
// Waiter and the underlying request options.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If
|
||||
// the context is nil a panic will occur. In the future the SDK may create
|
||||
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *DynamoDB) WaitUntilTableExistsWithContext(ctx aws.Context, input *DescribeTableInput, opts ...request.WaiterOption) error {
|
||||
w := request.Waiter{
|
||||
Name: "WaitUntilTableExists",
|
||||
MaxAttempts: 25,
|
||||
Delay: request.ConstantWaiterDelay(20 * time.Second),
|
||||
Acceptors: []request.WaiterAcceptor{
|
||||
{
|
||||
State: request.SuccessWaiterState,
|
||||
Matcher: request.PathWaiterMatch, Argument: "Table.TableStatus",
|
||||
Expected: "ACTIVE",
|
||||
},
|
||||
{
|
||||
State: request.RetryWaiterState,
|
||||
Matcher: request.ErrorWaiterMatch,
|
||||
Expected: "ResourceNotFoundException",
|
||||
},
|
||||
},
|
||||
Logger: c.Config.Logger,
|
||||
NewRequest: func(opts []request.Option) (*request.Request, error) {
|
||||
var inCpy *DescribeTableInput
|
||||
if input != nil {
|
||||
tmp := *input
|
||||
inCpy = &tmp
|
||||
}
|
||||
req, _ := c.DescribeTableRequest(inCpy)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return req, nil
|
||||
},
|
||||
}
|
||||
w.ApplyOptions(opts...)
|
||||
|
||||
return w.WaitWithContext(ctx)
|
||||
}
|
||||
|
||||
// WaitUntilTableNotExists uses the DynamoDB API operation
|
||||
// DescribeTable to wait for a condition to be met before returning.
|
||||
// If the condition is not met within the max attempt window, an error will
|
||||
// be returned.
|
||||
func (c *DynamoDB) WaitUntilTableNotExists(input *DescribeTableInput) error {
|
||||
return c.WaitUntilTableNotExistsWithContext(aws.BackgroundContext(), input)
|
||||
}
|
||||
|
||||
// WaitUntilTableNotExistsWithContext is an extended version of WaitUntilTableNotExists.
|
||||
// With the support for passing in a context and options to configure the
|
||||
// Waiter and the underlying request options.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If
|
||||
// the context is nil a panic will occur. In the future the SDK may create
|
||||
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *DynamoDB) WaitUntilTableNotExistsWithContext(ctx aws.Context, input *DescribeTableInput, opts ...request.WaiterOption) error {
|
||||
w := request.Waiter{
|
||||
Name: "WaitUntilTableNotExists",
|
||||
MaxAttempts: 25,
|
||||
Delay: request.ConstantWaiterDelay(20 * time.Second),
|
||||
Acceptors: []request.WaiterAcceptor{
|
||||
{
|
||||
State: request.SuccessWaiterState,
|
||||
Matcher: request.ErrorWaiterMatch,
|
||||
Expected: "ResourceNotFoundException",
|
||||
},
|
||||
},
|
||||
Logger: c.Config.Logger,
|
||||
NewRequest: func(opts []request.Option) (*request.Request, error) {
|
||||
var inCpy *DescribeTableInput
|
||||
if input != nil {
|
||||
tmp := *input
|
||||
inCpy = &tmp
|
||||
}
|
||||
req, _ := c.DescribeTableRequest(inCpy)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return req, nil
|
||||
},
|
||||
}
|
||||
w.ApplyOptions(opts...)
|
||||
|
||||
return w.WaitWithContext(ctx)
|
||||
}
|
71742
vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
generated
vendored
71742
vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
generated
vendored
File diff suppressed because it is too large
Load diff
120
vendor/github.com/aws/aws-sdk-go/service/ec2/customizations.go
generated
vendored
120
vendor/github.com/aws/aws-sdk-go/service/ec2/customizations.go
generated
vendored
|
@ -1,120 +0,0 @@
|
|||
package ec2
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awsutil"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/endpoints"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/internal/sdkrand"
|
||||
)
|
||||
|
||||
type retryer struct {
|
||||
client.DefaultRetryer
|
||||
}
|
||||
|
||||
func (d retryer) RetryRules(r *request.Request) time.Duration {
|
||||
switch r.Operation.Name {
|
||||
case opModifyNetworkInterfaceAttribute:
|
||||
fallthrough
|
||||
case opAssignPrivateIpAddresses:
|
||||
return customRetryRule(r)
|
||||
default:
|
||||
return d.DefaultRetryer.RetryRules(r)
|
||||
}
|
||||
}
|
||||
|
||||
func customRetryRule(r *request.Request) time.Duration {
|
||||
retryTimes := []time.Duration{
|
||||
time.Second,
|
||||
3 * time.Second,
|
||||
5 * time.Second,
|
||||
}
|
||||
|
||||
count := r.RetryCount
|
||||
if count >= len(retryTimes) {
|
||||
count = len(retryTimes) - 1
|
||||
}
|
||||
|
||||
minTime := int(retryTimes[count])
|
||||
return time.Duration(sdkrand.SeededRand.Intn(minTime) + minTime)
|
||||
}
|
||||
|
||||
func setCustomRetryer(c *client.Client) {
|
||||
maxRetries := aws.IntValue(c.Config.MaxRetries)
|
||||
if c.Config.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries {
|
||||
maxRetries = 3
|
||||
}
|
||||
|
||||
c.Retryer = retryer{
|
||||
DefaultRetryer: client.DefaultRetryer{
|
||||
NumMaxRetries: maxRetries,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
initClient = func(c *client.Client) {
|
||||
if c.Config.Retryer == nil {
|
||||
// Only override the retryer with a custom one if the config
|
||||
// does not already contain a retryer
|
||||
setCustomRetryer(c)
|
||||
}
|
||||
}
|
||||
initRequest = func(r *request.Request) {
|
||||
if r.Operation.Name == opCopySnapshot { // fill the PresignedURL parameter
|
||||
r.Handlers.Build.PushFront(fillPresignedURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fillPresignedURL(r *request.Request) {
|
||||
if !r.ParamsFilled() {
|
||||
return
|
||||
}
|
||||
|
||||
origParams := r.Params.(*CopySnapshotInput)
|
||||
|
||||
// Stop if PresignedURL/DestinationRegion is set
|
||||
if origParams.PresignedUrl != nil || origParams.DestinationRegion != nil {
|
||||
return
|
||||
}
|
||||
|
||||
origParams.DestinationRegion = r.Config.Region
|
||||
newParams := awsutil.CopyOf(r.Params).(*CopySnapshotInput)
|
||||
|
||||
// Create a new request based on the existing request. We will use this to
|
||||
// presign the CopySnapshot request against the source region.
|
||||
cfg := r.Config.Copy(aws.NewConfig().
|
||||
WithEndpoint("").
|
||||
WithRegion(aws.StringValue(origParams.SourceRegion)))
|
||||
|
||||
clientInfo := r.ClientInfo
|
||||
resolved, err := r.Config.EndpointResolver.EndpointFor(
|
||||
clientInfo.ServiceName, aws.StringValue(cfg.Region),
|
||||
func(opt *endpoints.Options) {
|
||||
opt.DisableSSL = aws.BoolValue(cfg.DisableSSL)
|
||||
opt.UseDualStack = aws.BoolValue(cfg.UseDualStack)
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
r.Error = err
|
||||
return
|
||||
}
|
||||
|
||||
clientInfo.Endpoint = resolved.URL
|
||||
clientInfo.SigningRegion = resolved.SigningRegion
|
||||
|
||||
// Presign a CopySnapshot request with modified params
|
||||
req := request.New(*cfg, clientInfo, r.Handlers, r.Retryer, r.Operation, newParams, r.Data)
|
||||
url, err := req.Presign(5 * time.Minute) // 5 minutes should be enough.
|
||||
if err != nil { // bubble error back up to original request
|
||||
r.Error = err
|
||||
return
|
||||
}
|
||||
|
||||
// We have our URL, set it on params
|
||||
origParams.PresignedUrl = &url
|
||||
}
|
30
vendor/github.com/aws/aws-sdk-go/service/ec2/doc.go
generated
vendored
30
vendor/github.com/aws/aws-sdk-go/service/ec2/doc.go
generated
vendored
|
@ -1,30 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package ec2 provides the client and types for making API
|
||||
// requests to Amazon Elastic Compute Cloud.
|
||||
//
|
||||
// Amazon Elastic Compute Cloud (Amazon EC2) provides resizable computing capacity
|
||||
// in the AWS Cloud. Using Amazon EC2 eliminates the need to invest in hardware
|
||||
// up front, so you can develop and deploy applications faster.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15 for more information on this service.
|
||||
//
|
||||
// See ec2 package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact Amazon Elastic Compute Cloud with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
// See the SDK's documentation for more information on how to use the SDK.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/
|
||||
//
|
||||
// See aws.Config documentation for more information on configuring SDK clients.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
|
||||
//
|
||||
// See the Amazon Elastic Compute Cloud client EC2 for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#New
|
||||
package ec2
|
3
vendor/github.com/aws/aws-sdk-go/service/ec2/errors.go
generated
vendored
3
vendor/github.com/aws/aws-sdk-go/service/ec2/errors.go
generated
vendored
|
@ -1,3 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package ec2
|
93
vendor/github.com/aws/aws-sdk-go/service/ec2/service.go
generated
vendored
93
vendor/github.com/aws/aws-sdk-go/service/ec2/service.go
generated
vendored
|
@ -1,93 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package ec2
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/signer/v4"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/ec2query"
|
||||
)
|
||||
|
||||
// EC2 provides the API operation methods for making requests to
|
||||
// Amazon Elastic Compute Cloud. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// EC2 methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type EC2 struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
// Used for custom client initialization logic
|
||||
var initClient func(*client.Client)
|
||||
|
||||
// Used for custom request initialization logic
|
||||
var initRequest func(*request.Request)
|
||||
|
||||
// Service information constants
|
||||
const (
|
||||
ServiceName = "ec2" // Service endpoint prefix API calls made to.
|
||||
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
|
||||
)
|
||||
|
||||
// New creates a new instance of the EC2 client with a session.
|
||||
// If additional configuration is needed for the client instance use the optional
|
||||
// aws.Config parameter to add your extra config.
|
||||
//
|
||||
// Example:
|
||||
// // Create a EC2 client from just a session.
|
||||
// svc := ec2.New(mySession)
|
||||
//
|
||||
// // Create a EC2 client with additional configuration
|
||||
// svc := ec2.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *EC2 {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
// newClient creates, initializes and returns a new service client instance.
|
||||
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *EC2 {
|
||||
svc := &EC2{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2016-11-15",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(ec2query.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(ec2query.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(ec2query.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(ec2query.UnmarshalErrorHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a EC2 operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *EC2) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
// Run custom request initialization if present
|
||||
if initRequest != nil {
|
||||
initRequest(req)
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
1626
vendor/github.com/aws/aws-sdk-go/service/ec2/waiters.go
generated
vendored
1626
vendor/github.com/aws/aws-sdk-go/service/ec2/waiters.go
generated
vendored
File diff suppressed because it is too large
Load diff
11156
vendor/github.com/aws/aws-sdk-go/service/ecs/api.go
generated
vendored
11156
vendor/github.com/aws/aws-sdk-go/service/ecs/api.go
generated
vendored
File diff suppressed because it is too large
Load diff
45
vendor/github.com/aws/aws-sdk-go/service/ecs/doc.go
generated
vendored
45
vendor/github.com/aws/aws-sdk-go/service/ecs/doc.go
generated
vendored
|
@ -1,45 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package ecs provides the client and types for making API
|
||||
// requests to Amazon EC2 Container Service.
|
||||
//
|
||||
// Amazon Elastic Container Service (Amazon ECS) is a highly scalable, fast,
|
||||
// container management service that makes it easy to run, stop, and manage
|
||||
// Docker containers on a cluster. You can host your cluster on a serverless
|
||||
// infrastructure that is managed by Amazon ECS by launching your services or
|
||||
// tasks using the Fargate launch type. For more control, you can host your
|
||||
// tasks on a cluster of Amazon Elastic Compute Cloud (Amazon EC2) instances
|
||||
// that you manage by using the EC2 launch type. For more information about
|
||||
// launch types, see Amazon ECS Launch Types (http://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html).
|
||||
//
|
||||
// Amazon ECS lets you launch and stop container-based applications with simple
|
||||
// API calls, allows you to get the state of your cluster from a centralized
|
||||
// service, and gives you access to many familiar Amazon EC2 features.
|
||||
//
|
||||
// You can use Amazon ECS to schedule the placement of containers across your
|
||||
// cluster based on your resource needs, isolation policies, and availability
|
||||
// requirements. Amazon ECS eliminates the need for you to operate your own
|
||||
// cluster management and configuration management systems or worry about scaling
|
||||
// your management infrastructure.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13 for more information on this service.
|
||||
//
|
||||
// See ecs package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ecs/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact Amazon EC2 Container Service with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
// See the SDK's documentation for more information on how to use the SDK.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/
|
||||
//
|
||||
// See aws.Config documentation for more information on configuring SDK clients.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
|
||||
//
|
||||
// See the Amazon EC2 Container Service client ECS for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ecs/#New
|
||||
package ecs
|
145
vendor/github.com/aws/aws-sdk-go/service/ecs/errors.go
generated
vendored
145
vendor/github.com/aws/aws-sdk-go/service/ecs/errors.go
generated
vendored
|
@ -1,145 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package ecs
|
||||
|
||||
const (
|
||||
|
||||
// ErrCodeAccessDeniedException for service response error code
|
||||
// "AccessDeniedException".
|
||||
//
|
||||
// You do not have authorization to perform the requested action.
|
||||
ErrCodeAccessDeniedException = "AccessDeniedException"
|
||||
|
||||
// ErrCodeAttributeLimitExceededException for service response error code
|
||||
// "AttributeLimitExceededException".
|
||||
//
|
||||
// You can apply up to 10 custom attributes per resource. You can view the attributes
|
||||
// of a resource with ListAttributes. You can remove existing attributes on
|
||||
// a resource with DeleteAttributes.
|
||||
ErrCodeAttributeLimitExceededException = "AttributeLimitExceededException"
|
||||
|
||||
// ErrCodeBlockedException for service response error code
|
||||
// "BlockedException".
|
||||
//
|
||||
// Your AWS account has been blocked. Contact AWS Support (http://aws.amazon.com/contact-us/)
|
||||
// for more information.
|
||||
ErrCodeBlockedException = "BlockedException"
|
||||
|
||||
// ErrCodeClientException for service response error code
|
||||
// "ClientException".
|
||||
//
|
||||
// These errors are usually caused by a client action, such as using an action
|
||||
// or resource on behalf of a user that doesn't have permissions to use the
|
||||
// action or resource, or specifying an identifier that is not valid.
|
||||
ErrCodeClientException = "ClientException"
|
||||
|
||||
// ErrCodeClusterContainsContainerInstancesException for service response error code
|
||||
// "ClusterContainsContainerInstancesException".
|
||||
//
|
||||
// You cannot delete a cluster that has registered container instances. You
|
||||
// must first deregister the container instances before you can delete the cluster.
|
||||
// For more information, see DeregisterContainerInstance.
|
||||
ErrCodeClusterContainsContainerInstancesException = "ClusterContainsContainerInstancesException"
|
||||
|
||||
// ErrCodeClusterContainsServicesException for service response error code
|
||||
// "ClusterContainsServicesException".
|
||||
//
|
||||
// You cannot delete a cluster that contains services. You must first update
|
||||
// the service to reduce its desired task count to 0 and then delete the service.
|
||||
// For more information, see UpdateService and DeleteService.
|
||||
ErrCodeClusterContainsServicesException = "ClusterContainsServicesException"
|
||||
|
||||
// ErrCodeClusterContainsTasksException for service response error code
|
||||
// "ClusterContainsTasksException".
|
||||
//
|
||||
// You cannot delete a cluster that has active tasks.
|
||||
ErrCodeClusterContainsTasksException = "ClusterContainsTasksException"
|
||||
|
||||
// ErrCodeClusterNotFoundException for service response error code
|
||||
// "ClusterNotFoundException".
|
||||
//
|
||||
// The specified cluster could not be found. You can view your available clusters
|
||||
// with ListClusters. Amazon ECS clusters are region-specific.
|
||||
ErrCodeClusterNotFoundException = "ClusterNotFoundException"
|
||||
|
||||
// ErrCodeInvalidParameterException for service response error code
|
||||
// "InvalidParameterException".
|
||||
//
|
||||
// The specified parameter is invalid. Review the available parameters for the
|
||||
// API request.
|
||||
ErrCodeInvalidParameterException = "InvalidParameterException"
|
||||
|
||||
// ErrCodeMissingVersionException for service response error code
|
||||
// "MissingVersionException".
|
||||
//
|
||||
// Amazon ECS is unable to determine the current version of the Amazon ECS container
|
||||
// agent on the container instance and does not have enough information to proceed
|
||||
// with an update. This could be because the agent running on the container
|
||||
// instance is an older or custom version that does not use our version information.
|
||||
ErrCodeMissingVersionException = "MissingVersionException"
|
||||
|
||||
// ErrCodeNoUpdateAvailableException for service response error code
|
||||
// "NoUpdateAvailableException".
|
||||
//
|
||||
// There is no update available for this Amazon ECS container agent. This could
|
||||
// be because the agent is already running the latest version, or it is so old
|
||||
// that there is no update path to the current version.
|
||||
ErrCodeNoUpdateAvailableException = "NoUpdateAvailableException"
|
||||
|
||||
// ErrCodePlatformTaskDefinitionIncompatibilityException for service response error code
|
||||
// "PlatformTaskDefinitionIncompatibilityException".
|
||||
//
|
||||
// The specified platform version does not satisfy the task definition’s required
|
||||
// capabilities.
|
||||
ErrCodePlatformTaskDefinitionIncompatibilityException = "PlatformTaskDefinitionIncompatibilityException"
|
||||
|
||||
// ErrCodePlatformUnknownException for service response error code
|
||||
// "PlatformUnknownException".
|
||||
//
|
||||
// The specified platform version does not exist.
|
||||
ErrCodePlatformUnknownException = "PlatformUnknownException"
|
||||
|
||||
// ErrCodeServerException for service response error code
|
||||
// "ServerException".
|
||||
//
|
||||
// These errors are usually caused by a server issue.
|
||||
ErrCodeServerException = "ServerException"
|
||||
|
||||
// ErrCodeServiceNotActiveException for service response error code
|
||||
// "ServiceNotActiveException".
|
||||
//
|
||||
// The specified service is not active. You can't update a service that is inactive.
|
||||
// If you have previously deleted a service, you can re-create it with CreateService.
|
||||
ErrCodeServiceNotActiveException = "ServiceNotActiveException"
|
||||
|
||||
// ErrCodeServiceNotFoundException for service response error code
|
||||
// "ServiceNotFoundException".
|
||||
//
|
||||
// The specified service could not be found. You can view your available services
|
||||
// with ListServices. Amazon ECS services are cluster-specific and region-specific.
|
||||
ErrCodeServiceNotFoundException = "ServiceNotFoundException"
|
||||
|
||||
// ErrCodeTargetNotFoundException for service response error code
|
||||
// "TargetNotFoundException".
|
||||
//
|
||||
// The specified target could not be found. You can view your available container
|
||||
// instances with ListContainerInstances. Amazon ECS container instances are
|
||||
// cluster-specific and region-specific.
|
||||
ErrCodeTargetNotFoundException = "TargetNotFoundException"
|
||||
|
||||
// ErrCodeUnsupportedFeatureException for service response error code
|
||||
// "UnsupportedFeatureException".
|
||||
//
|
||||
// The specified task is not supported in this region.
|
||||
ErrCodeUnsupportedFeatureException = "UnsupportedFeatureException"
|
||||
|
||||
// ErrCodeUpdateInProgressException for service response error code
|
||||
// "UpdateInProgressException".
|
||||
//
|
||||
// There is already a current Amazon ECS container agent update in progress
|
||||
// on the specified container instance. If the container agent becomes disconnected
|
||||
// while it is in a transitional stage, such as PENDING or STAGING, the update
|
||||
// process can get stuck in that state. However, when the agent reconnects,
|
||||
// it resumes where it stopped previously.
|
||||
ErrCodeUpdateInProgressException = "UpdateInProgressException"
|
||||
)
|
95
vendor/github.com/aws/aws-sdk-go/service/ecs/service.go
generated
vendored
95
vendor/github.com/aws/aws-sdk-go/service/ecs/service.go
generated
vendored
|
@ -1,95 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package ecs
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/signer/v4"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
|
||||
)
|
||||
|
||||
// ECS provides the API operation methods for making requests to
|
||||
// Amazon EC2 Container Service. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// ECS methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type ECS struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
// Used for custom client initialization logic
|
||||
var initClient func(*client.Client)
|
||||
|
||||
// Used for custom request initialization logic
|
||||
var initRequest func(*request.Request)
|
||||
|
||||
// Service information constants
|
||||
const (
|
||||
ServiceName = "ecs" // Service endpoint prefix API calls made to.
|
||||
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
|
||||
)
|
||||
|
||||
// New creates a new instance of the ECS client with a session.
|
||||
// If additional configuration is needed for the client instance use the optional
|
||||
// aws.Config parameter to add your extra config.
|
||||
//
|
||||
// Example:
|
||||
// // Create a ECS client from just a session.
|
||||
// svc := ecs.New(mySession)
|
||||
//
|
||||
// // Create a ECS client with additional configuration
|
||||
// svc := ecs.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *ECS {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
// newClient creates, initializes and returns a new service client instance.
|
||||
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *ECS {
|
||||
svc := &ECS{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2014-11-13",
|
||||
JSONVersion: "1.1",
|
||||
TargetPrefix: "AmazonEC2ContainerServiceV20141113",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a ECS operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *ECS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
// Run custom request initialization if present
|
||||
if initRequest != nil {
|
||||
initRequest(req)
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
224
vendor/github.com/aws/aws-sdk-go/service/ecs/waiters.go
generated
vendored
224
vendor/github.com/aws/aws-sdk-go/service/ecs/waiters.go
generated
vendored
|
@ -1,224 +0,0 @@
|
|||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package ecs
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
)
|
||||
|
||||
// WaitUntilServicesInactive uses the Amazon ECS API operation
|
||||
// DescribeServices to wait for a condition to be met before returning.
|
||||
// If the condition is not met within the max attempt window, an error will
|
||||
// be returned.
|
||||
func (c *ECS) WaitUntilServicesInactive(input *DescribeServicesInput) error {
|
||||
return c.WaitUntilServicesInactiveWithContext(aws.BackgroundContext(), input)
|
||||
}
|
||||
|
||||
// WaitUntilServicesInactiveWithContext is an extended version of WaitUntilServicesInactive.
|
||||
// With the support for passing in a context and options to configure the
|
||||
// Waiter and the underlying request options.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If
|
||||
// the context is nil a panic will occur. In the future the SDK may create
|
||||
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *ECS) WaitUntilServicesInactiveWithContext(ctx aws.Context, input *DescribeServicesInput, opts ...request.WaiterOption) error {
|
||||
w := request.Waiter{
|
||||
Name: "WaitUntilServicesInactive",
|
||||
MaxAttempts: 40,
|
||||
Delay: request.ConstantWaiterDelay(15 * time.Second),
|
||||
Acceptors: []request.WaiterAcceptor{
|
||||
{
|
||||
State: request.FailureWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "failures[].reason",
|
||||
Expected: "MISSING",
|
||||
},
|
||||
{
|
||||
State: request.SuccessWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "services[].status",
|
||||
Expected: "INACTIVE",
|
||||
},
|
||||
},
|
||||
Logger: c.Config.Logger,
|
||||
NewRequest: func(opts []request.Option) (*request.Request, error) {
|
||||
var inCpy *DescribeServicesInput
|
||||
if input != nil {
|
||||
tmp := *input
|
||||
inCpy = &tmp
|
||||
}
|
||||
req, _ := c.DescribeServicesRequest(inCpy)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return req, nil
|
||||
},
|
||||
}
|
||||
w.ApplyOptions(opts...)
|
||||
|
||||
return w.WaitWithContext(ctx)
|
||||
}
|
||||
|
||||
// WaitUntilServicesStable uses the Amazon ECS API operation
|
||||
// DescribeServices to wait for a condition to be met before returning.
|
||||
// If the condition is not met within the max attempt window, an error will
|
||||
// be returned.
|
||||
func (c *ECS) WaitUntilServicesStable(input *DescribeServicesInput) error {
|
||||
return c.WaitUntilServicesStableWithContext(aws.BackgroundContext(), input)
|
||||
}
|
||||
|
||||
// WaitUntilServicesStableWithContext is an extended version of WaitUntilServicesStable.
|
||||
// With the support for passing in a context and options to configure the
|
||||
// Waiter and the underlying request options.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If
|
||||
// the context is nil a panic will occur. In the future the SDK may create
|
||||
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *ECS) WaitUntilServicesStableWithContext(ctx aws.Context, input *DescribeServicesInput, opts ...request.WaiterOption) error {
|
||||
w := request.Waiter{
|
||||
Name: "WaitUntilServicesStable",
|
||||
MaxAttempts: 40,
|
||||
Delay: request.ConstantWaiterDelay(15 * time.Second),
|
||||
Acceptors: []request.WaiterAcceptor{
|
||||
{
|
||||
State: request.FailureWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "failures[].reason",
|
||||
Expected: "MISSING",
|
||||
},
|
||||
{
|
||||
State: request.FailureWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "services[].status",
|
||||
Expected: "DRAINING",
|
||||
},
|
||||
{
|
||||
State: request.FailureWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "services[].status",
|
||||
Expected: "INACTIVE",
|
||||
},
|
||||
{
|
||||
State: request.SuccessWaiterState,
|
||||
Matcher: request.PathWaiterMatch, Argument: "length(services[?!(length(deployments) == `1` && runningCount == desiredCount)]) == `0`",
|
||||
Expected: true,
|
||||
},
|
||||
},
|
||||
Logger: c.Config.Logger,
|
||||
NewRequest: func(opts []request.Option) (*request.Request, error) {
|
||||
var inCpy *DescribeServicesInput
|
||||
if input != nil {
|
||||
tmp := *input
|
||||
inCpy = &tmp
|
||||
}
|
||||
req, _ := c.DescribeServicesRequest(inCpy)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return req, nil
|
||||
},
|
||||
}
|
||||
w.ApplyOptions(opts...)
|
||||
|
||||
return w.WaitWithContext(ctx)
|
||||
}
|
||||
|
||||
// WaitUntilTasksRunning uses the Amazon ECS API operation
|
||||
// DescribeTasks to wait for a condition to be met before returning.
|
||||
// If the condition is not met within the max attempt window, an error will
|
||||
// be returned.
|
||||
func (c *ECS) WaitUntilTasksRunning(input *DescribeTasksInput) error {
|
||||
return c.WaitUntilTasksRunningWithContext(aws.BackgroundContext(), input)
|
||||
}
|
||||
|
||||
// WaitUntilTasksRunningWithContext is an extended version of WaitUntilTasksRunning.
|
||||
// With the support for passing in a context and options to configure the
|
||||
// Waiter and the underlying request options.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If
|
||||
// the context is nil a panic will occur. In the future the SDK may create
|
||||
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *ECS) WaitUntilTasksRunningWithContext(ctx aws.Context, input *DescribeTasksInput, opts ...request.WaiterOption) error {
|
||||
w := request.Waiter{
|
||||
Name: "WaitUntilTasksRunning",
|
||||
MaxAttempts: 100,
|
||||
Delay: request.ConstantWaiterDelay(6 * time.Second),
|
||||
Acceptors: []request.WaiterAcceptor{
|
||||
{
|
||||
State: request.FailureWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "tasks[].lastStatus",
|
||||
Expected: "STOPPED",
|
||||
},
|
||||
{
|
||||
State: request.FailureWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "failures[].reason",
|
||||
Expected: "MISSING",
|
||||
},
|
||||
{
|
||||
State: request.SuccessWaiterState,
|
||||
Matcher: request.PathAllWaiterMatch, Argument: "tasks[].lastStatus",
|
||||
Expected: "RUNNING",
|
||||
},
|
||||
},
|
||||
Logger: c.Config.Logger,
|
||||
NewRequest: func(opts []request.Option) (*request.Request, error) {
|
||||
var inCpy *DescribeTasksInput
|
||||
if input != nil {
|
||||
tmp := *input
|
||||
inCpy = &tmp
|
||||
}
|
||||
req, _ := c.DescribeTasksRequest(inCpy)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return req, nil
|
||||
},
|
||||
}
|
||||
w.ApplyOptions(opts...)
|
||||
|
||||
return w.WaitWithContext(ctx)
|
||||
}
|
||||
|
||||
// WaitUntilTasksStopped uses the Amazon ECS API operation
|
||||
// DescribeTasks to wait for a condition to be met before returning.
|
||||
// If the condition is not met within the max attempt window, an error will
|
||||
// be returned.
|
||||
func (c *ECS) WaitUntilTasksStopped(input *DescribeTasksInput) error {
|
||||
return c.WaitUntilTasksStoppedWithContext(aws.BackgroundContext(), input)
|
||||
}
|
||||
|
||||
// WaitUntilTasksStoppedWithContext is an extended version of WaitUntilTasksStopped.
|
||||
// With the support for passing in a context and options to configure the
|
||||
// Waiter and the underlying request options.
|
||||
//
|
||||
// The context must be non-nil and will be used for request cancellation. If
|
||||
// the context is nil a panic will occur. In the future the SDK may create
|
||||
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
|
||||
// for more information on using Contexts.
|
||||
func (c *ECS) WaitUntilTasksStoppedWithContext(ctx aws.Context, input *DescribeTasksInput, opts ...request.WaiterOption) error {
|
||||
w := request.Waiter{
|
||||
Name: "WaitUntilTasksStopped",
|
||||
MaxAttempts: 100,
|
||||
Delay: request.ConstantWaiterDelay(6 * time.Second),
|
||||
Acceptors: []request.WaiterAcceptor{
|
||||
{
|
||||
State: request.SuccessWaiterState,
|
||||
Matcher: request.PathAllWaiterMatch, Argument: "tasks[].lastStatus",
|
||||
Expected: "STOPPED",
|
||||
},
|
||||
},
|
||||
Logger: c.Config.Logger,
|
||||
NewRequest: func(opts []request.Option) (*request.Request, error) {
|
||||
var inCpy *DescribeTasksInput
|
||||
if input != nil {
|
||||
tmp := *input
|
||||
inCpy = &tmp
|
||||
}
|
||||
req, _ := c.DescribeTasksRequest(inCpy)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return req, nil
|
||||
},
|
||||
}
|
||||
w.ApplyOptions(opts...)
|
||||
|
||||
return w.WaitWithContext(ctx)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue