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.
This commit is contained in:
Martin Atkins 2018-03-06 14:54:43 -08:00
parent a26ff56f01
commit c05a1050fc
2 changed files with 22 additions and 40 deletions

View File

@ -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,

View File

@ -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 {