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

tfsdk: Add support for single nested mode blocks #477

Merged
merged 2 commits into from Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
)