From edc670d0791a95ae76ce7cb4f10fb629e7f9f8d4 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Wed, 26 Aug 2020 10:46:04 -0400 Subject: [PATCH] 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 --- configs/provisioner.go | 10 ++++++++++ configs/testdata/warning-files/vendor_provisioners.tf | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 configs/testdata/warning-files/vendor_provisioners.tf diff --git a/configs/provisioner.go b/configs/provisioner.go index 769382513..5b664d39b 100644 --- a/configs/provisioner.go +++ b/configs/provisioner.go @@ -31,6 +31,16 @@ func decodeProvisionerBlock(block *hcl.Block) (*Provisioner, hcl.Diagnostics) { content, config, diags := block.Body.PartialContent(provisionerBlockSchema) 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 { expr, shimDiags := shimTraversalInString(attr.Expr, true) diags = append(diags, shimDiags...) diff --git a/configs/testdata/warning-files/vendor_provisioners.tf b/configs/testdata/warning-files/vendor_provisioners.tf new file mode 100644 index 000000000..7da591df6 --- /dev/null +++ b/configs/testdata/warning-files/vendor_provisioners.tf @@ -0,0 +1,3 @@ +resource "null_resource" "test" { + provisioner "habitat" {} # WARNING: The "habitat" provisioner is deprecated +}