File tree Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -90,10 +90,11 @@ func TestIntegration(t *testing.T) {
9090 // TODO (sasswart): the cli doesn't support presets yet.
9191 // once it does, the value for workspace_parameter.value
9292 // will be the preset value.
93- "workspace_parameter.value" : `param value` ,
94- "workspace_parameter.icon" : `param icon` ,
95- "workspace_preset.name" : `preset` ,
96- "workspace_preset.parameters.param" : `preset param value` ,
93+ "workspace_parameter.value" : `param value` ,
94+ "workspace_parameter.icon" : `param icon` ,
95+ "workspace_preset.name" : `preset` ,
96+ "workspace_preset.parameters.param" : `preset param value` ,
97+ "workspace_preset.prebuilds.instances" : `1` ,
9798 },
9899 },
99100 {
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ data "coder_workspace_preset" "preset" {
2424 parameters = {
2525 (data. coder_parameter . param . name ) = " preset param value"
2626 }
27+
28+ prebuilds {
29+ instances = 1
30+ }
2731}
2832
2933locals {
@@ -47,6 +51,7 @@ locals {
4751 " workspace_parameter.icon" : data.coder_parameter.param.icon,
4852 " workspace_preset.name" : data.coder_workspace_preset.preset.name,
4953 " workspace_preset.parameters.param" : data.coder_workspace_preset.preset.parameters.param,
54+ " workspace_preset.prebuilds.instances" : tostring (one (data. coder_workspace_preset . preset . prebuilds ). instances ),
5055 }
5156}
5257
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ import (
1010)
1111
1212type WorkspacePreset struct {
13- Name string `mapstructure:"name"`
14- Parameters map [string ]string `mapstructure:"parameters"`
15- Prebuild [] WorkspacePrebuild `mapstructure:"prebuilds"`
13+ Name string `mapstructure:"name"`
14+ Parameters map [string ]string `mapstructure:"parameters"`
15+ Prebuilds WorkspacePrebuild `mapstructure:"prebuilds"`
1616}
1717
1818type WorkspacePrebuild struct {
@@ -29,31 +29,22 @@ func workspacePresetDataSource() *schema.Resource {
2929 err := mapstructure .Decode (struct {
3030 Name interface {}
3131 Parameters interface {}
32- Prebuilds [] struct {
32+ Prebuilds struct {
3333 Instances interface {}
3434 }
3535 }{
3636 Name : rd .Get ("name" ),
3737 Parameters : rd .Get ("parameters" ),
38- Prebuilds : [] struct {
38+ Prebuilds : struct {
3939 Instances interface {}
4040 }{
41- {
42- Instances : rd .Get ("prebuilds.0.instances" ),
43- },
41+ Instances : rd .Get ("prebuilds.0.instances" ),
4442 },
4543 }, & preset )
4644 if err != nil {
4745 return diag .Errorf ("decode workspace preset: %s" , err )
4846 }
4947
50- // MinItems doesn't work with maps, so we need to check the length
51- // of the map manually. All other validation is handled by the
52- // schema.
53- if len (preset .Parameters ) == 0 {
54- return diag .Errorf ("expected \" parameters\" to not be an empty map" )
55- }
56-
5748 rd .SetId (preset .Name )
5849
5950 return nil
You can’t perform that action at this time.
0 commit comments