Skip to content
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

Handle nil fields in response from describe API output - readOne and readMany #34

Merged
merged 1 commit into from
Mar 25, 2021

Conversation

surajkota
Copy link
Member

@surajkota surajkota commented Mar 19, 2021

Description of changes:

Currently, we create a copy for the current resource state in sdkFind and merge the output of describe output if it is non-nil. This doesn't work for fields that can toggle between nil and non-nil. The latest resource should match the output from AWS service. This PR addresses this issue

Testing

with sagemaker controller aws-controllers-k8s/sagemaker-controller#7

Notes to the reviewer

Change is not implemented for the ko.Status.ACKResourceMetadata field because the only case I see where it can toggle is if the user changes the name of resource they created, in which case sdkFind will throw an ackerr.NotFound error and sdkCreate should overwrite the ARN.

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

Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

See inline for a requested change. Also, you will need to modify the unit tests in pkg/generate

pkg/generate/code/set_resource.go Outdated Show resolved Hide resolved
@surajkota surajkota self-assigned this Mar 25, 2021
@surajkota surajkota force-pushed the before_delta branch 2 times, most recently from 4332bce to e135540 Compare March 25, 2021 02:13
@surajkota surajkota changed the title handle nil response for fields from describe output Handle nil response for fields from describe output Mar 25, 2021
@surajkota surajkota changed the title Handle nil response for fields from describe output Handle nil fields in response from describe API output - readOne and readMany Mar 25, 2021
@surajkota
Copy link
Member Author

surajkota commented Mar 25, 2021

@jaypipes Thanks for the quick review, PR is now ready to merge. Please check notes to the reviewer in the description

@surajkota surajkota added the kind/bug Categorizes issue or PR as related to a bug. label Mar 25, 2021
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

@surajkota looks good to me. I'd like @vijtrip2 to review this first, though, and just have an extra set of eyes on this part of the generated codebase. Vijay, please double-check that by setting Spac and Status fields to nil for empty fields in a Output shape, we would not be overriding any important or defaulted values...

pkg/generate/code/set_resource.go Outdated Show resolved Hide resolved
@vijtrip2
Copy link
Contributor

@surajkota looks good to me. I'd like @vijtrip2 to review this first, though, and just have an extra set of eyes on this part of the generated codebase. Vijay, please double-check that by setting Spac and Status fields to nil for empty fields in a Output shape, we would not be overriding any important or defaulted values...

Looks good to me.

  • I double checked that We are only updating spec fields for ReadOne, ReadMany and not Create. This was the existing behavior and still being preserved. 👍
  • And In my knowledge of AWS APIs, the ReadOne/ReadMany/CreateOutput result are consistent with CreateInput. If field is being present in CreateInput, it is reflected similarly in ReadOne/CreateOutput. So I am not concerned about overriding default values.

Copy link
Contributor

@vijtrip2 vijtrip2 left a comment

Choose a reason for hiding this comment

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

LGTM!

@jaypipes jaypipes merged commit 338d010 into aws-controllers-k8s:main Mar 25, 2021
@surajkota
Copy link
Member Author

Great! thanks folks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants