-
Notifications
You must be signed in to change notification settings - Fork 979
docs: describe workspace tags #13352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
caa6ee7
1042d5b
f3016fb
0c6c844
7443d42
716d01e
b43d8a1
883a17d
cfd0c23
12a292c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
--- | ||
name: Sample Template with Workspace Tags | ||
description: Review the sample template and introduce workspace tags to your template | ||
description: Review the sample template and introduce dynamic workspace tags to your template | ||
tags: [local, docker, workspace-tags] | ||
icon: /icon/docker.png | ||
--- | ||
|
||
# Overview | ||
|
||
This Coder template presents use of [Workspace Tags](https://coder.com/docs/v2/latest/templates/workspace-tags) [Coder Parameters](https://coder.com/docs/v2/latest/templates/parameters). | ||
|
||
# Use case | ||
|
||
Template administrators can use static tags to control workspace provisioning, limiting it to specific provisioner groups. However, this restricts workspace users from choosing their preferred workspace nodes. | ||
|
||
By using `coder_workspace_tags` and `coder_parameter`s, template administrators can allow dynamic tag selection, avoiding the need to push the same template multiple times with different tags. | ||
|
||
## Development | ||
|
||
Update the template and push it using the following command: | ||
|
||
``` | ||
./scripts/coder-dev.sh templates push examples-workspace-tags \ | ||
-d examples/workspace-tags \ | ||
--create \ | ||
-y | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,63 @@ terraform { | |
} | ||
} | ||
|
||
locals { | ||
username = data.coder_workspace.me.owner | ||
} | ||
|
||
data "coder_provisioner" "me" { | ||
} | ||
|
||
data "coder_workspace" "me" { | ||
} | ||
|
||
data "coder_workspace_tags" "custom_workspace_tags" { | ||
tags = { | ||
"zone" = "developers" | ||
"os" = data.coder_parameter.os_selector.value | ||
"project_id" = "PROJECT_${data.coder_parameter.project_name.value}" | ||
"cache" = data.coder_parameter.feature_cache_enabled.value == "true" ? "with-cache" : "no-cache" | ||
} | ||
} | ||
|
||
data "coder_parameter" "os_selector" { | ||
name = "os_selector" | ||
display_name = "OS runtime" | ||
default = "linux" | ||
|
||
option { | ||
name = "Linux" | ||
value = "linux" | ||
} | ||
option { | ||
name = "OSX" | ||
value = "osx" | ||
} | ||
option { | ||
name = "Windows" | ||
value = "windows" | ||
} | ||
|
||
mutable = false | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain if As this will also be published as an official example on https://registry.coder.com/templates, we should try to make the tags as practical as possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove the example altogether, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed the BTW I can modify it to depend on "foobars" too. My intention was to indicate the syntax rather providing use cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is better. But my opinion is that we should remove the example altogether if it is not usable out of the box. The docs are written well enough to serve the users who actually need to use this feature. |
||
|
||
data "coder_parameter" "project_name" { | ||
name = "project_name" | ||
display_name = "Project name" | ||
description = "Specify the project name." | ||
|
||
mutable = false | ||
} | ||
|
||
data "coder_parameter" "feature_cache_enabled" { | ||
name = "feature_cache_enabled" | ||
display_name = "Enable cache?" | ||
type = "bool" | ||
default = false | ||
|
||
mutable = false | ||
} | ||
|
||
resource "coder_agent" "main" { | ||
arch = data.coder_provisioner.me.arch | ||
os = "linux" | ||
|
Uh oh!
There was an error while loading. Please reload this page.