Add deprecation warning for vendor provisioners

Adds a warning for chef, habitat, puppet, and salt-masterless
provisioners, and a corresponding test file to test for the warning
This commit is contained in:
Pam Selle 2020-08-26 10:46:04 -04:00
parent 1b9b85115b
commit edc670d079
2 changed files with 13 additions and 0 deletions

View File

@ -31,6 +31,16 @@ func decodeProvisionerBlock(block *hcl.Block) (*Provisioner, hcl.Diagnostics) {
content, config, diags := block.Body.PartialContent(provisionerBlockSchema) content, config, diags := block.Body.PartialContent(provisionerBlockSchema)
pv.Config = config pv.Config = config
switch pv.Type {
case "chef", "habitat", "puppet", "salt-masterless":
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: fmt.Sprintf("The \"%s\" provisioner is deprecated", pv.Type),
Detail: fmt.Sprintf("The \"%s\" provisioner is deprecated and will be removed from future versions of Terraform. Visit https://learn.hashicorp.com/collections/terraform/provision for alternatives to using provisioners that are a better fit for the Terraform workflow.", pv.Type),
Subject: &pv.TypeRange,
})
}
if attr, exists := content.Attributes["when"]; exists { if attr, exists := content.Attributes["when"]; exists {
expr, shimDiags := shimTraversalInString(attr.Expr, true) expr, shimDiags := shimTraversalInString(attr.Expr, true)
diags = append(diags, shimDiags...) diags = append(diags, shimDiags...)

View File

@ -0,0 +1,3 @@
resource "null_resource" "test" {
provisioner "habitat" {} # WARNING: The "habitat" provisioner is deprecated
}