Skip to content

Conversation

mbaijal
Copy link
Contributor

@mbaijal mbaijal commented Sep 7, 2021

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

  1. Generated code for ApplicationAutoscaling and ensured CreationTime field now works as expected. Linked changes in this PR.
  2. Ensured that the SageMaker Controller can be generated using new changes with no diff as expected.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-bot ack-bot requested review from jaypipes and vijtrip2 September 7, 2021 09:04
@ack-bot
Copy link
Collaborator

ack-bot commented Sep 7, 2021

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 👆🏻

Copy link
Collaborator

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, ".")
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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

Copy link
Collaborator

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)

Copy link
Contributor Author

@mbaijal mbaijal Sep 7, 2021

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

Copy link
Contributor

@RedbackThomson RedbackThomson left a 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?

@mbaijal
Copy link
Contributor Author

mbaijal commented Sep 7, 2021

Is this worthy of some simple unit tests in the sdk_helper_test.go file?

Probably, let me give that a go.

@mbaijal mbaijal force-pushed the fields-post-release branch from b6ba086 to 7ffdf76 Compare September 8, 2021 02:55
@mbaijal mbaijal force-pushed the fields-post-release branch from 7ffdf76 to b32639c Compare September 8, 2021 05:58
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@a-hilaly
Copy link
Member

a-hilaly commented Sep 8, 2021

/ok-to-test

@ack-bot ack-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 8, 2021
@a-hilaly
Copy link
Member

a-hilaly commented Sep 8, 2021

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Sep 8, 2021

[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:
  • OWNERS [A-Hilaly,RedbackThomson,jaypipes]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit 9cebd89 into aws-controllers-k8s:main Sep 8, 2021
ack-bot pushed a commit to aws-controllers-k8s/applicationautoscaling-controller that referenced this pull request Sep 8, 2021
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants