Skip to content

Commit f957ca7

Browse files
authored
tfsdk: Add support for single nested mode blocks (#477)
Reference: #400 This support is required for provider developers to migrate from terraform-plugin-sdk to terraform-plugin-framework without affecting practitioner configurations or requiring state upgrades. For example: ```terraform resource "examplecloud_thing" "example" { timeouts { create = "5m" } } ```
1 parent b79aef6 commit f957ca7

22 files changed

+3210
-6
lines changed

.changelog/477.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:note
2+
tfsdk: Schema definitions may now introduce single nested mode blocks, however this support is only intended for migrating terraform-plugin-sdk timeouts blocks. New implementations should prefer single nested attributes instead.
3+
```
4+
5+
```release-note:enhancement
6+
tfsdk: Added single nested mode block support
7+
```

internal/fwschema/block_nested_mode.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package fwschema
33
// BlockNestingMode is an enum type of the ways attributes and blocks can be
44
// nested in a block. They can be a list or a set.
55
//
6-
// While the protocol and theoretically Terraform itself support map, single,
7-
// and group nesting modes, this framework intentionally only supports list
8-
// and set blocks as those other modes were not typically implemented or
9-
// tested since the older Terraform Plugin SDK did not support them.
6+
// While the protocol and theoretically Terraform itself support map and group
7+
// nesting modes, this framework intentionally only supports list, set, and
8+
// single blocks as those other modes were not typically implemented or
9+
// tested with Terraform since the older Terraform Plugin SDK did not support
10+
// them.
1011
type BlockNestingMode uint8
1112

1213
const (
@@ -23,4 +24,13 @@ const (
2324
// with multiple, unique instances of those attributes nested inside a
2425
// set under another attribute.
2526
BlockNestingModeSet BlockNestingMode = 2
27+
28+
// BlockNestingModeSingle is for attributes that represent a single object.
29+
// The object cannot be repeated in the practitioner configuration.
30+
//
31+
// While the framework implements support for this block nesting mode, it
32+
// is not thoroughly tested in production Terraform environments beyond the
33+
// resource timeouts block from the older Terraform Plugin SDK. Use single
34+
// nested attributes for new implementations instead.
35+
BlockNestingModeSingle BlockNestingMode = 3
2636
)

0 commit comments

Comments
 (0)