check for nil config map (#10730)

This commit is contained in:
Sylvia Moss 2021-03-05 11:10:00 +01:00 committed by GitHub
parent 9df637d1f3
commit 610dde7f02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -1033,7 +1033,12 @@ func writeProvisioner(typeName string, provisioner *template.Provisioner) []byte
provisionerContent := hclwrite.NewEmptyFile()
body := provisionerContent.Body()
block := body.AppendNewBlock(typeName, []string{provisioner.Type})
cfg := provisioner.Config
if cfg == nil {
cfg = map[string]interface{}{}
}
if len(provisioner.Except) > 0 {
cfg["except"] = provisioner.Except
}
@ -1086,6 +1091,10 @@ func (p *PostProcessorParser) Parse(tpl *template.Template) error {
ppBody.SetAttributeValue("keep_input_artifact", cty.BoolVal(*pp.KeepInputArtifact))
}
cfg := pp.Config
if cfg == nil {
cfg = map[string]interface{}{}
}
if len(pp.Except) > 0 {
cfg["except"] = pp.Except
}

View File

@ -172,6 +172,11 @@ source "amazon-ebs" "named_builder" {
build {
sources = ["source.amazon-ebs.autogenerated_1", "source.amazon-ebs.named_builder"]
provisioner "breakpoint" {
only = ["amazon-ebs"]
pause_before = "5s"
}
provisioner "shell" {
except = ["amazon-ebs"]
inline = ["echo ${var.secret_account}", "echo ${build.ID}", "echo ${build.SSHPublicKey} | head -c 14", "echo ${path.root} is not ${path.cwd}", "echo ${packer.version}", "echo ${uuidv4()}"]
@ -277,5 +282,7 @@ build {
Description = "packer amazon-import ${local.timestamp}"
}
}
post-processor "compress" {
}
}
}

View File

@ -116,6 +116,13 @@
}
],
"provisioners": [
{
"type": "breakpoint",
"only": [
"amazon-ebs"
],
"pause_before": "5s"
},
{
"type": "shell",
"except": [
@ -230,6 +237,9 @@
"tags": {
"Description": "packer amazon-import {{timestamp}}"
}
},
{
"type": "compress"
}
]
]