configs/configupgrade: Test that map attrs as blocks are fixed

The old parser was forgiving in allowing the use of block syntax where a
map attribute was expected, but the new parser is not (in order to allow
for dynamic map keys, for expressions, etc) and so the upgrade tool must
fix these to use attribute syntax.
This commit is contained in:
Martin Atkins 2018-11-30 16:56:54 -08:00
parent 1aa368d0d8
commit bdb724562c
6 changed files with 20 additions and 3 deletions

View File

@ -0,0 +1,7 @@
resource "test_instance" "foo" {
type = "z1.weedy"
image = "image-abcd"
tags {
name = "boop"
}
}

View File

@ -0,0 +1,7 @@
resource "test_instance" "foo" {
type = "z1.weedy"
image = "image-abcd"
tags = {
name = "boop"
}
}

View File

@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}

View File

@ -1,3 +1,3 @@
resource "test_resource" "example" {
resource "test_instance" "example" {
}

View File

@ -1,3 +1,3 @@
resource "test_resource" "example" {
resource "test_instance" "example" {
}

View File

@ -188,7 +188,7 @@ var testProviders = map[string]providers.Factory{
p := &terraform.MockProvider{}
p.GetSchemaReturn = &terraform.ProviderSchema{
ResourceTypes: map[string]*configschema.Block{
"test_resource": {
"test_instance": {
Attributes: map[string]*configschema.Attribute{
"id": {Type: cty.String, Computed: true},
"type": {Type: cty.String, Optional: true},