From 5bacd370141396be68ce22aea3d1b7e6156417d7 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 17 Dec 2019 16:13:21 -0800 Subject: [PATCH] fix pps --- command/build.go | 11 ++++++----- hcl2template/types.packer_config.go | 7 ++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/command/build.go b/command/build.go index 74fbd8445..74b21b17f 100644 --- a/command/build.go +++ b/command/build.go @@ -136,11 +136,12 @@ func (c *BuildCommand) GetBuilds(path string) ([]packer.Build, int) { return c.GetBuildsFromHCL(path) } - c.Ui.Say(`Legacy JSON Configuration Will Be Used. -The template will be parsed in the legacy configuration style. This style -will continue to work but users are encouraged to move to the new style. -See: https://packer.io/guides/hcl -`) + // TODO: uncomment in v1.5.1 once we've polished HCL a bit more. + // c.Ui.Say(`Legacy JSON Configuration Will Be Used. + // The template will be parsed in the legacy configuration style. This style + // will continue to work but users are encouraged to move to the new style. + // See: https://packer.io/guides/hcl + // `) // Parse the template var tpl *template.Template diff --git a/hcl2template/types.packer_config.go b/hcl2template/types.packer_config.go index d33adf93d..dc8f29536 100644 --- a/hcl2template/types.packer_config.go +++ b/hcl2template/types.packer_config.go @@ -45,6 +45,7 @@ func (p *Parser) CoreBuildPostProcessors(blocks []*PostProcessorBlock) ([]packer PType: pp.PType, }) } + return res, diags } @@ -74,6 +75,10 @@ func (p *Parser) getBuilds(cfg *PackerConfig) ([]packer.Build, hcl.Diagnostics) continue } postProcessors, moreDiags := p.CoreBuildPostProcessors(build.PostProcessors) + pps := [][]packer.CoreBuildPostProcessor{} + if len(postProcessors) > 0 { + pps = [][]packer.CoreBuildPostProcessor{postProcessors} + } diags = append(diags, moreDiags...) if moreDiags.HasErrors() { continue @@ -83,7 +88,7 @@ func (p *Parser) getBuilds(cfg *PackerConfig) ([]packer.Build, hcl.Diagnostics) Type: src.Type, Builder: builder, Provisioners: provisioners, - PostProcessors: [][]packer.CoreBuildPostProcessor{postProcessors}, + PostProcessors: pps, Variables: cfg.Variables, } res = append(res, pcb)