Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f0e699a

Browse files
committedApr 23, 2025·
lint and make gen
1 parent 0f5842a commit f0e699a

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed
 

‎docs/data-sources/workspace_preset.md

-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ data "coder_workspace_preset" "example" {
4141
- `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.
4242
- `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

44-
### Optional
45-
46-
- `prebuilds` (Block Set, Max: 1) Prebuilds of the workspace preset. (see [below for nested schema](#nestedblock--prebuilds))
47-
4844
### Read-Only
4945

5046
- `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.

‎provider/workspace.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func workspaceDataSource() *schema.Resource {
2727
}
2828
_ = rd.Set("start_count", count)
2929

30-
isPrebuild := isPrebuiltWorkspace(c)
30+
isPrebuild := isPrebuiltWorkspace()
3131
prebuildCount := 0
3232
if isPrebuild {
3333
prebuildCount = 1
@@ -140,16 +140,24 @@ func workspaceDataSource() *schema.Resource {
140140
}
141141
}
142142

143-
func isPrebuiltWorkspace(ctx context.Context) bool {
143+
// isPrebuiltWorkspace returns true if the workspace is an unclaimed prebuilt workspace.
144+
func isPrebuiltWorkspace() bool {
144145
return helpers.OptionalEnv(IsPrebuildEnvironmentVariable()) == "true"
145146
}
146147

147-
// IsPrebuildEnvironmentVariable returns the name of the environment
148-
// variable that indicates whether the workspace is an unclaimed prebuilt workspace.
149-
// The value of this environment variable should be set to "true" if the workspace
150-
// is prebuilt and it has not yet been claimed by a user.
151-
// Any other values, including "false" and "" will be interpreted to mean that the
152-
// workspace is not prebuilt, or was prebuilt but has since been claimed by a user.
148+
// IsPrebuildEnvironmentVariable returns the name of the environment variable that
149+
// indicates whether the workspace is an unclaimed prebuilt workspace.
150+
//
151+
// Knowing whether the workspace is an unclaimed prebuilt workspace allows template
152+
// authors to conditionally execute code in the template based on whether the workspace
153+
// has been assigned to a user or not. This allows identity specific configuration to
154+
// be applied only after the workspace is claimed, while the rest of the workspace can
155+
// be pre-configured.
156+
//
157+
// The value of this environment variable should be set to "true" if the workspace is prebuilt
158+
// and it has not yet been claimed by a user. Any other values, including "false"
159+
// and "" will be interpreted to mean that the workspace is not prebuilt, or was
160+
// prebuilt but has since been claimed by a user.
153161
func IsPrebuildEnvironmentVariable() string {
154162
return "CODER_WORKSPACE_IS_PREBUILD"
155163
}

0 commit comments

Comments
 (0)
Please sign in to comment.