]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / private / protocol / xml / xmlutil / build.go
index 07764c8626499bc05178c6939e0011662befdc58..cf981fe951324275764e9daa814cb7cee40e63ec 100644 (file)
@@ -87,15 +87,13 @@ func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag refle
        }
 }
 
-// buildStruct adds a struct and its fields to the current XMLNode. All fields any any nested
+// buildStruct adds a struct and its fields to the current XMLNode. All fields and any nested
 // types are converted to XMLNodes also.
 func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
        if !value.IsValid() {
                return nil
        }
 
-       fieldAdded := false
-
        // unwrap payloads
        if payload := tag.Get("payload"); payload != "" {
                field, _ := value.Type().FieldByName(payload)
@@ -123,6 +121,8 @@ func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag refl
                child.Attr = append(child.Attr, ns)
        }
 
+       var payloadFields, nonPayloadFields int
+
        t := value.Type()
        for i := 0; i < value.NumField(); i++ {
                member := elemOf(value.Field(i))
@@ -137,8 +137,10 @@ func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag refl
 
                mTag := field.Tag
                if mTag.Get("location") != "" { // skip non-body members
+                       nonPayloadFields++
                        continue
                }
+               payloadFields++
 
                if protocol.CanSetIdempotencyToken(value.Field(i), field) {
                        token := protocol.GetIdempotencyToken()
@@ -153,11 +155,11 @@ func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag refl
                if err := b.buildValue(member, child, mTag); err != nil {
                        return err
                }
-
-               fieldAdded = true
        }
 
-       if fieldAdded { // only append this child if we have one ore more valid members
+       // Only case where the child shape is not added is if the shape only contains
+       // non-payload fields, e.g headers/query.
+       if !(payloadFields == 0 && nonPayloadFields > 0) {
                current.AddChild(child)
        }