From cbc16cfed51dbc011658d365b3531ab3d0116848 Mon Sep 17 00:00:00 2001 From: Devashish Date: Fri, 26 Jan 2024 12:04:53 -0500 Subject: [PATCH] Add versionFingerprint to EvalContext --- hcl2template/types.packer_config.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hcl2template/types.packer_config.go b/hcl2template/types.packer_config.go index 109632261..b88dfe4d3 100644 --- a/hcl2template/types.packer_config.go +++ b/hcl2template/types.packer_config.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/gobwas/glob" - hcl "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/hcl/v2/hclsyntax" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" @@ -128,6 +128,14 @@ func (cfg *PackerConfig) EvalContext(ctx BlockContext, variables map[string]cty. }) } + versionFingerprint, ok := cfg.HCPVars["versionFingerprint"] + if ok { + ectx.Variables[packerAccessor] = cty.ObjectVal(map[string]cty.Value{ + "version": cty.StringVal(cfg.CorePackerVersionString), + "versionFingerprint": versionFingerprint, + }) + } + // In the future we'd like to load and execute HCL blocks using a graph // dependency tree, so that any block can use any block whatever the // order.