-
Notifications
You must be signed in to change notification settings - Fork 226
Support nested paths in field config specifically list type members #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @mbaijal. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
for x, elem := range elements { | ||
if elem == "" { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is fine for now. I suppose we could also warn or panic if the ..
notation was used to indicate a non-list/map field but I'm cool just ignoring for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this check is required since the path string in case of a list is currently split into 3 elements and we need to ignore the second one -
input Path - ScalableTargets..CreationTime
the elements array in line 254 - ["ScalableTargets", "", "CreationTime"]
and we need to make sure we don't process the second elem. Another option would be to directly parse for ".." and handle lists but that seemed unnecessary at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaypipes just making sure we are on the same page 👆🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we're all good.
shape *awssdkmodel.Shape, | ||
path string, | ||
) (*awssdkmodel.ShapeRef, bool) { | ||
elements := strings.Split(path, ".") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth calling out in the docstring that ..
notation for list/map types is currently ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, i will add the comment based on the discussion on the above comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment and TODO.
elemType := shapeRef.Shape.Type | ||
switch elemType { | ||
case "list": | ||
shape = shapeRef.Shape.MemberRef.Shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we should support map
type as well, which would be:
case "map":
shape = shapeRef.Shape.ValueRef.Shape
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do that in a followup PR, though, since this one is for lists only (and dealing with map types in the code generator is a little tougher anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, created an issue here - aws-controllers-k8s/community#936
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this worthy of some simple unit tests in the sdk_helper_test.go
file?
Probably, let me give that a go. |
b6ba086
to
7ffdf76
Compare
7ffdf76
to
b32639c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
/ok-to-test |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: A-Hilaly, jaypipes, mbaijal, RedbackThomson The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…rces (#39) Issue #, if available: aws-controllers-k8s/community#932 Description of changes: Add creationTime to Status for ScalableTarget and ScalingPolicy resources based off of [code gen changes in this PR.](aws-controllers-k8s/code-generator#183) TODO: Add required check to the existing integration test. Testing Manually tested that the field is present in the Status of the `kubectl get` response. Kind tests pass locally By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue #, if available:
aws-controllers-k8s/community#932
Description of changes:
getMemberByPath
checks the shape type as it loops through members to ensure lists are handled correctly. Currently I have simply ignored the empty element created by the splitting of the string on the single dot instead of handling the double dot notation explicitly. Open to comments.Also added a Unit Test for the same.
Testing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.