File tree 1 file changed +8
-13
lines changed
1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ import (
12
12
type WorkspacePreset struct {
13
13
Name string `mapstructure:"name"`
14
14
Parameters map [string ]string `mapstructure:"parameters"`
15
- Prebuilds WorkspacePrebuild `mapstructure:"prebuilds"`
15
+ // There should always be only one prebuild block, but Terraform's type system
16
+ // still parses them as a slice, so we need to handle it as such. We could use
17
+ // an anonymous type and rd.Get to avoid a slice here, but that would not be possible
18
+ // for utilities that parse our terraform output using this type. To remain compatible
19
+ // with those cases, we use a slice here.
20
+ Prebuilds []WorkspacePrebuild `mapstructure:"prebuilds"`
16
21
}
17
22
18
23
type WorkspacePrebuild struct {
@@ -27,19 +32,9 @@ func workspacePresetDataSource() *schema.Resource {
27
32
ReadContext : func (ctx context.Context , rd * schema.ResourceData , i interface {}) diag.Diagnostics {
28
33
var preset WorkspacePreset
29
34
err := mapstructure .Decode (struct {
30
- Name interface {}
31
- Parameters interface {}
32
- Prebuilds struct {
33
- Instances interface {}
34
- }
35
+ Name interface {}
35
36
}{
36
- Name : rd .Get ("name" ),
37
- Parameters : rd .Get ("parameters" ),
38
- Prebuilds : struct {
39
- Instances interface {}
40
- }{
41
- Instances : rd .Get ("prebuilds.0.instances" ),
42
- },
37
+ Name : rd .Get ("name" ),
43
38
}, & preset )
44
39
if err != nil {
45
40
return diag .Errorf ("decode workspace preset: %s" , err )
You can’t perform that action at this time.
0 commit comments