File tree 3 files changed +16
-19
lines changed
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) {
90
90
// TODO (sasswart): the cli doesn't support presets yet.
91
91
// once it does, the value for workspace_parameter.value
92
92
// 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` ,
97
98
},
98
99
},
99
100
{
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ data "coder_workspace_preset" "preset" {
24
24
parameters = {
25
25
(data. coder_parameter . param . name ) = " preset param value"
26
26
}
27
+
28
+ prebuilds {
29
+ instances = 1
30
+ }
27
31
}
28
32
29
33
locals {
@@ -47,6 +51,7 @@ locals {
47
51
" workspace_parameter.icon" : data.coder_parameter.param.icon,
48
52
" workspace_preset.name" : data.coder_workspace_preset.preset.name,
49
53
" 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 ),
50
55
}
51
56
}
52
57
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ import (
10
10
)
11
11
12
12
type 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"`
16
16
}
17
17
18
18
type WorkspacePrebuild struct {
@@ -29,31 +29,22 @@ func workspacePresetDataSource() *schema.Resource {
29
29
err := mapstructure .Decode (struct {
30
30
Name interface {}
31
31
Parameters interface {}
32
- Prebuilds [] struct {
32
+ Prebuilds struct {
33
33
Instances interface {}
34
34
}
35
35
}{
36
36
Name : rd .Get ("name" ),
37
37
Parameters : rd .Get ("parameters" ),
38
- Prebuilds : [] struct {
38
+ Prebuilds : struct {
39
39
Instances interface {}
40
40
}{
41
- {
42
- Instances : rd .Get ("prebuilds.0.instances" ),
43
- },
41
+ Instances : rd .Get ("prebuilds.0.instances" ),
44
42
},
45
43
}, & preset )
46
44
if err != nil {
47
45
return diag .Errorf ("decode workspace preset: %s" , err )
48
46
}
49
47
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
-
57
48
rd .SetId (preset .Name )
58
49
59
50
return nil
You can’t perform that action at this time.
0 commit comments