Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pkg/fieldpath/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,17 @@ func memberShapeRef(
}
switch shapeRef.Shape.Type {
case "structure":
return shapeRef.Shape.MemberRefs[memberName]
// We are looking for a member of a structure. Since the ACK fields and
// the AWS SDK fields may have different casing (e.g AWSVPCConfiguration
// and AwsVpcConfiguration) we need to perform a case insensitive
// comparison to find the correct member reference.
for memberRefName, memberRefShape := range shapeRef.Shape.MemberRefs {
if strings.EqualFold(memberRefName, memberName) {
return memberRefShape
}
}
// If no matching member is found, return nil.
return nil
case "list":
return memberShapeRef(&shapeRef.Shape.MemberRef, memberName)
case "map":
Expand Down
13 changes: 13 additions & 0 deletions pkg/fieldpath/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ func TestShapeRef(t *testing.T) {
},
},
},
"WeirdlycasEdType": &awssdkmodel.ShapeRef{
ShapeName: "WeirdlycasEdType",
Shape: &awssdkmodel.Shape{
Type: "string",
},
},
},
},
}
Expand Down Expand Up @@ -220,4 +226,11 @@ func TestShapeRef(t *testing.T) {

// Calling ShapeRef should not modify the original Path
require.Equal("Author.Books.ChapterPageCounts.PageCount", p.String())

// Case-insensitive comparisons...
p = fieldpath.FromString("Author.WeirdlyCasedType")
ref = p.ShapeRef(authShapeRef)
require.NotNil(ref)
require.Equal("WeirdlycasEdType", ref.ShapeName)
require.Equal("string", ref.Shape.Type)
}