Skip to content

Commit d8f5d5a

Browse files
bendbennettbflad
andauthored
Documentation for mapping between SDKv2 and the Framework (#660)
* Adding table to provide mapping between SDKv2 schema validators and framework attribute and data source, provider and resource validators (#659) * Adding a table to provide mapping between SDK schema fields and Framework (#659) * Apply suggestions from code review Co-authored-by: Brian Flad <[email protected]> * Adding a table to provide mapping between SDK schema fields and Framework for Blocks (#659) * Add import statements for usage of timeouts module (#659) * Apply suggestions from code review Co-authored-by: Brian Flad <[email protected]> --------- Co-authored-by: Brian Flad <[email protected]>
1 parent 1be6094 commit d8f5d5a

File tree

7 files changed

+114
-0
lines changed

7 files changed

+114
-0
lines changed

website/docs/plugin/framework/data-sources/timeouts.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ resource "timeouts_example" "example" {
3636
}
3737
```
3838

39+
Import the [timeouts module](https://github.com/hashicorp/terraform-plugin-framework-timeouts).
40+
41+
```go
42+
import (
43+
/* ... */
44+
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
45+
)
46+
````
47+
3948
You can use this module to mutate the `schema.Schema` as follows:
4049
4150
```go

website/docs/plugin/framework/migrating/attributes-blocks/blocks.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,38 @@ This page explains how to migrate nested blocks that are not computed (i.e., do
1414
[Blocks with Computed Fields](/plugin/framework/migrating/attributes-blocks/blocks-computed) for more details
1515
about migrating nested blocks that contain fields that are computed.
1616

17+
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.
18+
19+
| SDK Schema Field | Framework |
20+
|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
21+
| Type | [ListNestedBlock](/plugin/framework/migrating/attributes-blocks/blocks), [SetNestedBlock](/plugin/framework/migrating/attributes-blocks/blocks) |
22+
| ConfigMode | Schema must be explictly defined using [Attributes](/plugin/framework/migrating/attributes-blocks/attribute-schema) and [Blocks](/plugin/framework/migrating/attributes-blocks/blocks) |
23+
| Required | [listvalidator.IsRequired](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#IsRequired), [setvalidator.IsRequired](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#IsRequired) |
24+
| Optional | N/A - no implementation required |
25+
| Computed | [Blocks with Computed Fields](/plugin/framework/migrating/attributes-blocks/blocks-computed) |
26+
| ForceNew | [RequiresReplace](/plugin/framework/migrating/attributes-blocks/force-new) on `PlanModifiers` field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
27+
| DiffSuppressFunc | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
28+
| DiffSuppressOnRefresh | [Read](/plugin/framework/migrating/resources/crud) method on resource |
29+
| Default | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
30+
| DefaultFunc | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
31+
| Description | `Description` field on block |
32+
| InputDefault | N/A - no longer valid |
33+
| StateFunc | Requires implementation of bespoke logic before storing state, for instance in resource [Create method](plugin/framework/migrating/resources/crud#framework-1) |
34+
| Elem | `NestedObject` within block |
35+
| MaxItems | Use [listValidator.SizeAtMost](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#SizeAtMost) or [setvalidator.SizeAtMost](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#SizeAtMost) on `Validators` field on `ListNestedBlock` or `SetNestedBlock` |
36+
| MinItems | Use [listValidator.SizeAtLeast](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#SizeAtLeast) or [setvalidator.SizeAtLeast](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#SizeAtLeast) on `Validators` field on `ListNestedBlock` or `SetNestedBlock` |
37+
| Set | N/A - no implementation required | |
38+
| ComputedWhen | N/A - no longer valid |
39+
| ConflictsWith | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
40+
| ExactlyOneOf | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
41+
| AtLeastOneOf | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
42+
| RequiredWith | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
43+
| Deprecated | `DeprecationMessage` field on attribute within block |
44+
| ValidateFunc | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) and [Custom Validators](/plugin/framework/migrating/attributes-blocks/validators-custom) |
45+
| ValidateDiagFunc | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) and [Custom Validators](/plugin/framework/migrating/attributes-blocks/validators-custom) |
46+
| Sensitive | N/A - only supported on attributes |
47+
48+
1749
## Nested Block Example
1850

1951
The following example shows a nested block in Terraform resource configuration. The `subject` nested

0 commit comments

Comments
 (0)