From 34ff3d0c8f2ed67e3a23bd06ef5a407a6754fd79 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 7 Jul 2020 11:29:27 +0200 Subject: [PATCH] hcl2 GetBuilds: use packer.BuilderDataCommonKeys to avoid forcing all builders to return exactly what they will return It would have been a bit nicer if all builder were more specific in order for hcl to tell wether a value will be set during the first prepare time but that also totally works ! --- hcl2template/types.packer_config.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hcl2template/types.packer_config.go b/hcl2template/types.packer_config.go index a19dba2dd..dd72a6955 100644 --- a/hcl2template/types.packer_config.go +++ b/hcl2template/types.packer_config.go @@ -7,7 +7,6 @@ import ( "github.com/gobwas/glob" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclsyntax" - "github.com/hashicorp/packer/helper/common" "github.com/hashicorp/packer/packer" "github.com/zclconf/go-cty/cty" ) @@ -361,11 +360,8 @@ func (cfg *PackerConfig) GetBuilds(opts packer.GetBuildsOptions) ([]packer.Build // the provisioner prepare() so that the provisioner can appropriately // validate user input against what will become available. Otherwise, // only pass the default variables, using the basic placeholder data. - generatedPlaceholderMap := packer.BasicPlaceholderData() unknownBuildValues := map[string]cty.Value{} - for _, k := range generatedVars { - generatedPlaceholderMap[k] = fmt.Sprintf("Build_%s. "+ - common.PlaceholderMsg, k) + for _, k := range append(packer.BuilderDataCommonKeys, generatedVars...) { unknownBuildValues[k] = cty.StringVal("") }