configs/configupgrade: Pass through connection and provisioner blocks

This is a temporary implementation of these rules just so that these can
be passed through verbatim (rather than generating an error) while we
do testing of other features.

A subsequent commit will finish these with their own custom rulesets.
This commit is contained in:
Martin Atkins 2018-12-04 17:29:42 -08:00
parent 028b5ba34e
commit 8112f589c1
3 changed files with 34 additions and 0 deletions

View File

@ -1,3 +1,11 @@
resource "test_instance" "example" {
connection {
host = "127.0.0.1"
}
provisioner "local-exec" {
connection {
host = "127.0.0.2"
}
}
}

View File

@ -1,3 +1,11 @@
resource "test_instance" "example" {
connection {
host = "127.0.0.1"
}
provisioner "local-exec" {
connection {
host = "127.0.0.2"
}
}
}

View File

@ -329,6 +329,24 @@ func (u *Upgrader) upgradeNativeSyntaxResource(filename string, buf *bytes.Buffe
rules["depends_on"] = dependsOnAttributeRule(filename, an)
rules["provider"] = maybeBareTraversalAttributeRule(filename, an)
rules["lifecycle"] = nestedBlockRule(filename, lifecycleBlockBodyRules(filename, an), an, adhocComments)
rules["connection"] = func(buf *bytes.Buffer, blockAddr string, item *hcl1ast.ObjectItem) tfdiags.Diagnostics {
// TODO: For the few resource types that were setting ConnInfo in
// state after create/update in prior versions, generate the additional
// explicit connection settings that are now required if and only if
// there's at least one provisioner block.
// For now, we just pass this through as-is.
hcl1printer.Fprint(buf, item)
buf.WriteByte('\n')
return nil
}
rules["provisioner"] = func(buf *bytes.Buffer, blockAddr string, item *hcl1ast.ObjectItem) tfdiags.Diagnostics {
// TODO: Look up the provisioner schema and map this properly to ensure
// any references get properly updated.
// For now, we just pass this through as-is.
hcl1printer.Fprint(buf, item)
buf.WriteByte('\n')
return nil
}
printComments(buf, item.LeadComment)
printBlockOpen(buf, blockType, labels, item.LineComment)