change github.com/aws/aws-sdk-go to be the same revision in kubernetes

This commit is contained in:
Jingfang Liu
2018-10-16 09:34:22 -07:00
parent e0958159f3
commit c6a78cee92
462 changed files with 20605 additions and 85780 deletions

View File

@@ -189,11 +189,6 @@ type MarshalOptions struct {
//
// Enabled by default.
SupportJSONTags bool
// Support other custom struct tag keys, such as `yaml` or `toml`.
// Note that values provided with a custom TagKey must also be supported
// by the (un)marshalers in this package.
TagKey string
}
// An Encoder provides marshaling Go value types to AttributeValues.

View File

@@ -99,12 +99,8 @@ func enumFields(t reflect.Type, opts MarshalOptions) []field {
fieldTag := tag{}
fieldTag.parseAVTag(sf.Tag)
// Because MarshalOptions.TagKey must be explicitly set, use it
// over JSON, which is enabled by default.
if opts.TagKey != "" && fieldTag == (tag{}) {
fieldTag.parseStructTag(opts.TagKey, sf.Tag)
} else if opts.SupportJSONTags && fieldTag == (tag{}) {
fieldTag.parseStructTag("json", sf.Tag)
if opts.SupportJSONTags && fieldTag == (tag{}) {
fieldTag.parseJSONTag(sf.Tag)
}
if fieldTag.Ignore {

View File

@@ -571,65 +571,3 @@ func BenchmarkMarshal(b *testing.B) {
}
}
}
func Test_Encode_YAML_TagKey(t *testing.T) {
input := struct {
String string `yaml:"string"`
EmptyString string `yaml:"empty"`
OmitString string `yaml:"omitted,omitempty"`
Ignored string `yaml:"-"`
Byte []byte `yaml:"byte"`
Float32 float32 `yaml:"float32"`
Float64 float64 `yaml:"float64"`
Int int `yaml:"int"`
Uint uint `yaml:"uint"`
Slice []string `yaml:"slice"`
Map map[string]int `yaml:"map"`
NoTag string
}{
String: "String",
Ignored: "Ignored",
Slice: []string{"one", "two"},
Map: map[string]int{
"one": 1,
"two": 2,
},
NoTag: "NoTag",
}
expected := &dynamodb.AttributeValue{
M: map[string]*dynamodb.AttributeValue{
"string": {S: aws.String("String")},
"empty": {NULL: &trueValue},
"byte": {NULL: &trueValue},
"float32": {N: aws.String("0")},
"float64": {N: aws.String("0")},
"int": {N: aws.String("0")},
"uint": {N: aws.String("0")},
"slice": {
L: []*dynamodb.AttributeValue{
{S: aws.String("one")},
{S: aws.String("two")},
},
},
"map": {
M: map[string]*dynamodb.AttributeValue{
"one": {N: aws.String("1")},
"two": {N: aws.String("2")},
},
},
"NoTag": {S: aws.String("NoTag")},
},
}
enc := NewEncoder(func(e *Encoder) {
e.TagKey = "yaml"
})
actual, err := enc.Encode(input)
if err != nil {
t.Errorf("Encode with input %#v retured error `%s`, expected nil", input, err)
}
compareObjects(t, expected, actual)
}

View File

@@ -24,8 +24,8 @@ func (t *tag) parseAVTag(structTag reflect.StructTag) {
t.parseTagStr(tagStr)
}
func (t *tag) parseStructTag(tag string, structTag reflect.StructTag) {
tagStr := structTag.Get(tag)
func (t *tag) parseJSONTag(structTag reflect.StructTag) {
tagStr := structTag.Get("json")
if len(tagStr) == 0 {
return
}

View File

@@ -35,7 +35,7 @@ func TestTagParse(t *testing.T) {
for i, c := range cases {
actual := tag{}
if c.json {
actual.parseStructTag("json", c.in)
actual.parseJSONTag(c.in)
}
if c.av {
actual.parseAVTag(c.in)