Add the deprecation warning and update docs

pull/12809/head
Devashish 2 years ago committed by Lucas Bajolet
parent cbc16cfed5
commit b77d581cda

@ -5,6 +5,7 @@ package hcl2template
import (
"fmt"
"log"
"sort"
"strings"
@ -110,8 +111,9 @@ func (cfg *PackerConfig) EvalContext(ctx BlockContext, variables map[string]cty.
}),
buildAccessor: cty.UnknownVal(cty.EmptyObject),
packerAccessor: cty.ObjectVal(map[string]cty.Value{
"version": cty.StringVal(cfg.CorePackerVersionString),
"iterationID": cty.UnknownVal(cty.String),
"version": cty.StringVal(cfg.CorePackerVersionString),
"iterationID": cty.UnknownVal(cty.String),
"versionFingerprint": cty.UnknownVal(cty.String),
}),
pathVariablesAccessor: cty.ObjectVal(map[string]cty.Value{
"cwd": cty.StringVal(strings.ReplaceAll(cfg.Cwd, `\`, `/`)),
@ -122,6 +124,8 @@ func (cfg *PackerConfig) EvalContext(ctx BlockContext, variables map[string]cty.
iterID, ok := cfg.HCPVars["iterationID"]
if ok {
log.Printf("[WARN] Deprecation: Contextual Variable `iterationID` has been deprecated packer context. " +
"Please use `versionFingerprint` variable instead.")
ectx.Variables[packerAccessor] = cty.ObjectVal(map[string]cty.Value{
"version": cty.StringVal(cfg.CorePackerVersionString),
"iterationID": iterID,

@ -132,6 +132,8 @@ parenthesis may through off your shell escaping otherwise.
# HCP Packer Iteration ID
~> **Note**: Deprecation: Contextual Variable `iterationID` has been deprecated packer context. Please use `versionFingerprint` variable instead.
If your build is pushing metadata to the HCP Packer registry, this variable is
set to the value of the Iteration ID associated with this run.
@ -145,6 +147,22 @@ source "amazon-ebs" "cannonical-ubuntu-server" {
}
```
# HCP Packer Version Fingerprint
If your build is pushing metadata to the HCP Packer registry, this variable is
set to the value of the Version Fingerprint associated with this run.
```hcl
source "amazon-ebs" "cannonical-ubuntu-server" {
ami_name = "packer-example"
// ...
run_volume_tags = {
hcp_version_fingerprint = packer.versionFingerprint
}
}
```
```shell-session
==> vanilla.amazon-ebs.cannonical-ubuntu-server: Adding tags to source instance
vanilla.amazon-ebs.cannonical-ubuntu-server: Adding tag: "Name": "Packer Builder"
@ -158,6 +176,8 @@ You can also add this value to post-processors, for example to add to a manifest
output = "manifest.json"
strip_path = true
custom_data = {
version_fingerprint = "${packer.versionFingerprint}"
// `packer.iterationID` has been deprecated.
iteration = "${packer.iterationID}"
}
}

Loading…
Cancel
Save