-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fieldpath): Handle case differences in structure member names
This patch updates the `memberShapeRef` function in the `fieldpath` package to handle case differences between struct member names in the ACK model and the AWS SDK Model. Previously, the function assumed that member names in the ACK model and AWS SDK model were identical. However, this is not always the case, as some field names may have different casing (e.g `AWSVPCConfiguration` in the ACK model and `AwsVpcConfiguration` in the AWS SDK model). To address this issue, the function now leverages `strings.EqualFold` to compare the member names case isensitively. Signed-off-by: Amine Hilaly <hilalyamine@gmail.com>
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters