-
Notifications
You must be signed in to change notification settings - Fork 97
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
Documentation for mapping between SDKv2 and the Framework #660
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4bef283
Adding table to provide mapping between SDKv2 schema validators and f…
bendbennett 3e5fa7f
Adding a table to provide mapping between SDK schema fields and Frame…
bendbennett 6601435
Merge branch 'main' into bendbennett/issues-659
bendbennett d9714e1
Apply suggestions from code review
bendbennett 5ed3c6b
Adding a table to provide mapping between SDK schema fields and Frame…
bendbennett f248110
Add import statements for usage of timeouts module (#659)
bendbennett b461ff8
Apply suggestions from code review
bendbennett bdf7ac9
Merge branch 'main' into bendbennett/issues-659
bendbennett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,38 @@ description: >- | |
A subset of attribute fields, such as required, optional, computed, or sensitive, define attribute behavior as boolean flags. Refer to | ||
[Schemas - Attributes](/plugin/framework/handling-data/schemas#required) in the Framework documentation for details. | ||
|
||
The following table describes the mapping between [SDK Schema Fields](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/helper/schema#Schema) and the Framework. | ||
|
||
| SDK Schema Field | Framework | | ||
|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| Type | [Attribute Types](/plugin/framework/migrating/attributes-blocks/types) | | ||
| ConfigMode | Schema must be explictly defined using [Attributes](/plugin/framework/migrating/attributes-blocks/attribute-schema) and [Blocks](/plugin/framework/migrating/attributes-blocks/blocks) | | ||
| Required | `Required` field on attribute | | ||
| Optional | `Optional` field on attribute | | ||
| Computed | `Computed` field on attribute | | ||
| ForceNew | [RequiresReplace](/plugin/framework/migrating/attributes-blocks/force-new) on `PlanModifiers` field on attribute or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface | | ||
| DiffSuppressFunc | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface | | ||
| DiffSuppressOnRefresh | [Read](/plugin/framework/migrating/resources/crud) method on resource | | ||
| Default | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface | | ||
| DefaultFunc | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface | | ||
| Description | `Description` field on attribute | | ||
| InputDefault | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface | | ||
bendbennett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| StateFunc | Requires implementation of bespoke logic before storing state, for instance in resource [Create method](plugin/framework/migrating/resources/crud#framework-1) | | ||
| Elem | `ElementType` on [ListAttribute](/plugin/framework/migrating/attributes-blocks/types), [MapAttribute](/plugin/framework/migrating/attributes-blocks/types) or [SetAttribute](/plugin/framework/migrating/attributes-blocks/types) | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be good to call out that any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to include call out. |
||
| MaxItems | Use [listValidator.SizeAtMost](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#SizeAtMost), [mapvalidator.SizeAtMost](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator#SizeAtMost) or [setvalidator.SizeAtMost](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#SizeAtMost) on `Validators` field on list, map or set attribute | | ||
| MinItems | Use [listValidator.SizeAtLeast](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#SizeAtLeast), [mapvalidator.SizeAtLeast](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator#SizeAtLeast) or [setvalidator.SizeAtLeast](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#SizeAtLeast) on `Validators` field on list, map or set attribute | | ||
| Set | N/A - no implementation is required | | | ||
| ComputedWhen | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface | | ||
bendbennett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ConflictsWith | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) | | ||
| ExactlyOneOf | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) | | ||
| AtLeastOneOf | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) | | ||
| RequiredWith | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) | | ||
| Deprecated | `DeprecationMessage` field on attribute | | ||
| ValidateFunc | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) and [Custom Validators](/plugin/framework/migrating/attributes-blocks/validators-custom) | | ||
| ValidateDiagFunc | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) and [Custom Validators](/plugin/framework/migrating/attributes-blocks/validators-custom) | | ||
| Sensitive | `Sensitive` field on attribute | | ||
|
||
|
||
This page explains how to migrate the required, optional, computed, and sensitive attribute fields from SDKv2 to the | ||
Framework. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are a variety of differences between blocks and attributes, I think this page might warrant its own table. The prior SDK allowed developers to do unsupported things, like declare
Sensitive
on blocks (hashicorp/terraform-plugin-sdk#819) and we already have special callouts in paragraph form aboutComputed
andRequired
. Therefore I think we should walk through the various fields and how they relate to blocks:listvalidator.IsRequired()
andsetvalidator.IsRequired()
(let's omit any discussion on single nested blocks, they weren't possible to declare before)etc. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added a table into the Blocks page.