-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Bug: Create own struct to be able to add omitempty json tag on attributes #35950
Bug: Create own struct to be able to add omitempty json tag on attributes #35950
Conversation
Community NoteVoting for Prioritization
For Submitters
|
6f1cbfe
to
571736d
Compare
Hey @stromp 👋 Thank you for your contribution here! I'm not one of the people who will be doing a final review on this, but I wanted to note that I added the |
hi @justinretzolk. I guess it is a bit how you look at it. Currently the resource will give you a different JSON result then the original JSON returned by the AWS API would. Since the purpose of the attribute is that it returns the API JSON I would personally classify this as a bug. |
571736d
to
f43bd49
Compare
I have just rebased the branch since it became out of sync due to the aws sdk update. Can I ask for some attention to get this merged? |
fix indenting
8b858eb
to
a9e5047
Compare
This generic helper function strips nil values, empty arrays, and empty objects from the provided byte slice, preventing nil values from the AWS API response from being stored in the computed `json` attribute.
… case This test verifies that nil values returned in the ApprovalRule response are appropriately scrubbed from the `json` attribute. ```console % make testacc PKG=ssm TESTS=TestAccSSMPatchBaseline_ make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.22.2 test ./internal/service/ssm/... -v -count 1 -parallel 20 -run='TestAccSSMPatchBaseline_' -timeout 360m --- PASS: TestAccSSMPatchBaseline_disappears (31.31s) === CONT TestAccSSMPatchBaseline_tags_null --- PASS: TestAccSSMPatchBaseline_rejectPatchesAction (37.77s) === CONT TestAccSSMPatchBaseline_tags_DefaultTags_providerOnly --- PASS: TestAccSSMPatchBaseline_approvedPatchesNonSec (39.94s) === CONT TestAccSSMPatchBaseline_tags_DefaultTags_updateToProviderOnly --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_nullOverlappingResourceTag (43.85s) === CONT TestAccSSMPatchBaseline_tags_DefaultTags_updateToResourceOnly --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_nullNonOverlappingResourceTag (43.91s) === CONT TestAccSSMPatchBaseline_tags_DefaultTags_overlapping --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_emptyProviderOnlyTag (45.51s) === CONT TestAccSSMPatchBaseline_tags_EmptyTag_OnUpdate_Replace --- PASS: TestAccSSMPatchBaseline_tags_ComputedTag_OnCreate (49.76s) --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_emptyResourceTag (50.56s) --- PASS: TestAccSSMPatchBaseline_operatingSystem (56.32s) --- PASS: TestAccSSMPatchBaseline_sources (59.38s) --- PASS: TestAccSSMPatchBaseline_approveUntilDateParam (59.69s) --- PASS: TestAccSSMPatchBaseline_approvalRuleEmpty (67.48s) --- PASS: TestAccSSMPatchBaseline_basic (67.74s) --- PASS: TestAccSSMPatchBaseline_tags_AddOnUpdate (68.98s) --- PASS: TestAccSSMPatchBaseline_tags_ComputedTag_OnUpdate_Replace (70.36s) --- PASS: TestAccSSMPatchBaseline_tags_EmptyTag_OnCreate (72.92s) --- PASS: TestAccSSMPatchBaseline_tags_null (42.16s) --- PASS: TestAccSSMPatchBaseline_tags_ComputedTag_OnUpdate_Add (75.00s) --- PASS: TestAccSSMPatchBaseline_tags_EmptyTag_OnUpdate_Add (85.97s) --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_updateToResourceOnly (42.60s) --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_updateToProviderOnly (46.77s) --- PASS: TestAccSSMPatchBaseline_tags_EmptyTag_OnUpdate_Replace (41.84s) --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_nonOverlapping (89.47s) --- PASS: TestAccSSMPatchBaseline_tags (100.06s) --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_overlapping (59.82s) --- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_providerOnly (77.53s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/ssm 121.254s ```
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 🎉
% make testacc PKG=ssm TESTS=TestAccSSMPatchBaseline_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/ssm/... -v -count 1 -parallel 20 -run='TestAccSSMPatchBaseline_' -timeout 360m
--- PASS: TestAccSSMPatchBaseline_disappears (31.31s)
=== CONT TestAccSSMPatchBaseline_tags_null
--- PASS: TestAccSSMPatchBaseline_rejectPatchesAction (37.77s)
=== CONT TestAccSSMPatchBaseline_tags_DefaultTags_providerOnly
--- PASS: TestAccSSMPatchBaseline_approvedPatchesNonSec (39.94s)
=== CONT TestAccSSMPatchBaseline_tags_DefaultTags_updateToProviderOnly
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_nullOverlappingResourceTag (43.85s)
=== CONT TestAccSSMPatchBaseline_tags_DefaultTags_updateToResourceOnly
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_nullNonOverlappingResourceTag (43.91s)
=== CONT TestAccSSMPatchBaseline_tags_DefaultTags_overlapping
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_emptyProviderOnlyTag (45.51s)
=== CONT TestAccSSMPatchBaseline_tags_EmptyTag_OnUpdate_Replace
--- PASS: TestAccSSMPatchBaseline_tags_ComputedTag_OnCreate (49.76s)
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_emptyResourceTag (50.56s)
--- PASS: TestAccSSMPatchBaseline_operatingSystem (56.32s)
--- PASS: TestAccSSMPatchBaseline_sources (59.38s)
--- PASS: TestAccSSMPatchBaseline_approveUntilDateParam (59.69s)
--- PASS: TestAccSSMPatchBaseline_approvalRuleEmpty (67.48s)
--- PASS: TestAccSSMPatchBaseline_basic (67.74s)
--- PASS: TestAccSSMPatchBaseline_tags_AddOnUpdate (68.98s)
--- PASS: TestAccSSMPatchBaseline_tags_ComputedTag_OnUpdate_Replace (70.36s)
--- PASS: TestAccSSMPatchBaseline_tags_EmptyTag_OnCreate (72.92s)
--- PASS: TestAccSSMPatchBaseline_tags_null (42.16s)
--- PASS: TestAccSSMPatchBaseline_tags_ComputedTag_OnUpdate_Add (75.00s)
--- PASS: TestAccSSMPatchBaseline_tags_EmptyTag_OnUpdate_Add (85.97s)
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_updateToResourceOnly (42.60s)
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_updateToProviderOnly (46.77s)
--- PASS: TestAccSSMPatchBaseline_tags_EmptyTag_OnUpdate_Replace (41.84s)
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_nonOverlapping (89.47s)
--- PASS: TestAccSSMPatchBaseline_tags (100.06s)
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_overlapping (59.82s)
--- PASS: TestAccSSMPatchBaseline_tags_DefaultTags_providerOnly (77.53s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ssm 121.254s
Thanks for your contribution, @stromp! 👍 |
This functionality has been released in v5.61.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Description
The whole struct was returned which marshalled attributes with a null values. Those attributes should be omitted, since you can not use them when you provider the json to AWS.
Relations
Relates #33565
Output from Acceptance Testing
=== RUN TestAccSSMPatchBaseline_basic
=== PAUSE TestAccSSMPatchBaseline_basic
=== CONT TestAccSSMPatchBaseline_basic
--- PASS: TestAccSSMPatchBaseline_basic (34.30s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ssm 34.398s
...