File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ import (
1212type WorkspacePreset struct {
1313 Name string `mapstructure:"name"`
1414 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"`
1621}
1722
1823type WorkspacePrebuild struct {
@@ -27,19 +32,9 @@ func workspacePresetDataSource() *schema.Resource {
2732 ReadContext : func (ctx context.Context , rd * schema.ResourceData , i interface {}) diag.Diagnostics {
2833 var preset WorkspacePreset
2934 err := mapstructure .Decode (struct {
30- Name interface {}
31- Parameters interface {}
32- Prebuilds struct {
33- Instances interface {}
34- }
35+ Name interface {}
3536 }{
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" ),
4338 }, & preset )
4439 if err != nil {
4540 return diag .Errorf ("decode workspace preset: %s" , err )
You can’t perform that action at this time.
0 commit comments