diff --git a/diff.txt b/diff.txt new file mode 100644 index 00000000..b82b8c8d --- /dev/null +++ b/diff.txt @@ -0,0 +1,25 @@ +diff --git a/pkg/fieldpath/path.go b/pkg/fieldpath/path.go +index d607318..d20b2b4 100644 +--- a/pkg/fieldpath/path.go ++++ b/pkg/fieldpath/path.go +@@ -242,7 +242,19 @@ func memberShapeRef( + } + switch shapeRef.Shape.Type { + case "structure": +- return shapeRef.Shape.MemberRefs[memberName] ++ // We are looking for a member of a structure. We need to loop through ++ // the structure's members to find the member with the name we are ++ // looking for. ++ // Since the ACK fields and the AWS SDK fields are not exactly the same, ++ // we need to EqualFold the member names. e.g in ECS Service resource, ++ // AWSVPCConfiguration is the field name in the ACK model, but ++ // AwsVpcConfiguration is the field name in the AWS SDK model. ++ for memberRefName, memberRefShape := range shapeRef.Shape.MemberRefs { ++ if strings.EqualFold(memberRefName, memberName) { ++ return memberRefShape ++ } ++ } ++ return nil + case "list": + return memberShapeRef(&shapeRef.Shape.MemberRef, memberName) + case "map": diff --git a/pkg/fieldpath/path.go b/pkg/fieldpath/path.go index d6073187..7513ad4d 100644 --- a/pkg/fieldpath/path.go +++ b/pkg/fieldpath/path.go @@ -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": diff --git a/pkg/fieldpath/path_test.go b/pkg/fieldpath/path_test.go index 180b4025..5127b25a 100644 --- a/pkg/fieldpath/path_test.go +++ b/pkg/fieldpath/path_test.go @@ -148,6 +148,12 @@ func TestShapeRef(t *testing.T) { }, }, }, + "WeirdlycasEdType": &awssdkmodel.ShapeRef{ + ShapeName: "WeirdlycasEdType", + Shape: &awssdkmodel.Shape{ + Type: "string", + }, + }, }, }, } @@ -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) }