Fix provider attribute to block conversion #288
Merged
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.
To mimic Terraform's built-in backwards-compatible logic, where list(object) or set(object) attributes are also accessible as blocks, we check all attributes to see if they match those types. But we only did this for the top-level attributes of a block, and didn't check nested attributes. This PR fixes that.
The example in hashicorp/vscode-terraform#1594 had three attributes, that were also available as a block:
managed_disk
,network_interface
, andunmanaged_disk
. All three are of type set(object) and encoded as such in the provider schema.We convert them to blocks in
terraform-schema/schema/convert_json.go
Lines 123 to 134 in 8c97616
and so they show up for completion in the top-level dynamic block
managed_disk
contains the attributetarget_disk_encryption
with type list(object) that also could be a block, but we never tried to convert it. So it never showed up for completion in a nested dynamic block and was marked as a problem by the schema validation.UX
Before
After