Skip to content

Changing back TaskProtectionResponse to use pointers for nested struct fields #4559

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

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

mye956
Copy link
Contributor

@mye956 mye956 commented Apr 3, 2025

Summary

This PR will change back the TaskProtectionResponse struct to have pointers to its struct fields (e.g. ProtectionTask and Failure) so that the response body will respect the omitempty.

Implementation details

  • Changed back types.* to *types.* for the struct fields of TaskProtectionResponse

Testing

  • Modified the unit tests to also test that the response JSON string is what we intend it to be
  • Manual testing

Before this change:

root@e71d43e2b5e5:/# curl --request GET ${ECS_AGENT_URI}/task-protection/v1/state
{"protection":{"ExpirationDate":null,"ProtectionEnabled":false,"TaskArn":"arn:aws:ecs:us-west-2:*:task/963adc2fcf1d4095bff50879c2840d01"},"failure":{"Arn":null,"Detail":null,"Reason":null}}

After:

root@c811d7572190:/# curl --request GET ${ECS_AGENT_URI}/task-protection/v1/state
{"protection":{"ExpirationDate":null,"ProtectionEnabled":false,"TaskArn":"arn:aws:ecs:us-west-2:*:task/b513ca611b3f48efabc0d753978ed91a"}}

New tests cover the changes: yes

Description for the changelog

Bugfix - Change back to having struct field pointers within TaskProtectionResponse

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?

Does this PR include the addition of new environment variables in the README?

Licensing

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

@mye956 mye956 force-pushed the fix-task-protection branch 5 times, most recently from f19690f to 43bd527 Compare April 4, 2025 17:45
@mye956 mye956 marked this pull request as ready for review April 4, 2025 17:45
@mye956 mye956 requested a review from a team as a code owner April 4, 2025 17:45
@mye956 mye956 added the bot/test label Apr 4, 2025
@mye956 mye956 changed the title WIP Changing back TaskProtectionResponse to use pointers for nested struct fields Apr 4, 2025
@@ -69,19 +69,19 @@ func (taskProtection *taskProtection) String() string {

// TaskProtectionResponse is response type for all Update/GetTaskProtection requests
type TaskProtectionResponse struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible for this to be three different structs? It seems that Protection, Failure, and RequestID+Error should never be in the same response, based on the public documentation. Just a thought; I see that the tests now enforce this, which is sufficient.

Copy link
Contributor

@ShelbyZ ShelbyZ left a comment

Choose a reason for hiding this comment

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

Do we have or need a test that covers the omitempty for Failures?

@mye956
Copy link
Contributor Author

mye956 commented Apr 7, 2025

Do we have or need a test that covers the omitempty for Failures?

I think the happy case scenario cover this.

…t fields

fix unit test to include asserting response JSON body
@mye956 mye956 force-pushed the fix-task-protection branch from 43bd527 to 11787f3 Compare April 7, 2025 20:02
@mye956 mye956 added the bot/test label Apr 7, 2025
@mye956 mye956 enabled auto-merge (rebase) April 7, 2025 23:06
@mye956 mye956 merged commit 4385ba1 into aws:dev Apr 7, 2025
40 of 41 checks passed
@TheanLim TheanLim mentioned this pull request Apr 9, 2025
@mye956 mye956 deleted the fix-task-protection branch April 28, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants