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

Embedded structs in models #941

Closed

Conversation

skyscrapr
Copy link

@skyscrapr skyscrapr commented Mar 5, 2024

A number of requests have been made to support embedded structs in models.
#242 has been open for over 3 years.

However I understand this might be a fairly big effort to implement.
Therefore I attempted a minimal change to implement a solution.

See what you think and if appropriate happy to work to get it merged.
Would help me on some other providers that I'm building.

The idea is to allow this type of struct embedding:

type SimpleStruct struct {
	Field1 string `tfsdk:"field1"`
	Field2 int    `tfsdk:"field2"`
	Field3 bool   `tfsdk:"field3"`
}

type ComplexStruct struct {
	SimpleStruct
	Field4 string `tfsdk:"field4"`
}

@skyscrapr skyscrapr requested a review from a team as a code owner March 5, 2024 05:25
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 5, 2024

CLA assistant check
All committers have signed the CLA.

@DariuszPorowski
Copy link

Hi @bflad @austinvalle

Do you have any thoughts / plans to merge it? or any other ideas to address #242

@austinvalle
Copy link
Member

Hey there @skyscrapr 👋, thanks for the submission and apologies on the delayed review!

We've recently been reviewing #242, your PR here, and the previous community PR #667, and we've landed on an alternative implementation (#1021) using field indexes that I believe will achieve the minimal implementation goal you've proposed here, while preserving our original validation rules. (your thinking here definitely aligns with our goal for the feature!)

With that said, I'm going to close this PR in favor of #1021, which we're hoping to merge/release with the next minor version of terraform-plugin-framework. If you're interested in testing out the PR, you can install it with:

go get -u github.com/hashicorp/terraform-plugin-framework@2ccf8f265f8d5eae49f226fb15501e62b5c5aaf2

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants