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: Introduce NestedAttribute interface and cleanup Attribute interface methods #543

Merged
merged 4 commits into from Nov 17, 2022

Conversation

bflad
Copy link
Member

@bflad bflad commented Nov 16, 2022

Reference: #132

As part of upcoming effort to split schema functionality into the datasource, provider, and resource packages, there are some internal implementation details which need to be sorted beforehand. Throughout the 0.x versions, schema functionality has been migrated from the tfsdk package into the internal/fwschema package, but there is some lingering technical debt of duplicate and confusing methods.

This change creates a new NestedAttribute (singular) interface which extends the Attribute interface with the methods only required for an attribute that does in fact implement nested attributes. The tfsdk.Attribute type is updated to support both the Attribute and NestedAttribute interfaces as it accurately describes the overloaded abstraction. The NestedAttributes (plural) interface remains to describe how tfsdk.Attribute implements that concepts under its Attributes field. The NestedAttributes (plural) interface and its implementations will be removed when tfsdk.Attribute is removed.

Another aspect of these changes is cleaning up the type describing methods, removing the separate Attribute type FrameworkType() method and NestedAttributes type AttributeType() method.

The upcoming split schemas will implement explicit attribute types which only implement NestedAttribute (singular) as appropriate.

…tribute interface methods

Reference: #132

As part of upcoming effort to split schema functionality into the `datasource`, `provider`, and `resource` packages, there are some internal implementation details which need to be sorted beforehand. Throughout the 0.x versions, schema functionality has been migrated from the `tfsdk` package into the `internal/fwschema` package, but there is some lingering technical debt of duplicate and confusing methods.

This change creates a new `NestedAttribute` (singular) interface which extends the `Attribute` interface with the methods only required for an attribute that does in fact implement nested attributes. The `tfsdk.Attribute` type is updated to support both the `Attribute` and `NestedAttribute` interfaces as it accurately describes the overloaded abstraction. The `NestedAttributes` (plural) interface remains to describe how `tfsdk.Attribute` implements that concepts under its `Attributes` field. The `NestedAttributes` (plural) interface and its implementations will be removed when `tfsdk.Attribute` is removed.

Another aspect of these changes is cleaning up the type describing methods, removing the separate `Attribute` type `FrameworkType()` method and `NestedAttributes` type `AttributeType()` method.

The upcoming split schemas will implement explicit attribute types which only implement `NestedAttribute` (singular) as appropriate.
@bflad bflad added breaking-change This PR introduces a breaking change or the resolution of this issue may require a breaking change. tech-debt Issues tracking technical debt that we're carrying. labels Nov 16, 2022
@bflad bflad added this to the v0.17.0 milestone Nov 16, 2022
@bflad bflad requested a review from a team as a code owner November 16, 2022 20:14
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@bflad bflad merged commit 59a847d into main Nov 17, 2022
@bflad bflad deleted the bflad/split-schema-internal-prep branch November 17, 2022 15:13
@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 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change This PR introduces a breaking change or the resolution of this issue may require a breaking change. tech-debt Issues tracking technical debt that we're carrying.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants