configs: More interpolation-only expr deprecations
Extend the deprecation for interpolation-only expressions to include module calls, data sources, outputs, and locals.
This commit is contained in:
parent
fa4917172d
commit
e693c14e5a
|
@ -31,6 +31,13 @@ type ModuleCall struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagnostics) {
|
func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagnostics) {
|
||||||
|
var diags hcl.Diagnostics
|
||||||
|
|
||||||
|
// Produce deprecation messages for any pre-0.12-style
|
||||||
|
// single-interpolation-only expressions.
|
||||||
|
moreDiags := warnForDeprecatedInterpolationsInBody(block.Body)
|
||||||
|
diags = append(diags, moreDiags...)
|
||||||
|
|
||||||
mc := &ModuleCall{
|
mc := &ModuleCall{
|
||||||
Name: block.Labels[0],
|
Name: block.Labels[0],
|
||||||
DeclRange: block.DefRange,
|
DeclRange: block.DefRange,
|
||||||
|
@ -41,7 +48,8 @@ func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagno
|
||||||
schema = schemaForOverrides(schema)
|
schema = schemaForOverrides(schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
content, remain, diags := block.Body.PartialContent(schema)
|
content, remain, moreDiags := block.Body.PartialContent(schema)
|
||||||
|
diags = append(diags, moreDiags...)
|
||||||
mc.Config = remain
|
mc.Config = remain
|
||||||
|
|
||||||
if !hclsyntax.ValidIdentifier(mc.Name) {
|
if !hclsyntax.ValidIdentifier(mc.Name) {
|
||||||
|
|
|
@ -433,6 +433,8 @@ type Output struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeOutputBlock(block *hcl.Block, override bool) (*Output, hcl.Diagnostics) {
|
func decodeOutputBlock(block *hcl.Block, override bool) (*Output, hcl.Diagnostics) {
|
||||||
|
var diags hcl.Diagnostics
|
||||||
|
|
||||||
o := &Output{
|
o := &Output{
|
||||||
Name: block.Labels[0],
|
Name: block.Labels[0],
|
||||||
DeclRange: block.DefRange,
|
DeclRange: block.DefRange,
|
||||||
|
@ -443,7 +445,13 @@ func decodeOutputBlock(block *hcl.Block, override bool) (*Output, hcl.Diagnostic
|
||||||
schema = schemaForOverrides(schema)
|
schema = schemaForOverrides(schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
content, diags := block.Body.Content(schema)
|
// Produce deprecation messages for any pre-0.12-style
|
||||||
|
// single-interpolation-only expressions.
|
||||||
|
moreDiags := warnForDeprecatedInterpolationsInBody(block.Body)
|
||||||
|
diags = append(diags, moreDiags...)
|
||||||
|
|
||||||
|
content, moreDiags := block.Body.Content(schema)
|
||||||
|
diags = append(diags, moreDiags...)
|
||||||
|
|
||||||
if !hclsyntax.ValidIdentifier(o.Name) {
|
if !hclsyntax.ValidIdentifier(o.Name) {
|
||||||
diags = append(diags, &hcl.Diagnostic{
|
diags = append(diags, &hcl.Diagnostic{
|
||||||
|
@ -506,6 +514,11 @@ func decodeLocalsBlock(block *hcl.Block) ([]*Local, hcl.Diagnostics) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Produce deprecation messages for any pre-0.12-style
|
||||||
|
// single-interpolation-only expressions.
|
||||||
|
moreDiags := warnForDeprecatedInterpolationsInExpr(attr.Expr)
|
||||||
|
diags = append(diags, moreDiags...)
|
||||||
|
|
||||||
locals = append(locals, &Local{
|
locals = append(locals, &Local{
|
||||||
Name: name,
|
Name: name,
|
||||||
Expr: attr.Expr,
|
Expr: attr.Expr,
|
||||||
|
|
|
@ -290,6 +290,7 @@ func decodeResourceBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
|
func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
|
||||||
|
var diags hcl.Diagnostics
|
||||||
r := &Resource{
|
r := &Resource{
|
||||||
Mode: addrs.DataResourceMode,
|
Mode: addrs.DataResourceMode,
|
||||||
Type: block.Labels[0],
|
Type: block.Labels[0],
|
||||||
|
@ -298,7 +299,13 @@ func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
|
||||||
TypeRange: block.LabelRanges[0],
|
TypeRange: block.LabelRanges[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
content, remain, diags := block.Body.PartialContent(dataBlockSchema)
|
// Produce deprecation messages for any pre-0.12-style
|
||||||
|
// single-interpolation-only expressions.
|
||||||
|
moreDiags := warnForDeprecatedInterpolationsInBody(block.Body)
|
||||||
|
diags = append(diags, moreDiags...)
|
||||||
|
|
||||||
|
content, remain, moreDiags := block.Body.PartialContent(dataBlockSchema)
|
||||||
|
diags = append(diags, moreDiags...)
|
||||||
r.Config = remain
|
r.Config = remain
|
||||||
|
|
||||||
if !hclsyntax.ValidIdentifier(r.Type) {
|
if !hclsyntax.ValidIdentifier(r.Type) {
|
||||||
|
|
|
@ -34,3 +34,20 @@ resource "null_resource" "a" {
|
||||||
wrapped = ["${var.triggers["greeting"]}"]
|
wrapped = ["${var.triggers["greeting"]}"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module "foo" {
|
||||||
|
source = "./foo"
|
||||||
|
foo = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
|
||||||
|
}
|
||||||
|
|
||||||
|
data "null_data_source" "b" {
|
||||||
|
has_computed_default = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
|
||||||
|
}
|
||||||
|
|
||||||
|
output "output" {
|
||||||
|
value = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
foo = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue