From ca123721a64dab3589e69d81eae591b544469b1c Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 5 Feb 2021 11:06:52 -0800 Subject: [PATCH] plugin loading failure should be considered an error so build will not try to run --- hcl2template/types.build.post-processor.go | 7 ++++--- hcl2template/types.build.provisioners.go | 7 ++++--- hcl2template/types.source.go | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hcl2template/types.build.post-processor.go b/hcl2template/types.build.post-processor.go index e79f808e5..a70d9dd61 100644 --- a/hcl2template/types.build.post-processor.go +++ b/hcl2template/types.build.post-processor.go @@ -59,9 +59,10 @@ func (cfg *PackerConfig) startPostProcessor(source SourceUseBlock, pp *PostProce postProcessor, err := cfg.parser.PluginConfig.PostProcessors.Start(pp.PType) if err != nil { diags = append(diags, &hcl.Diagnostic{ - Summary: fmt.Sprintf("Failed loading %s", pp.PType), - Subject: pp.DefRange.Ptr(), - Detail: err.Error(), + Severity: hcl.DiagError, + Summary: fmt.Sprintf("Failed loading %s", pp.PType), + Subject: pp.DefRange.Ptr(), + Detail: err.Error(), }) return nil, diags } diff --git a/hcl2template/types.build.provisioners.go b/hcl2template/types.build.provisioners.go index 96f975a0b..818d05be1 100644 --- a/hcl2template/types.build.provisioners.go +++ b/hcl2template/types.build.provisioners.go @@ -146,9 +146,10 @@ func (cfg *PackerConfig) startProvisioner(source SourceUseBlock, pb *Provisioner provisioner, err := cfg.parser.PluginConfig.Provisioners.Start(pb.PType) if err != nil { diags = append(diags, &hcl.Diagnostic{ - Summary: fmt.Sprintf("failed loading %s", pb.PType), - Subject: pb.HCL2Ref.LabelsRanges[0].Ptr(), - Detail: err.Error(), + Severity: hcl.DiagError, + Summary: fmt.Sprintf("failed loading %s", pb.PType), + Subject: pb.HCL2Ref.LabelsRanges[0].Ptr(), + Detail: err.Error(), }) return nil, diags } diff --git a/hcl2template/types.source.go b/hcl2template/types.source.go index cbdd54277..dde0ed257 100644 --- a/hcl2template/types.source.go +++ b/hcl2template/types.source.go @@ -101,8 +101,9 @@ func (cfg *PackerConfig) startBuilder(source SourceUseBlock, ectx *hcl.EvalConte builder, err := cfg.parser.PluginConfig.Builders.Start(source.Type) if err != nil { diags = append(diags, &hcl.Diagnostic{ - Summary: "Failed to load " + sourceLabel + " type", - Detail: err.Error(), + Severity: hcl.DiagError, + Summary: "Failed to load " + sourceLabel + " type", + Detail: err.Error(), }) return builder, diags, nil }