Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a2c18d

Browse files
authored
Correct the prebuilds type (#376)
1 parentef92eea commit3a2c18d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

‎provider/workspace_preset.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import (
1212
typeWorkspacePresetstruct {
1313
Namestring`mapstructure:"name"`
1414
Parametersmap[string]string`mapstructure:"parameters"`
15-
PrebuildsWorkspacePrebuild`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

1823
typeWorkspacePrebuildstruct {
@@ -27,19 +32,9 @@ func workspacePresetDataSource() *schema.Resource {
2732
ReadContext:func(ctx context.Context,rd*schema.ResourceData,iinterface{}) diag.Diagnostics {
2833
varpresetWorkspacePreset
2934
err:=mapstructure.Decode(struct {
30-
Nameinterface{}
31-
Parametersinterface{}
32-
Prebuildsstruct {
33-
Instancesinterface{}
34-
}
35+
Nameinterface{}
3536
}{
36-
Name:rd.Get("name"),
37-
Parameters:rd.Get("parameters"),
38-
Prebuilds:struct {
39-
Instancesinterface{}
40-
}{
41-
Instances:rd.Get("prebuilds.0.instances"),
42-
},
37+
Name:rd.Get("name"),
4338
},&preset)
4439
iferr!=nil {
4540
returndiag.Errorf("decode workspace preset: %s",err)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp