mirror of https://github.com/hashicorp/packer
HCL2: pass on builder type and name (#8956)
* sets `packer_build_name` and `packer_builder_type` variables for builder provisioners and post-processors in HCL2
* allows to use the new `${source.type}` and `${source.name}` variables in HCL2
* fixes #8932
Note that the common.PackerConfig is used everywhere and was not set for HCL2, this had some implications:
For #8923 you can see the issue here:
dde74232f2/builder/lxd/config.go (L61-L63)
More random examples of where this could cause an issue :
0785c2f6fc/provisioner/ansible-local/provisioner.go (L380-L381)
b4efd13a4d/builder/amazon/ebs/builder.go (L232-L236)
* [All references to PackerConfig.PackerBuildName](https://sourcegraph.com/github.com/hashicorp/packer@ff6a039d5bb45e34ff761d9c52e8b98972288447/-/blob/common/packer_config.go#L7:2&tab=references)
* [All references to PackerConfig.PackerBuilderType](https://sourcegraph.com/github.com/hashicorp/packer@ff6a039d5bb45e34ff761d9c52e8b98972288447/-/blob/common/packer_config.go#L8:2&tab=references)
pull/9037/head
parent
c358682411
commit
2af40c762b
@ -0,0 +1,21 @@
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"name": "test",
|
||||
"communicator": "none",
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"name": "potato",
|
||||
"communicator": "none",
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
{
|
||||
"type": "manifest",
|
||||
"output": "manifest.json",
|
||||
"strip_time": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
source "null" "test" {
|
||||
communicator = "none"
|
||||
}
|
||||
|
||||
source "null" "potato" {
|
||||
communicator = "none"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"sources.null.test",
|
||||
"sources.null.potato",
|
||||
]
|
||||
|
||||
provisioner "shell-local" {
|
||||
inline = [
|
||||
"echo '' > ${source.type}.${source.name}.txt"
|
||||
]
|
||||
}
|
||||
|
||||
post-processor "manifest" {
|
||||
output = "manifest.json"
|
||||
strip_time = true
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
<!-- Code generated from the comments of the Config struct in post-processor/manifest/post-processor.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `output` (string) - The manifest will be written to this file. This defaults to
|
||||
`packer-manifest.json`.
|
||||
|
||||
- `strip_path` (bool) - Write only filename without the path to the manifest file. This defaults
|
||||
to false.
|
||||
|
||||
- `strip_time` (bool) - Don't write the `build_time` field from the output.
|
||||
|
||||
- `custom_data` (map[string]string) - Arbitrary data to add to the manifest. This is a [template
|
||||
engine](https://packer.io/docs/templates/engine.html). Therefore, you
|
||||
may use user variables and template functions in this field.
|
||||
|
||||
Loading…
Reference in new issue