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

tfsdk: Support for List and Set Blocks #188

Merged
merged 9 commits into from
Nov 3, 2021
Merged

tfsdk: Support for List and Set Blocks #188

merged 9 commits into from
Nov 3, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Sep 29, 2021

Closes #85

The primary purpose for supporting blocks is to allow previously existing schemas defined by the older Terraform Plugin SDK to not require practitioner breaking changes upon migrating to the framework (except the protocol version and therefore the minimum Terraform CLI version unless a tfprotov5 server implementation is added to this framework as well). This also allows this framework to be muxed with the older framework since the provider schema must match. It is expected that over time any schema definitions including Blocks will migrate to Attributes.

Provider developers should always opt for Attributes in new schema definitions.

@bflad bflad added the enhancement New feature or request label Sep 29, 2021
@bflad bflad requested a review from a team September 29, 2021 21:18
bflad added a commit that referenced this pull request Sep 29, 2021
@bflad bflad self-assigned this Oct 29, 2021
bflad added 3 commits October 29, 2021 16:12
Reference: #85

This implementation is analogous to the existing `Attributes` field on `Attribute`. While the framework handles the major differences at the protocol layer during conversion, it also must enforce the constraints of the underlying type system.

Some notable features include:

* Defining schemas is very similar to `Attributes`.
* Accessing and writing `Config`, `Plan`, and `State` data is no different than `Attributes` with the same nesting mode.
* Blocks are structural by Terraform's and cty's definition, meaning there is no concept of `Computed`, `Optional`, `Required`, or `Sensitive`. Checks are in place to enforce these constraints.

The primary purpose for supporting blocks is to allow previously existing schemas defined by the older Terraform Plugin SDK to not require practitioner breaking changes upon migrating to the framework (except the protocol version and therefore the minimum Terraform CLI version). This also allows this framework to be muxed with the older framework since the provider schema must match. It is expected that over time any schema definitions including `Blocks` will migrate to `Attributes`.

Provider developers should always opt for `Attributes` in new schema definitions.
@bflad bflad removed their assignment Oct 29, 2021
tfsdk/nested_attributes.go Outdated Show resolved Hide resolved
Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

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

Start of a review, getting distracted so going to leave the comments I have, but still have to look through a lot of this, sorry.

tfsdk/attribute.go Show resolved Hide resolved
tfsdk/block.go Outdated Show resolved Hide resolved
tfsdk/block.go Show resolved Hide resolved
tfsdk/nested_attributes.go Outdated Show resolved Hide resolved
…attr.Value).Type() in Block conversion errors
@bflad
Copy link
Contributor Author

bflad commented Nov 2, 2021

I've addressed the first round of feedback. I've created #222 for plan modification so we can either try to include that in this first round of support or later on since that's another large code chunk.

@bflad bflad requested a review from paddycarver November 2, 2021 15:08
Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

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

Some final minor comments, but on the whole looks good to me.

A lot going on here, and it's really bringing home for me how badly #215 is needed. But I think I'm as confident as reasonably possible in the changes.

I think there's a lingering question in my mind of whether we want blocks to match nested attributes in using enum functions (e.g. tfsdk.ListNestedAttributes but ListNestedBlocks instead) just for uniformity, but I'm 🤔 about that design and whether we want to keep it, anyways, so I think that's always something we can tackle later, if we need to.

Awesome work.

tfsdk/block.go Show resolved Hide resolved
tfsdk/schema.go Show resolved Hide resolved
tfsdk/schema.go Show resolved Hide resolved
@bflad bflad requested a review from paddycarver November 3, 2021 13:09
Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

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

Let's do it 😎

@bflad bflad merged commit 085ea63 into main Nov 3, 2021
@bflad bflad deleted the bflad-f-blocks branch November 3, 2021 14:56
@bflad bflad added this to the v0.5.0 milestone Nov 3, 2021
@github-actions
Copy link

github-actions bot commented Dec 4, 2021

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 contributions.
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 Dec 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding (deprecated) support for blocks 😢
2 participants