Skip to content

Commit a77ea74

Browse files
authored
Merge pull request #26272 from hashicorp/alisdair/more-interpolation-only-expression-deprecations-0.13
configs: More interpolation-only expr deprecations
2 parents f8273b2 + 68f64d2 commit a77ea74

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

configs/module_call.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ type ModuleCall struct {
3131
}
3232

3333
func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagnostics) {
34+
var diags hcl.Diagnostics
35+
36+
// Produce deprecation messages for any pre-0.12-style
37+
// single-interpolation-only expressions.
38+
moreDiags := warnForDeprecatedInterpolationsInBody(block.Body)
39+
diags = append(diags, moreDiags...)
40+
3441
mc := &ModuleCall{
3542
Name: block.Labels[0],
3643
DeclRange: block.DefRange,
@@ -41,7 +48,8 @@ func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagno
4148
schema = schemaForOverrides(schema)
4249
}
4350

44-
content, remain, diags := block.Body.PartialContent(schema)
51+
content, remain, moreDiags := block.Body.PartialContent(schema)
52+
diags = append(diags, moreDiags...)
4553
mc.Config = remain
4654

4755
if !hclsyntax.ValidIdentifier(mc.Name) {

configs/named_values.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ type Output struct {
433433
}
434434

435435
func decodeOutputBlock(block *hcl.Block, override bool) (*Output, hcl.Diagnostics) {
436+
var diags hcl.Diagnostics
437+
436438
o := &Output{
437439
Name: block.Labels[0],
438440
DeclRange: block.DefRange,
@@ -443,7 +445,13 @@ func decodeOutputBlock(block *hcl.Block, override bool) (*Output, hcl.Diagnostic
443445
schema = schemaForOverrides(schema)
444446
}
445447

446-
content, diags := block.Body.Content(schema)
448+
// Produce deprecation messages for any pre-0.12-style
449+
// single-interpolation-only expressions.
450+
moreDiags := warnForDeprecatedInterpolationsInBody(block.Body)
451+
diags = append(diags, moreDiags...)
452+
453+
content, moreDiags := block.Body.Content(schema)
454+
diags = append(diags, moreDiags...)
447455

448456
if !hclsyntax.ValidIdentifier(o.Name) {
449457
diags = append(diags, &hcl.Diagnostic{
@@ -506,6 +514,11 @@ func decodeLocalsBlock(block *hcl.Block) ([]*Local, hcl.Diagnostics) {
506514
})
507515
}
508516

517+
// Produce deprecation messages for any pre-0.12-style
518+
// single-interpolation-only expressions.
519+
moreDiags := warnForDeprecatedInterpolationsInExpr(attr.Expr)
520+
diags = append(diags, moreDiags...)
521+
509522
locals = append(locals, &Local{
510523
Name: name,
511524
Expr: attr.Expr,

configs/resource.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ func decodeResourceBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
290290
}
291291

292292
func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
293+
var diags hcl.Diagnostics
293294
r := &Resource{
294295
Mode: addrs.DataResourceMode,
295296
Type: block.Labels[0],
@@ -298,7 +299,13 @@ func decodeDataBlock(block *hcl.Block) (*Resource, hcl.Diagnostics) {
298299
TypeRange: block.LabelRanges[0],
299300
}
300301

301-
content, remain, diags := block.Body.PartialContent(dataBlockSchema)
302+
// Produce deprecation messages for any pre-0.12-style
303+
// single-interpolation-only expressions.
304+
moreDiags := warnForDeprecatedInterpolationsInBody(block.Body)
305+
diags = append(diags, moreDiags...)
306+
307+
content, remain, moreDiags := block.Body.PartialContent(dataBlockSchema)
308+
diags = append(diags, moreDiags...)
302309
r.Config = remain
303310

304311
if !hclsyntax.ValidIdentifier(r.Type) {

configs/testdata/warning-files/redundant_interp.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,20 @@ resource "null_resource" "a" {
3434
wrapped = ["${var.triggers["greeting"]}"]
3535
}
3636
}
37+
38+
module "foo" {
39+
source = "./foo"
40+
foo = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
41+
}
42+
43+
data "null_data_source" "b" {
44+
has_computed_default = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
45+
}
46+
47+
output "output" {
48+
value = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
49+
}
50+
51+
locals {
52+
foo = "${var.foo}" # WARNING: Interpolation-only expressions are deprecated
53+
}

0 commit comments

Comments
 (0)