plugin loading failure should be considered an error so build will not try to run

This commit is contained in:
Megan Marsh 2021-02-05 11:06:52 -08:00
parent 540effbbc0
commit ca123721a6
3 changed files with 11 additions and 8 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}