From c05a1050fc53b3ad2a7c1edd63751de13ac44bcb Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 6 Mar 2018 14:54:43 -0800 Subject: [PATCH] configs: Disable deprecation warning for quoted keywords/references Although we do still consider these deprecated for 0.12, we'll defer actually generating warnings for them until a later minor release so that module authors can retain their quoted identifiers for a period after 0.12 release for backward-compatibility with Terraform 0.11. --- configs/compat_shim.go | 37 +++++++++++++++++++++-------------- configs/parser_config_test.go | 25 ----------------------- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/configs/compat_shim.go b/configs/compat_shim.go index 2f803b3fa..ed4f37d43 100644 --- a/configs/compat_shim.go +++ b/configs/compat_shim.go @@ -59,21 +59,28 @@ func shimTraversalInString(expr hcl.Expression, wantKeyword bool) (hcl.Expressio ) diags = append(diags, tDiags...) - if wantKeyword { - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagWarning, - Summary: "Quoted keywords are deprecated", - Detail: "In this context, keywords are expected literally rather than in quotes. Previous versions of Terraform required quotes, but that usage is now deprecated. Remove the quotes surrounding this keyword to silence this warning.", - Subject: &srcRange, - }) - } else { - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagWarning, - Summary: "Quoted references are deprecated", - Detail: "In this context, references are expected literally rather than in quotes. Previous versions of Terraform required quotes, but that usage is now deprecated. Remove the quotes surrounding this reference to silence this warning.", - Subject: &srcRange, - }) - } + // For initial release our deprecation warnings are disabled to allow + // a period where modules can be compatible with both old and new + // conventions. + // FIXME: Re-enable these deprecation warnings in a release prior to + // Terraform 0.13 and then remove the shims altogether for 0.13. + /* + if wantKeyword { + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagWarning, + Summary: "Quoted keywords are deprecated", + Detail: "In this context, keywords are expected literally rather than in quotes. Previous versions of Terraform required quotes, but that usage is now deprecated. Remove the quotes surrounding this keyword to silence this warning.", + Subject: &srcRange, + }) + } else { + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagWarning, + Summary: "Quoted references are deprecated", + Detail: "In this context, references are expected literally rather than in quotes. Previous versions of Terraform required quotes, but that usage is now deprecated. Remove the quotes surrounding this reference to silence this warning.", + Subject: &srcRange, + }) + } + */ return &hclsyntax.ScopeTraversalExpr{ Traversal: traversal, diff --git a/configs/parser_config_test.go b/configs/parser_config_test.go index ff90d5eba..62a04d3ba 100644 --- a/configs/parser_config_test.go +++ b/configs/parser_config_test.go @@ -99,11 +99,6 @@ func TestParserLoadConfigFileFailureMessages(t *testing.T) { hcl.DiagError, "Invalid variable type hint", }, - { - "valid-files/variable-type-quoted.tf", - hcl.DiagWarning, - "Quoted keywords are deprecated", - }, { "invalid-files/unexpected-attr.tf", hcl.DiagError, @@ -119,16 +114,6 @@ func TestParserLoadConfigFileFailureMessages(t *testing.T) { hcl.DiagError, "Unsuitable value type", }, - { - "valid-files/resources-dependson-quoted.tf", - hcl.DiagWarning, - "Quoted references are deprecated", - }, - { - "valid-files/resources-ignorechanges-quoted.tf", - hcl.DiagWarning, - "Quoted references are deprecated", - }, { "valid-files/resources-ignorechanges-all-legacy.tf", hcl.DiagWarning, @@ -139,16 +124,6 @@ func TestParserLoadConfigFileFailureMessages(t *testing.T) { hcl.DiagWarning, "Deprecated ignore_changes wildcard", }, - { - "valid-files/resources-provisioner-when-quoted.tf", - hcl.DiagWarning, - "Quoted keywords are deprecated", - }, - { - "valid-files/resources-provisioner-onfailure-quoted.tf", - hcl.DiagWarning, - "Quoted keywords are deprecated", - }, } for _, test := range tests {