internal/fwschema: Add NestedAttributeObject and NestedBlockObject interfaces #545
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 totfsdk.Attribute
andtfsdk.Block
. While thetfsdk
package schema handling does not expose the new potential enhancements, the upcomingdatasource
,provider
, andresource
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 theinternal/fwschema
package in further preparation for creating additional schema implementations that will benefit from the existing schema logic.