Skip to content

Commit

Permalink
tfsdk: Add support for single nested mode blocks (#477)
Browse files Browse the repository at this point in the history
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"
  }
}
```
  • Loading branch information
bflad committed Sep 13, 2022
1 parent b79aef6 commit f957ca7
Show file tree
Hide file tree
Showing 22 changed files with 3,210 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .changelog/477.txt
@@ -0,0 +1,7 @@
```release-note:note
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.
```

```release-note:enhancement
tfsdk: Added single nested mode block support
```
18 changes: 14 additions & 4 deletions internal/fwschema/block_nested_mode.go
Expand Up @@ -3,10 +3,11 @@ package fwschema
// BlockNestingMode is an enum type of the ways attributes and blocks can be
// nested in a block. They can be a list or a set.
//
// While the protocol and theoretically Terraform itself support map, single,
// and group nesting modes, this framework intentionally only supports list
// and set blocks as those other modes were not typically implemented or
// tested since the older Terraform Plugin SDK did not support them.
// While the protocol and theoretically Terraform itself support map and group
// nesting modes, this framework intentionally only supports list, set, and
// single blocks as those other modes were not typically implemented or
// tested with Terraform since the older Terraform Plugin SDK did not support
// them.
type BlockNestingMode uint8

const (
Expand All @@ -23,4 +24,13 @@ const (
// with multiple, unique instances of those attributes nested inside a
// set under another attribute.
BlockNestingModeSet BlockNestingMode = 2

// BlockNestingModeSingle is for attributes that represent a single object.
// The object cannot be repeated in the practitioner configuration.
//
// While the framework implements support for this block nesting mode, it
// is not thoroughly tested in production Terraform environments beyond the
// resource timeouts block from the older Terraform Plugin SDK. Use single
// nested attributes for new implementations instead.
BlockNestingModeSingle BlockNestingMode = 3
)

0 comments on commit f957ca7

Please sign in to comment.