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

autoflex: wire up option functions, add IgnoreFieldNames option #36437

Merged
merged 1 commit into from
May 2, 2024

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Mar 18, 2024

Description

This change implements AutoFlex options, allowing custom options to be passed to flex.Expand or flex.Flatten. The changes include:

  • Adding a new AutoFlexOptions struct, which stores all configurable options
  • Embedding the AutoFlexOptions struct into the autoExpand and autoFlatten flexer structs
  • Adjusting the AutoFlexOptionsFunc signature to accept a pointer to AutoFlexOptions

As a first use case, the IgnoreFieldNames option was added. This option is a slice of strings, with a default value of []string{"Tags"}. This replaces the previously hardcoded logic which skipped processing of any fields named Tags, and instead makes this configurable. Test cases have been added to exercise the behavior with default options and overrides to remove defaults and add custom values.

Relations

Relates #36332
Depends on hashicorp/terraform-plugin-framework#961
Depends on #36992

References

Output from Acceptance Testing

% go test ./internal/framework/flex/...
ok      github.com/hashicorp/terraform-provider-aws/internal/framework/flex     0.488s

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed size/L Managed by automation to categorize the size of a PR. labels Mar 18, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Mar 18, 2024
Copy link

Thank you for your contribution! 🚀

A new usage of AWS SDK for Go V1 was detected. Please prefer AWS SDK for Go V2 for all net-new services. If this is an enhancement or bug fix to an existing AWS SDK Go V1 based resource, this comment can be safely ignored.

For additional information refer to the AWS SDK for Go Versions page in the contributor guide.

@jar-b jar-b force-pushed the f-autoflex-options branch 2 times, most recently from 399f866 to 2a07d8e Compare March 19, 2024 17:13
@github-actions github-actions bot added the size/XL Managed by automation to categorize the size of a PR. label Mar 19, 2024
@jar-b jar-b marked this pull request as ready for review April 25, 2024 18:31
This change implements AutoFlex options, allowing custom options to be passed to `flex.Expand` or `flex.Flatten`. The changes include:

- Adding a new `AutoFlexOptions` struct, which stores all configurable options
- Embedding the `AutoFlexOptions` struct into the `autoExpand` and `autoFlatten` flexer structs
- Adjusting the `AutoFlexOptionsFunc` signature to accept a pointer to `AutoFlexOptions`

As a first use case, the `IgnoreFieldNames` option was added. This option is a slice of strings, with a default value of `[]string{"Tags"}`. This replaces the previously hardcoded logic which skipped processing of any fields named `Tags`, and instead makes this configurable. Test cases have been added to exercise the behavior with default options and overrides to remove defaults and add custom values.
@jar-b jar-b added the flex Pertains to FLatteners and EXpanders. label Apr 30, 2024
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% go test ./internal/framework/flex 
ok  	github.com/hashicorp/terraform-provider-aws/internal/framework/flex	0.817s

@jar-b jar-b merged commit 376e1a7 into main May 2, 2024
43 checks passed
@jar-b jar-b deleted the f-autoflex-options branch May 2, 2024 18:05
@github-actions github-actions bot added this to the v5.48.0 milestone May 2, 2024
github-actions bot pushed a commit that referenced this pull request May 2, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label May 2, 2024
Copy link

github-actions bot commented May 2, 2024

This functionality has been released in v5.48.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!

Copy link

github-actions bot commented Jun 2, 2024

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
flex Pertains to FLatteners and EXpanders. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants