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

internal/fwschema: Add NestedAttributeObject and NestedBlockObject interfaces #545

Merged
merged 1 commit into from Nov 18, 2022

Conversation

bflad
Copy link
Member

@bflad bflad commented Nov 18, 2022

Reference: #132
Reference: #508
Reference: #532

Since the initial version of the framework, it has treated nested attributes and blocks as a singular entity with some internal gymnastics to handle the one (single; object) or two (list, map, set to object) actual types that make up the nested attribute or block. Having these schema abstractions as single entities caused developer confusion when attempting to extract data or create paths.

Other desirable features for the framework are the ability to customize the types, define validators, and define plan modifiers of nested attributes and blocks. This type customization, validation, or plan modification may need to be on the nested object to simplify provider implementations. Exposing these options with a flat abstraction could be confusing.

This change introduces the concept of a nested attribute object and a nested block object into the internal/fwschema package and makes the necessary implementation changes to tfsdk.Attribute and tfsdk.Block. While the tfsdk package schema handling does not expose the new potential enhancements, the upcoming datasource, provider, and resource schema handling will. The existing unit testing shows no regressions and the new unit tests with validation show it should be possible to implement nested object validation (and when implemented in the near future, plan modification).

This changeset additionally migrates more tfsdk.Schema logic into the internal/fwschema package in further preparation for creating additional schema implementations that will benefit from the existing schema logic.

@bflad bflad added the enhancement New feature or request label Nov 18, 2022
@bflad bflad added this to the v0.17.0 milestone Nov 18, 2022
@bflad bflad requested a review from a team as a code owner November 18, 2022 04:33
…terfaces

Reference: #132
Reference: #508
Reference: #532

Since the initial version of the framework, it has treated nested attributes and blocks as a singular entity with some internal gynastics to handle the one (single; object) or two (list, map, set to object) actual types that make up the nested attribute or block. Having these schema abstractions as single entities caused developer confusion when attempting to extract data or create paths.

Other desirable features for the framework are the ability to customize the types, define validators, and define plan modifiers of nested attributes and blocks. This type customization, validation, or plan modification may need to be on the nested object to simplify provider implementations. Exposing these options with a flat abstraction could be confusing.

This change introduces the concept of a nested attribute object and a nested block object into the `internal/fwschema` package and makes the necessary implementation changes to `tfsdk.Attribute` and `tfsdk.Block`. While the `tfsdk` package schema handling does not expose the new potential enhancements, the upcoming `datasource`, `provider`, and `resource` schema handling will. The existing unit testing shows no regressions and the new unit tests with validation show it should be possible to implement nested object validation (and when implemented in the near future, plan modification).

This changeset additionally migrates more `tfsdk.Schema` logic into the `internal/fwschema` package in further preparation for creating additional schema implementations that will benefit from the existing schema logic.
@bflad bflad merged commit 2845f93 into main Nov 18, 2022
@bflad bflad deleted the bflad/nested-objects branch November 18, 2022 17:03
@pksunkara
Copy link

This is some great work that's much needed (which I already mentioned here). But I have no idea on how to start using this, the docs are not good enough.

Can you guys please add some examples in the repository with each use case? That would be really helpful.

@github-actions
Copy link

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 20, 2022
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.

None yet

3 participants