@@ -10,7 +10,6 @@ import (
10
10
"github.com/hashicorp/hcl/v2/hclsyntax"
11
11
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
12
12
hcl2shim "github.com/hashicorp/packer/hcl2template/shim"
13
- "github.com/hashicorp/packer/packer"
14
13
"github.com/zclconf/go-cty/cty"
15
14
)
16
15
@@ -65,31 +64,33 @@ func (ds *Datasources) Values() (map[string]cty.Value, hcl.Diagnostics) {
65
64
return res , diags
66
65
}
67
66
68
- func (cfg * PackerConfig ) startDatasource (dataSourceStore packer. DatasourceStore , ref DatasourceRef , secondaryEvaluation bool ) (packersdk.Datasource , hcl.Diagnostics ) {
67
+ func (cfg * PackerConfig ) startDatasource (ds DatasourceBlock ) (packersdk.Datasource , hcl.Diagnostics ) {
69
68
var diags hcl.Diagnostics
70
- block := cfg .Datasources [ref ].block
69
+ block := ds .block
70
+
71
+ dataSourceStore := cfg .parser .PluginConfig .DataSources
71
72
72
73
if dataSourceStore == nil {
73
74
diags = append (diags , & hcl.Diagnostic {
74
- Summary : "Unknown " + dataSourceLabel + " type " + ref .Type ,
75
+ Summary : "Unknown " + dataSourceLabel + " type " + ds .Type ,
75
76
Subject : block .LabelRanges [0 ].Ptr (),
76
77
Detail : "packer does not currently know any data source." ,
77
78
Severity : hcl .DiagError ,
78
79
})
79
80
return nil , diags
80
81
}
81
82
82
- if ! dataSourceStore .Has (ref .Type ) {
83
+ if ! dataSourceStore .Has (ds .Type ) {
83
84
diags = append (diags , & hcl.Diagnostic {
84
- Summary : "Unknown " + dataSourceLabel + " type " + ref .Type ,
85
+ Summary : "Unknown " + dataSourceLabel + " type " + ds .Type ,
85
86
Subject : block .LabelRanges [0 ].Ptr (),
86
87
Detail : fmt .Sprintf ("known data sources: %v" , dataSourceStore .List ()),
87
88
Severity : hcl .DiagError ,
88
89
})
89
90
return nil , diags
90
91
}
91
92
92
- datasource , err := dataSourceStore .Start (ref .Type )
93
+ datasource , err := dataSourceStore .Start (ds .Type )
93
94
if err != nil {
94
95
diags = append (diags , & hcl.Diagnostic {
95
96
Summary : err .Error (),
@@ -99,7 +100,7 @@ func (cfg *PackerConfig) startDatasource(dataSourceStore packer.DatasourceStore,
99
100
}
100
101
if datasource == nil {
101
102
diags = append (diags , & hcl.Diagnostic {
102
- Summary : fmt .Sprintf ("failed to start datasource plugin %q.%q" , ref .Type , ref .Name ),
103
+ Summary : fmt .Sprintf ("failed to start datasource plugin %q.%q" , ds .Type , ds .Name ),
103
104
Subject : & block .DefRange ,
104
105
Severity : hcl .DiagError ,
105
106
})
0 commit comments