|
|
|
|
@ -10,7 +10,6 @@ import (
|
|
|
|
|
"github.com/hashicorp/hcl/v2/hclsyntax"
|
|
|
|
|
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
|
|
|
|
hcl2shim "github.com/hashicorp/packer/hcl2template/shim"
|
|
|
|
|
"github.com/hashicorp/packer/packer"
|
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@ -65,13 +64,15 @@ func (ds *Datasources) Values() (map[string]cty.Value, hcl.Diagnostics) {
|
|
|
|
|
return res, diags
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (cfg *PackerConfig) startDatasource(dataSourceStore packer.DatasourceStore, ref DatasourceRef, secondaryEvaluation bool) (packersdk.Datasource, hcl.Diagnostics) {
|
|
|
|
|
func (cfg *PackerConfig) startDatasource(ds DatasourceBlock) (packersdk.Datasource, hcl.Diagnostics) {
|
|
|
|
|
var diags hcl.Diagnostics
|
|
|
|
|
block := cfg.Datasources[ref].block
|
|
|
|
|
block := ds.block
|
|
|
|
|
|
|
|
|
|
dataSourceStore := cfg.parser.PluginConfig.DataSources
|
|
|
|
|
|
|
|
|
|
if dataSourceStore == nil {
|
|
|
|
|
diags = append(diags, &hcl.Diagnostic{
|
|
|
|
|
Summary: "Unknown " + dataSourceLabel + " type " + ref.Type,
|
|
|
|
|
Summary: "Unknown " + dataSourceLabel + " type " + ds.Type,
|
|
|
|
|
Subject: block.LabelRanges[0].Ptr(),
|
|
|
|
|
Detail: "packer does not currently know any data source.",
|
|
|
|
|
Severity: hcl.DiagError,
|
|
|
|
|
@ -79,9 +80,9 @@ func (cfg *PackerConfig) startDatasource(dataSourceStore packer.DatasourceStore,
|
|
|
|
|
return nil, diags
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !dataSourceStore.Has(ref.Type) {
|
|
|
|
|
if !dataSourceStore.Has(ds.Type) {
|
|
|
|
|
diags = append(diags, &hcl.Diagnostic{
|
|
|
|
|
Summary: "Unknown " + dataSourceLabel + " type " + ref.Type,
|
|
|
|
|
Summary: "Unknown " + dataSourceLabel + " type " + ds.Type,
|
|
|
|
|
Subject: block.LabelRanges[0].Ptr(),
|
|
|
|
|
Detail: fmt.Sprintf("known data sources: %v", dataSourceStore.List()),
|
|
|
|
|
Severity: hcl.DiagError,
|
|
|
|
|
@ -89,7 +90,7 @@ func (cfg *PackerConfig) startDatasource(dataSourceStore packer.DatasourceStore,
|
|
|
|
|
return nil, diags
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource, err := dataSourceStore.Start(ref.Type)
|
|
|
|
|
datasource, err := dataSourceStore.Start(ds.Type)
|
|
|
|
|
if err != nil {
|
|
|
|
|
diags = append(diags, &hcl.Diagnostic{
|
|
|
|
|
Summary: err.Error(),
|
|
|
|
|
@ -99,7 +100,7 @@ func (cfg *PackerConfig) startDatasource(dataSourceStore packer.DatasourceStore,
|
|
|
|
|
}
|
|
|
|
|
if datasource == nil {
|
|
|
|
|
diags = append(diags, &hcl.Diagnostic{
|
|
|
|
|
Summary: fmt.Sprintf("failed to start datasource plugin %q.%q", ref.Type, ref.Name),
|
|
|
|
|
Summary: fmt.Sprintf("failed to start datasource plugin %q.%q", ds.Type, ds.Name),
|
|
|
|
|
Subject: &block.DefRange,
|
|
|
|
|
Severity: hcl.DiagError,
|
|
|
|
|
})
|
|
|
|
|
|