Skip to content

Commit 9f26791

Browse files
committed
additional documentation for prebuilds
1 parent 06cf760 commit 9f26791

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

docs/data-sources/workspace.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ resource "docker_container" "workspace" {
6969
- `access_port` (Number) The access port of the Coder deployment provisioning this workspace.
7070
- `access_url` (String) The access URL of the Coder deployment provisioning this workspace.
7171
- `id` (String) UUID of the workspace.
72-
- `is_prebuild` (Boolean) Whether the workspace is a prebuild.
72+
- `is_prebuild` (Boolean) Similar to `prebuild_count`, but a boolean value instead of a count. This is set to true if the workspace is a currently unassigned prebuild. Once the workspace is assigned, this value will be false.
7373
- `name` (String) Name of the workspace.
74-
- `prebuild_count` (Number) A computed count, equal to 1 if the workspace was prebuilt.
74+
- `prebuild_count` (Number) A computed count, equal to 1 if the workspace is a currently unassigned prebuild. Use this to conditionally act on the status of a prebuild. Actions that do not require user identity can be taken when this value is set to 1. Actions that should only be taken once the workspace has been assigned to a user may be taken when this value is set to 0.
7575
- `start_count` (Number) A computed count based on `transition` state. If `start`, count will equal 1.
7676
- `template_id` (String) ID of the workspace's template.
7777
- `template_name` (String) Name of the workspace's template.

docs/data-sources/workspace_preset.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "coder_workspace_preset Data Source - terraform-provider-coder"
44
subcategory: ""
55
description: |-
6-
Use this data source to predefine common configurations for workspaces.
6+
Use this data source to predefine common configurations for coder workspaces. Users will have the option to select a defined preset, which will automatically apply the selected configuration. Any parameters defined in the preset will be applied to the workspace. Parameters that are not defined by the preset will still be configurable when creating a workspace.
77
---
88

99
# coder_workspace_preset (Data Source)
1010

11-
Use this data source to predefine common configurations for workspaces.
11+
Use this data source to predefine common configurations for coder workspaces. Users will have the option to select a defined preset, which will automatically apply the selected configuration. Any parameters defined in the preset will be applied to the workspace. Parameters that are not defined by the preset will still be configurable when creating a workspace.
1212

1313
## Example Usage
1414

@@ -34,20 +34,20 @@ data "coder_workspace_preset" "example" {
3434

3535
### Required
3636

37-
- `name` (String) Name of the workspace preset.
38-
- `parameters` (Map of String) Parameters of the workspace preset.
37+
- `name` (String) The name of the workspace preset.
3938

4039
### Optional
4140

42-
- `prebuilds` (Block Set, Max: 1) Prebuilds of the workspace preset. (see [below for nested schema](#nestedblock--prebuilds))
41+
- `parameters` (Map of String) Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
42+
- `prebuilds` (Block Set, Max: 1) Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build. (see [below for nested schema](#nestedblock--prebuilds))
4343

4444
### Read-Only
4545

46-
- `id` (String) ID of the workspace preset.
46+
- `id` (String) The preset ID is automatically generated and may change between runs. It is recommended to use the `name` attribute to identify the preset.
4747

4848
<a id="nestedblock--prebuilds"></a>
4949
### Nested Schema for `prebuilds`
5050

5151
Required:
5252

53-
- `instances` (Number)
53+
- `instances` (Number) The number of workspaces to keep in reserve for this preset.

provider/workspace.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func workspaceDataSource() *schema.Resource {
9494
"prebuild_count": {
9595
Type: schema.TypeInt,
9696
Computed: true,
97-
Description: "A computed count, equal to 1 if the workspace was prebuilt.",
97+
Description: "A computed count, equal to 1 if the workspace is a currently unassigned prebuild. Use this to conditionally act on the status of a prebuild. Actions that do not require user identity can be taken when this value is set to 1. Actions that should only be taken once the workspace has been assigned to a user may be taken when this value is set to 0.",
9898
},
9999
"start_count": {
100100
Type: schema.TypeInt,
@@ -114,7 +114,7 @@ func workspaceDataSource() *schema.Resource {
114114
"is_prebuild": {
115115
Type: schema.TypeBool,
116116
Computed: true,
117-
Description: "Whether the workspace is a prebuild.",
117+
Description: "Similar to `prebuild_count`, but a boolean value instead of a count. This is set to true if the workspace is a currently unassigned prebuild. Once the workspace is assigned, this value will be false.",
118118
},
119119
"name": {
120120
Type: schema.TypeString,

provider/workspace_preset.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func workspacePresetDataSource() *schema.Resource {
2323
return &schema.Resource{
2424
SchemaVersion: 1,
2525

26-
Description: "Use this data source to predefine common configurations for workspaces.",
26+
Description: "Use this data source to predefine common configurations for coder workspaces. Users will have the option to select a defined preset, which will automatically apply the selected configuration. Any parameters defined in the preset will be applied to the workspace. Parameters that are not defined by the preset will still be configurable when creating a workspace.",
2727
ReadContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics {
2828
var preset WorkspacePreset
2929
err := mapstructure.Decode(struct {
@@ -52,18 +52,18 @@ func workspacePresetDataSource() *schema.Resource {
5252
Schema: map[string]*schema.Schema{
5353
"id": {
5454
Type: schema.TypeString,
55-
Description: "ID of the workspace preset.",
55+
Description: "The preset ID is automatically generated and may change between runs. It is recommended to use the `name` attribute to identify the preset.",
5656
Computed: true,
5757
},
5858
"name": {
5959
Type: schema.TypeString,
60-
Description: "Name of the workspace preset.",
60+
Description: "The name of the workspace preset.",
6161
Required: true,
6262
ValidateFunc: validation.StringIsNotEmpty,
6363
},
6464
"parameters": {
6565
Type: schema.TypeMap,
66-
Description: "Parameters of the workspace preset.",
66+
Description: "Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.",
6767
Optional: true,
6868
Elem: &schema.Schema{
6969
Type: schema.TypeString,
@@ -73,13 +73,14 @@ func workspacePresetDataSource() *schema.Resource {
7373
},
7474
"prebuilds": {
7575
Type: schema.TypeSet,
76-
Description: "Prebuilds of the workspace preset.",
76+
Description: "Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.",
7777
Optional: true,
7878
MaxItems: 1,
7979
Elem: &schema.Resource{
8080
Schema: map[string]*schema.Schema{
8181
"instances": {
8282
Type: schema.TypeInt,
83+
Description: "The number of workspaces to keep in reserve for this preset.",
8384
Required: true,
8485
ForceNew: true,
8586
ValidateFunc: validation.IntAtLeast(0),

0 commit comments

Comments
 (0)