mirror of https://github.com/hashicorp/packer
Fix {{packer_version}} interpolation regression (#11200)
* Add Packer version to main context at variable interpolation
Test Results Before Change
```
=== RUN TestCoreBuild_packerVersion
testing.go:30: err: template: root:1:2: executing "root" at <packer_version>: error calling packer_version: packer_version not available
--- FAIL: TestCoreBuild_packerVersion (0.00s)
```
Test Results After Change
```
=== RUN TestCoreBuild_packerVersion
--- PASS: TestCoreBuild_packerVersion (0.00s)
```
* Add packer_core_version to interpolation context for HCL configs
Test Results Before Change
```
=== RUN TestParse_build/provisioner_with_packer_version_interpolation
common_test.go:109: Parser.getBuilds() unexpected diagnostics. testdata/build/provisioner_packer_version_interpolation.pkr.hcl:8,5-24: Failed preparing provisioner-block
"shell" ""; render 'slice_string': template: root:1:2: executing "root" at <packer_version>: error calling packer_version: packer_version not available in:
{{packer_version}}
--- FAIL: TestParse_build (0.01s)
```
Test Results After Change
```
--- PASS: TestParse_build (0.02s)
--- PASS: TestParse_build/provisioner_with_packer_version_interpolation (0.00s)
```
pull/11205/head
parent
689c7763d4
commit
e8b5b4b516
@ -0,0 +1,15 @@
|
||||
|
||||
// starts resources to provision them.
|
||||
build {
|
||||
sources = [
|
||||
"source.virtualbox-iso.ubuntu-1204",
|
||||
]
|
||||
|
||||
provisioner "shell" {
|
||||
slice_string = ["{{packer_version}}"]
|
||||
}
|
||||
}
|
||||
|
||||
source "virtualbox-iso" "ubuntu-1204" {
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"variables": {
|
||||
"CreatedBy": "{{packer_version}}"
|
||||
},
|
||||
"builders": [{
|
||||
"type": "test",
|
||||
"value": "{{user `CreatedBy`}}"
|
||||
}]
|
||||
}
|
||||
Loading…
Reference in new issue