From 00814b0a5fc5de938027626db5367cf4eb772323 Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Thu, 1 May 2025 20:53:31 +0000 Subject: [PATCH 01/14] add dynamic params --- .../extending-templates/parameters.md | 522 ++++++++++++++++++ 1 file changed, 522 insertions(+) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 676b79d72c36f..4d4b9aa918f2d 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -391,3 +391,525 @@ With the feature enabled: 2. Coder will populate recently used parameter key-value pairs for the user. This feature helps reduce repetition when filling common parameters such as `dotfiles_url` or `region`. + +## Dynamic Parameters + +Dynamic Parameters enhances Coder's existing parameter system with real-time validation, +conditional parameter behavior, and richer input types. +This feature allows template authors to create more interactive and responsive workspace creation experiences. + +### Enable Dynamic Parameters + +
+ +To use Dynamic Parameters, enable the experiment flag or set the environment variable: + +## Flag + +```shell +coder server --experiments=dynamic-parameters +``` + +## Env Variable + +```shell +CODER_EXPERIMENTS=dynamic-parameters +``` + +
+ +Once enabled, users can toggle between the experimental and classic interfaces during +workspace creation. + +### Features and Capabilities + +Dynamic Parameters introduces three primary enhancements to the standard parameter system: + +- **Conditional Parameters** + + - Parameters can respond to changes in other parameters + - Show or hide parameters based on other selections + - Modify validation rules conditionally + - Create branching paths in workspace creation forms + +- **Dynamic Data Fetching** + + - Fetch data at workspace creation time + - Access Coder user attributes (groups, username, auth) + - Selectively expose options based on user properties + - Connect to external resources + +- **Rich Parameter Entry** + + - Searchable dropdown lists for easier selection + - Multi-select options for choosing multiple items + - Secret text inputs for sensitive information + - Key-value pair inputs for complex data + - Button parameters for toggling sections + +### Available Form Types + +Dynamic Parameters supports a variety of form types to create rich, interactive user experiences: + +
**dropdown**: A searchable select menu for choosing a single option from a list + +```tf +data "coder_parameter" "region" { + name = "region" + display_name = "Region" + description = "Select a region" + type = "string" + form_type = "dropdown" # This is the default for string parameters with options + + option { + name = "US East" + value = "us-east-1" + } + option { + name = "US West" + value = "us-west-2" + } +} +``` + +
+ +
**radio**: Radio buttons for selecting a single option with high visibility + +```tf +data "coder_parameter" "environment" { + name = "environment" + display_name = "Environment" + type = "string" + form_type = "radio" + default = "dev" + + option { + name = "Development" + value = "dev" + } + option { + name = "Staging" + value = "staging" + } +} +``` + +
+ +
**multi-select**: Checkboxes for selecting multiple options from a list + +```tf +data "coder_parameter" "tools" { + name = "tools" + display_name = "Developer Tools" + type = "list(string)" + form_type = "multi-select" + default = jsonencode(["git", "docker"]) + + option { + name = "Git" + value = "git" + } + option { + name = "Docker" + value = "docker" + } + option { + name = "Kubernetes CLI" + value = "kubectl" + } +} +``` + +
+ +
**checkbox**: A single checkbox for boolean values + +```tf +data "coder_parameter" "enable_gpu" { + name = "enable_gpu" + display_name = "Enable GPU" + type = "bool" + form_type = "checkbox" # This is the default for boolean parameters + default = false +} +``` + +
+ +
**switch**: A toggle switch for boolean values + +```tf +data "coder_parameter" "advanced_mode" { + name = "advanced_mode" + display_name = "Advanced Mode" + type = "bool" + form_type = "switch" + default = false +} +``` + +
+ +
**slider**: A slider for selecting numeric values within a range + +```tf +data "coder_parameter" "cpu_cores" { + name = "cpu_cores" + display_name = "CPU Cores" + type = "number" + form_type = "slider" + default = 2 + validation { + min = 1 + max = 8 + } +} +``` + +
+ +
**input**: A standard text input field + +```tf +data "coder_parameter" "custom_domain" { + name = "custom_domain" + display_name = "Custom Domain" + type = "string" + form_type = "input" # This is the default for string parameters without options + default = "" +} +``` + +
+ +
**textarea**: A multi-line text input field for longer content + +```tf +data "coder_parameter" "init_script" { + name = "init_script" + display_name = "Initialization Script" + type = "string" + form_type = "textarea" + default = "#!/bin/bash\necho 'Hello World'" +} +``` + +
+ +
**password**: A text input that masks sensitive information + +```tf +data "coder_parameter" "api_key" { + name = "api_key" + display_name = "API Key" + type = "string" + form_type = "password" + secret = true +} +``` + +
+ +
**key-value**: Input for entering key-value pairs + +```tf +data "coder_parameter" "environment_vars" { + name = "environment_vars" + display_name = "Environment Variables" + type = "string" + form_type = "key-value" + default = jsonencode({"NODE_ENV": "development"}) +} +``` + +
+ +### Examples + +
Conditional Parameters: Region and Instance Types + +This example shows instance types based on the selected region: + +```tf +data "coder_parameter" "region" { + name = "region" + display_name = "Region" + description = "Select a region for your workspace" + type = "string" + default = "us-east-1" + + option { + name = "US East (N. Virginia)" + value = "us-east-1" + } + + option { + name = "US West (Oregon)" + value = "us-west-2" + } +} + +data "coder_parameter" "instance_type" { + name = "instance_type" + display_name = "Instance Type" + description = "Select an instance type available in the selected region" + type = "string" + + # This option will only appear when us-east-1 is selected + dynamic "option" { + for_each = data.coder_parameter.region.value == "us-east-1" ? [1] : [] + content { + name = "t3.large (US East)" + value = "t3.large" + } + } + + # This option will only appear when us-west-2 is selected + dynamic "option" { + for_each = data.coder_parameter.region.value == "us-west-2" ? [1] : [] + content { + name = "t3.medium (US West)" + value = "t3.medium" + } + } +} +``` + +
+ +
Advanced Options Toggle + +This example shows how to create an advanced options section: + +```tf +data "coder_parameter" "show_advanced" { + name = "show_advanced" + display_name = "Show Advanced Options" + description = "Enable to show advanced configuration options" + type = "bool" + default = false +} + +data "coder_parameter" "advanced_setting" { + name = "advanced_setting" + display_name = "Advanced Setting" + description = "An advanced configuration option" + type = "string" + default = "default_value" + mutable = true + + # This parameter is only visible when show_advanced is true + condition { + field = data.coder_parameter.show_advanced.name + value = "true" + } +} +``` + +
+ +
Multi-select IDE Options + +This example allows selecting multiple IDEs to install: + +```tf +data "coder_parameter" "ides" { + name = "ides" + display_name = "IDEs to Install" + description = "Select which IDEs to install in your workspace" + type = "list(string)" + default = jsonencode(["vscode"]) + mutable = true + form_type = "multi-select" + + option { + name = "VS Code" + value = "vscode" + icon = "/icon/vscode.png" + } + + option { + name = "JetBrains IntelliJ" + value = "intellij" + icon = "/icon/intellij.png" + } + + option { + name = "JupyterLab" + value = "jupyter" + icon = "/icon/jupyter.png" + } +} +``` + +
+ +
Team-specific Resources + +This example filters resources based on user group membership: + +```tf +data "coder_parameter" "instance_type" { + name = "instance_type" + display_name = "Instance Type" + description = "Select an instance type for your workspace" + type = "string" + + # Show GPU options only if user belongs to the "data-science" group + dynamic "option" { + for_each = contains(data.coder_workspace_owner.me.groups, "data-science") ? [1] : [] + content { + name = "p3.2xlarge (GPU)" + value = "p3.2xlarge" + } + } + + # Standard options for all users + option { + name = "t3.medium (Standard)" + value = "t3.medium" + } +} +``` + +### Advanced Usage Patterns + +
Creating Branching Paths + +For templates serving multiple teams or use cases, you can create comprehensive branching paths: + +```tf +data "coder_parameter" "environment_type" { + name = "environment_type" + display_name = "Environment Type" + description = "Select your preferred development environment" + type = "string" + default = "container" + + option { + name = "Container" + value = "container" + } + + option { + name = "Virtual Machine" + value = "vm" + } +} + +# Container-specific parameters +data "coder_parameter" "container_image" { + name = "container_image" + display_name = "Container Image" + description = "Select a container image for your environment" + type = "string" + default = "ubuntu:latest" + + # Only show when container environment is selected + condition { + field = data.coder_parameter.environment_type.name + value = "container" + } + + option { + name = "Ubuntu" + value = "ubuntu:latest" + } + + option { + name = "Python" + value = "python:3.9" + } +} + +# VM-specific parameters +data "coder_parameter" "vm_image" { + name = "vm_image" + display_name = "VM Image" + description = "Select a VM image for your environment" + type = "string" + default = "ubuntu-20.04" + + # Only show when VM environment is selected + condition { + field = data.coder_parameter.environment_type.name + value = "vm" + } + + option { + name = "Ubuntu 20.04" + value = "ubuntu-20.04" + } + + option { + name = "Debian 11" + value = "debian-11" + } +} +``` + +
+ +
Conditional Validation + +Adjust validation rules dynamically based on parameter values: + +```tf +data "coder_parameter" "team" { + name = "team" + display_name = "Team" + type = "string" + default = "engineering" + + option { + name = "Engineering" + value = "engineering" + } + + option { + name = "Data Science" + value = "data-science" + } +} + +data "coder_parameter" "cpu_count" { + name = "cpu_count" + display_name = "CPU Count" + type = "number" + default = 2 + + # Engineering team has lower limits + dynamic "validation" { + for_each = data.coder_parameter.team.value == "engineering" ? [1] : [] + content { + min = 1 + max = 4 + } + } + + # Data Science team has higher limits + dynamic "validation" { + for_each = data.coder_parameter.team.value == "data-science" ? [1] : [] + content { + min = 2 + max = 8 + } + } +} +``` + +
+ +### API Details + +Dynamic Parameters uses WebSocket communication to provide real-time updates. + +The WebSocket endpoint is: + +```api +GET /users/{user}/templateversions/{templateversion}/parameters +``` + +The WebSocket connection sends parameter changes as they occur and receives updated parameter state and validation errors in response. From e7c2bd88fa3468ec577e34b333b2e41aff652a8c Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Thu, 1 May 2025 20:57:17 +0000 Subject: [PATCH 02/14] tab heading level --- docs/admin/templates/extending-templates/parameters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 4d4b9aa918f2d..31e97f17b1d02 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -404,13 +404,13 @@ This feature allows template authors to create more interactive and responsive w To use Dynamic Parameters, enable the experiment flag or set the environment variable: -## Flag +#### Flag ```shell coder server --experiments=dynamic-parameters ``` -## Env Variable +#### Env Variable ```shell CODER_EXPERIMENTS=dynamic-parameters From 455e703e11dec69ed5bcb78dd286a932bf6347b1 Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Thu, 15 May 2025 20:49:57 +0000 Subject: [PATCH 03/14] adjust descriptions and heading levels --- .../extending-templates/parameters.md | 157 ++++++++++-------- 1 file changed, 89 insertions(+), 68 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 04ead578cdb55..b53b33d810536 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -421,7 +421,7 @@ CODER_EXPERIMENTS=dynamic-parameters Once enabled, users can toggle between the experimental and classic interfaces during workspace creation. -### Features and Capabilities +## Features and Capabilities Dynamic Parameters introduces three primary enhancements to the standard parameter system: @@ -447,9 +447,44 @@ Dynamic Parameters introduces three primary enhancements to the standard paramet - Key-value pair inputs for complex data - Button parameters for toggling sections -### Available Form Types +## Available Form Types -Dynamic Parameters supports a variety of form types to create rich, interactive user experiences: +Dynamic Parameters supports a variety of form types to create rich, interactive user experiences. + +You can specify the form type using the `form_type` property. +Different parameter types support different form types. + +The "Options" column in the table below indicates whether the form type requires options to be defined (Yes) or doesn't support/require them (No). When required, options are specified using one or more `option` blocks in your parameter definition, where each option has a `name` (displayed to the user) and a `value` (used in your template logic). + +| Form Type | Parameter Types | Options | Notes | +|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------| +| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | +| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | +| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | +| `key-value` | `string` | No | For entering key-value pairs (as JSON). | +| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | +| `password` | `string` | No | Masked input field for sensitive information. | +| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | +| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | +| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | +| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | +| `textarea` | `string` | No | Multi-line text input field for longer content. | + +### Form Type Examples + +
**checkbox**: A single checkbox for boolean values + +```tf +data "coder_parameter" "enable_gpu" { + name = "enable_gpu" + display_name = "Enable GPU" + type = "bool" + form_type = "checkbox" # This is the default for boolean parameters + default = false +} +``` + +
**dropdown**: A searchable select menu for choosing a single option from a list @@ -474,24 +509,29 @@ data "coder_parameter" "region" {
-
**radio**: Radio buttons for selecting a single option with high visibility +
**input**: A standard text input field ```tf -data "coder_parameter" "environment" { - name = "environment" - display_name = "Environment" +data "coder_parameter" "custom_domain" { + name = "custom_domain" + display_name = "Custom Domain" type = "string" - form_type = "radio" - default = "dev" + form_type = "input" # This is the default for string parameters without options + default = "" +} +``` - option { - name = "Development" - value = "dev" - } - option { - name = "Staging" - value = "staging" - } +
+ +
**key-value**: Input for entering key-value pairs + +```tf +data "coder_parameter" "environment_vars" { + name = "environment_vars" + display_name = "Environment Variables" + type = "string" + form_type = "key-value" + default = jsonencode({"NODE_ENV": "development"}) } ``` @@ -524,29 +564,38 @@ data "coder_parameter" "tools" {
-
**checkbox**: A single checkbox for boolean values +
**password**: A text input that masks sensitive information ```tf -data "coder_parameter" "enable_gpu" { - name = "enable_gpu" - display_name = "Enable GPU" - type = "bool" - form_type = "checkbox" # This is the default for boolean parameters - default = false +data "coder_parameter" "api_key" { + name = "api_key" + display_name = "API Key" + type = "string" + form_type = "password" + secret = true } ```
-
**switch**: A toggle switch for boolean values +
**radio**: Radio buttons for selecting a single option with high visibility ```tf -data "coder_parameter" "advanced_mode" { - name = "advanced_mode" - display_name = "Advanced Mode" - type = "bool" - form_type = "switch" - default = false +data "coder_parameter" "environment" { + name = "environment" + display_name = "Environment" + type = "string" + form_type = "radio" + default = "dev" + + option { + name = "Development" + value = "dev" + } + option { + name = "Staging" + value = "staging" + } } ``` @@ -570,15 +619,15 @@ data "coder_parameter" "cpu_cores" {
-
**input**: A standard text input field +
**switch**: A toggle switch for boolean values ```tf -data "coder_parameter" "custom_domain" { - name = "custom_domain" - display_name = "Custom Domain" - type = "string" - form_type = "input" # This is the default for string parameters without options - default = "" +data "coder_parameter" "advanced_mode" { + name = "advanced_mode" + display_name = "Advanced Mode" + type = "bool" + form_type = "switch" + default = false } ``` @@ -598,35 +647,7 @@ data "coder_parameter" "init_script" {
-
**password**: A text input that masks sensitive information - -```tf -data "coder_parameter" "api_key" { - name = "api_key" - display_name = "API Key" - type = "string" - form_type = "password" - secret = true -} -``` - -
- -
**key-value**: Input for entering key-value pairs - -```tf -data "coder_parameter" "environment_vars" { - name = "environment_vars" - display_name = "Environment Variables" - type = "string" - form_type = "key-value" - default = jsonencode({"NODE_ENV": "development"}) -} -``` - -
- -### Examples +## Dynamic Parameter Use Case Examples
Conditional Parameters: Region and Instance Types @@ -902,7 +923,7 @@ data "coder_parameter" "cpu_count" {
-### API Details +## API Details Dynamic Parameters uses WebSocket communication to provide real-time updates. From 03c91dfb14ef4959c50abe5426350595d4544238 Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Thu, 15 May 2025 21:19:16 +0000 Subject: [PATCH 04/14] make --- docs/admin/templates/extending-templates/parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index b53b33d810536..ed8c61f561f9a 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -458,7 +458,7 @@ The "Options" column in the table below indicates whether the form type requires | Form Type | Parameter Types | Options | Notes | |----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------| -| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | +| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | | `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | | `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | | `key-value` | `string` | No | For entering key-value pairs (as JSON). | From 1b8525d7b402e76b43f8f6dd5a1b4159f7ffa735 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Fri, 16 May 2025 09:58:41 -0500 Subject: [PATCH 05/14] Update docs/admin/templates/extending-templates/parameters.md --- .../admin/templates/extending-templates/parameters.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index ed8c61f561f9a..2a8012ea280b8 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -711,23 +711,20 @@ data "coder_parameter" "show_advanced" { description = "Enable to show advanced configuration options" type = "bool" default = false + order = 0 } data "coder_parameter" "advanced_setting" { + # This parameter is only visible when show_advanced is true + count = data.coder_parameter.show_advanced.value ? 1 : 0 name = "advanced_setting" display_name = "Advanced Setting" description = "An advanced configuration option" type = "string" default = "default_value" mutable = true - - # This parameter is only visible when show_advanced is true - condition { - field = data.coder_parameter.show_advanced.name - value = "true" - } + order = 1 } -```
From b52ef338a02b3fcd380ee8e164ea1097812ee65c Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Fri, 16 May 2025 09:58:49 -0500 Subject: [PATCH 06/14] Update docs/admin/templates/extending-templates/parameters.md --- .../admin/templates/extending-templates/parameters.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 2a8012ea280b8..0684454b5dac4 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -920,14 +920,3 @@ data "coder_parameter" "cpu_count" {
-## API Details - -Dynamic Parameters uses WebSocket communication to provide real-time updates. - -The WebSocket endpoint is: - -```api -GET /users/{user}/templateversions/{templateversion}/parameters -``` - -The WebSocket connection sends parameter changes as they occur and receives updated parameter state and validation errors in response. From 0495e1ef0fd5a5f8f14d434ce3657a29da480d67 Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Fri, 16 May 2025 16:47:31 +0000 Subject: [PATCH 07/14] test expand in table --- .../extending-templates/parameters.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 0684454b5dac4..f8af8b559835e 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -456,19 +456,19 @@ Different parameter types support different form types. The "Options" column in the table below indicates whether the form type requires options to be defined (Yes) or doesn't support/require them (No). When required, options are specified using one or more `option` blocks in your parameter definition, where each option has a `name` (displayed to the user) and a `value` (used in your template logic). -| Form Type | Parameter Types | Options | Notes | -|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------| -| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | -| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | -| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | -| `key-value` | `string` | No | For entering key-value pairs (as JSON). | -| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | -| `password` | `string` | No | Masked input field for sensitive information. | -| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | -| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | -| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | -| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | -| `textarea` | `string` | No | Multi-line text input field for longer content. | +| Form Type | Parameter Types | Options | Notes | Example | +|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------| | +| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | | +| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | | +| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | | +| `key-value` | `string` | No | For entering key-value pairs (as JSON). | | +| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | | +| `password` | `string` | No | Masked input field for sensitive information. | | +| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | | +| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | | +| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | | +| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | | +| `textarea` | `string` | No | Multi-line text input field for longer content. | | ### Form Type Examples From daff7786dc9228369feb488a00129ef6e603b98f Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Fri, 16 May 2025 16:52:18 +0000 Subject: [PATCH 08/14] test expand in table --- .../extending-templates/parameters.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index f8af8b559835e..7892865c03f32 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -457,18 +457,18 @@ Different parameter types support different form types. The "Options" column in the table below indicates whether the form type requires options to be defined (Yes) or doesn't support/require them (No). When required, options are specified using one or more `option` blocks in your parameter definition, where each option has a `name` (displayed to the user) and a `value` (used in your template logic). | Form Type | Parameter Types | Options | Notes | Example | -|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------| | -| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | | -| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | | -| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | | -| `key-value` | `string` | No | For entering key-value pairs (as JSON). | | -| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | | -| `password` | `string` | No | Masked input field for sensitive information. | | -| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | | -| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | | -| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | | -| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | | -| `textarea` | `string` | No | Multi-line text input field for longer content. | | +|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------|----|
checkbox ``` tf data "coder_parameter" "enable_gpu" { name = "enable_gpu" display_name = "Enable GPU" type = "bool" form_type = "checkbox" # This is the default for boolean parameters default = false } ``` | +| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | placeholder | +| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | placeholder | +| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | placeholder | +| `key-value` | `string` | No | For entering key-value pairs (as JSON). | placeholder | +| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | placeholder | +| `password` | `string` | No | Masked input field for sensitive information. | placeholder | +| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | placeholder | +| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | placeholder | +| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | placeholder | +| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | placeholder | +| `textarea` | `string` | No | Multi-line text input field for longer content. | placeholder | ### Form Type Examples From 7c3e8259ee89f54d5ada7aa96c15da6e1b8c5c01 Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Fri, 16 May 2025 16:54:14 +0000 Subject: [PATCH 09/14] un-bold items in details --- .../extending-templates/parameters.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 7892865c03f32..54ab15f5a6768 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -472,7 +472,7 @@ The "Options" column in the table below indicates whether the form type requires ### Form Type Examples -
**checkbox**: A single checkbox for boolean values +
checkbox: A single checkbox for boolean values ```tf data "coder_parameter" "enable_gpu" { @@ -486,7 +486,7 @@ data "coder_parameter" "enable_gpu" {
-
**dropdown**: A searchable select menu for choosing a single option from a list +
dropdown: A searchable select menu for choosing a single option from a list ```tf data "coder_parameter" "region" { @@ -509,7 +509,7 @@ data "coder_parameter" "region" {
-
**input**: A standard text input field +
input: A standard text input field ```tf data "coder_parameter" "custom_domain" { @@ -523,7 +523,7 @@ data "coder_parameter" "custom_domain" {
-
**key-value**: Input for entering key-value pairs +
key-value: Input for entering key-value pairs ```tf data "coder_parameter" "environment_vars" { @@ -537,7 +537,7 @@ data "coder_parameter" "environment_vars" {
-
**multi-select**: Checkboxes for selecting multiple options from a list +
multi-select: Checkboxes for selecting multiple options from a list ```tf data "coder_parameter" "tools" { @@ -564,7 +564,7 @@ data "coder_parameter" "tools" {
-
**password**: A text input that masks sensitive information +
password: A text input that masks sensitive information ```tf data "coder_parameter" "api_key" { @@ -578,7 +578,7 @@ data "coder_parameter" "api_key" {
-
**radio**: Radio buttons for selecting a single option with high visibility +
radio: Radio buttons for selecting a single option with high visibility ```tf data "coder_parameter" "environment" { @@ -601,7 +601,7 @@ data "coder_parameter" "environment" {
-
**slider**: A slider for selecting numeric values within a range +
slider: A slider for selecting numeric values within a range ```tf data "coder_parameter" "cpu_cores" { @@ -619,7 +619,7 @@ data "coder_parameter" "cpu_cores" {
-
**switch**: A toggle switch for boolean values +
switch: A toggle switch for boolean values ```tf data "coder_parameter" "advanced_mode" { @@ -633,7 +633,7 @@ data "coder_parameter" "advanced_mode" {
-
**textarea**: A multi-line text input field for longer content +
textarea: A multi-line text input field for longer content ```tf data "coder_parameter" "init_script" { From 7119a3aa5074ba6d43e67e1fd0e3c78cc05dee47 Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Fri, 16 May 2025 16:56:10 +0000 Subject: [PATCH 10/14] fix test table md --- docs/admin/templates/extending-templates/parameters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 54ab15f5a6768..0a006ac400e90 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -457,8 +457,8 @@ Different parameter types support different form types. The "Options" column in the table below indicates whether the form type requires options to be defined (Yes) or doesn't support/require them (No). When required, options are specified using one or more `option` blocks in your parameter definition, where each option has a `name` (displayed to the user) and a `value` (used in your template logic). | Form Type | Parameter Types | Options | Notes | Example | -|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------|----|
checkbox ``` tf data "coder_parameter" "enable_gpu" { name = "enable_gpu" display_name = "Enable GPU" type = "bool" form_type = "checkbox" # This is the default for boolean parameters default = false } ``` | -| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. | placeholder | +|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------|---------| +| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. |
checkbox ``` tf data "coder_parameter" "enable_gpu" { name = "enable_gpu" display_name = "Enable GPU" type = "bool" form_type = "checkbox" # This is the default for boolean parameters default = false } ``` | | `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | placeholder | | `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | placeholder | | `key-value` | `string` | No | For entering key-value pairs (as JSON). | placeholder | From fa876a621ffc9a739a0b10f8bb605e984feab63d Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Fri, 16 May 2025 21:11:05 +0000 Subject: [PATCH 11/14] corrected dynamic paramters --- .../extending-templates/parameters.md | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 0a006ac400e90..262892b9ecae0 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -252,7 +252,7 @@ data "coder_parameter" "force_rebuild" { ## Validating parameters -Coder supports rich parameters with multiple validation modes: min, max, +Coder supports parameters with multiple validation modes: min, max, monotonic numbers, and regular expressions. ### Number @@ -400,9 +400,10 @@ This feature allows template authors to create more interactive and responsive w ### Enable Dynamic Parameters +To use Dynamic Parameters, enable the experiment flag or set the environment variable. Note that as of v.22.0, Dynamic parameters are an _unsafe_ experiment and will not be enabled by using the experiment wildcard. +
-To use Dynamic Parameters, enable the experiment flag or set the environment variable: #### Flag @@ -418,8 +419,22 @@ CODER_EXPERIMENTS=dynamic-parameters
+Dynamic Parameters also require version >=2.4.0 of the coder provider. Inject the following at the top of your template after enabling the experiment: + +```terraform +terraform { + required_providers { + coder = { + source = "coder/coder" + version = ">=2.4.0" + } + } +} +``` + + Once enabled, users can toggle between the experimental and classic interfaces during -workspace creation. +workspace creation using an escape hatch in the workspace creation form. ## Features and Capabilities @@ -432,12 +447,12 @@ Dynamic Parameters introduces three primary enhancements to the standard paramet - Modify validation rules conditionally - Create branching paths in workspace creation forms -- **Dynamic Data Fetching** +- **Reference User Properties** - - Fetch data at workspace creation time - - Access Coder user attributes (groups, username, auth) - - Selectively expose options based on user properties - - Connect to external resources + - Read user data at build time from [`coder_workspace_owner`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace_owner) + - Conditionally hide parameters based on user's role + - Change parameter options based on user groups + - Reference user name in parameters - **Rich Parameter Entry** From 1e0779761c92fa043723c3e0f977e768cb085fe7 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Fri, 16 May 2025 22:05:51 +0000 Subject: [PATCH 12/14] make fmt --- .../extending-templates/parameters.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 262892b9ecae0..73ec4781239f1 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -471,19 +471,19 @@ Different parameter types support different form types. The "Options" column in the table below indicates whether the form type requires options to be defined (Yes) or doesn't support/require them (No). When required, options are specified using one or more `option` blocks in your parameter definition, where each option has a `name` (displayed to the user) and a `value` (used in your template logic). -| Form Type | Parameter Types | Options | Notes | Example | -|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------|---------| +| Form Type | Parameter Types | Options | Notes | Example | +|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. |
checkbox ``` tf data "coder_parameter" "enable_gpu" { name = "enable_gpu" display_name = "Enable GPU" type = "bool" form_type = "checkbox" # This is the default for boolean parameters default = false } ``` | -| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | placeholder | -| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | placeholder | -| `key-value` | `string` | No | For entering key-value pairs (as JSON). | placeholder | -| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | placeholder | -| `password` | `string` | No | Masked input field for sensitive information. | placeholder | -| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | placeholder | -| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | placeholder | -| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | placeholder | -| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | placeholder | -| `textarea` | `string` | No | Multi-line text input field for longer content. | placeholder | +| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | placeholder | +| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | placeholder | +| `key-value` | `string` | No | For entering key-value pairs (as JSON). | placeholder | +| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | placeholder | +| `password` | `string` | No | Masked input field for sensitive information. | placeholder | +| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | placeholder | +| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | placeholder | +| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | placeholder | +| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | placeholder | +| `textarea` | `string` | No | Multi-line text input field for longer content. | placeholder | ### Form Type Examples From d944f2405bf1cbd14f09f8779245a1bd2975cb6c Mon Sep 17 00:00:00 2001 From: Edward Angert Date: Mon, 19 May 2025 17:00:12 -0400 Subject: [PATCH 13/14] Apply suggestions from code review Co-authored-by: Steven Masley --- docs/admin/templates/extending-templates/parameters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 73ec4781239f1..223c4c7974e0c 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -454,7 +454,7 @@ Dynamic Parameters introduces three primary enhancements to the standard paramet - Change parameter options based on user groups - Reference user name in parameters -- **Rich Parameter Entry** +- **Additional Form Inputs** - Searchable dropdown lists for easier selection - Multi-select options for choosing multiple items @@ -462,7 +462,7 @@ Dynamic Parameters introduces three primary enhancements to the standard paramet - Key-value pair inputs for complex data - Button parameters for toggling sections -## Available Form Types +## Available Form Input Types Dynamic Parameters supports a variety of form types to create rich, interactive user experiences. From bd613387805d143640f5de75d9110b3241ecebb7 Mon Sep 17 00:00:00 2001 From: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Date: Mon, 19 May 2025 21:19:18 +0000 Subject: [PATCH 14/14] examples out of table --- .../extending-templates/parameters.md | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/docs/admin/templates/extending-templates/parameters.md b/docs/admin/templates/extending-templates/parameters.md index 223c4c7974e0c..7f216bd3e64f9 100644 --- a/docs/admin/templates/extending-templates/parameters.md +++ b/docs/admin/templates/extending-templates/parameters.md @@ -398,12 +398,13 @@ Dynamic Parameters enhances Coder's existing parameter system with real-time val conditional parameter behavior, and richer input types. This feature allows template authors to create more interactive and responsive workspace creation experiences. -### Enable Dynamic Parameters +### Enable Dynamic Parameters (Early Access) -To use Dynamic Parameters, enable the experiment flag or set the environment variable. Note that as of v.22.0, Dynamic parameters are an _unsafe_ experiment and will not be enabled by using the experiment wildcard. +To use Dynamic Parameters, enable the experiment flag or set the environment variable. -
+Note that as of v2.22.0, Dynamic parameters are an unsafe experiment and will not be enabled with the experiment wildcard. +
#### Flag @@ -419,7 +420,9 @@ CODER_EXPERIMENTS=dynamic-parameters
-Dynamic Parameters also require version >=2.4.0 of the coder provider. Inject the following at the top of your template after enabling the experiment: +Dynamic Parameters also require version >=2.4.0 of the Coder provider. + +Enable the experiment, then include the following at the top of your template: ```terraform terraform { @@ -432,7 +435,6 @@ terraform { } ``` - Once enabled, users can toggle between the experimental and classic interfaces during workspace creation using an escape hatch in the workspace creation form. @@ -451,8 +453,8 @@ Dynamic Parameters introduces three primary enhancements to the standard paramet - Read user data at build time from [`coder_workspace_owner`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace_owner) - Conditionally hide parameters based on user's role - - Change parameter options based on user groups - - Reference user name in parameters + - Change parameter options based on user groups + - Reference user name in parameters - **Additional Form Inputs** @@ -471,23 +473,23 @@ Different parameter types support different form types. The "Options" column in the table below indicates whether the form type requires options to be defined (Yes) or doesn't support/require them (No). When required, options are specified using one or more `option` blocks in your parameter definition, where each option has a `name` (displayed to the user) and a `value` (used in your template logic). -| Form Type | Parameter Types | Options | Notes | Example | -|----------------|--------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `checkbox` | `bool` | No | A single checkbox for boolean parameters.
Default for boolean parameters. |
checkbox ``` tf data "coder_parameter" "enable_gpu" { name = "enable_gpu" display_name = "Enable GPU" type = "bool" form_type = "checkbox" # This is the default for boolean parameters default = false } ``` | -| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list.
Default for `string` or `number` parameters with options. | placeholder | -| `input` | `string`, `number` | No | Standard single-line text input field.
Default for string/number parameters without options. | placeholder | -| `key-value` | `string` | No | For entering key-value pairs (as JSON). | placeholder | -| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | placeholder | -| `password` | `string` | No | Masked input field for sensitive information. | placeholder | -| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | placeholder | -| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | placeholder | -| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | placeholder | -| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | placeholder | -| `textarea` | `string` | No | Multi-line text input field for longer content. | placeholder | +| Form Type | Parameter Types | Options | Notes | +|----------------|--------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------| +| `checkbox` | `bool` | No | A single checkbox for boolean parameters. Default for boolean parameters. | +| `dropdown` | `string`, `number` | Yes | Searchable dropdown list for choosing a single option from a list. Default for `string` or `number` parameters with options. | +| `input` | `string`, `number` | No | Standard single-line text input field. Default for string/number parameters without options. | +| `key-value` | `string` | No | For entering key-value pairs (as JSON). | +| `multi-select` | `list(string)` | Yes | Select multiple items from a list with checkboxes. | +| `password` | `string` | No | Masked input field for sensitive information. | +| `radio` | `string`, `number`, `bool`, `list(string)` | Yes | Radio buttons for selecting a single option with all choices visible at once. | +| `slider` | `number` | No | Slider selection with min/max validation for numeric values. | +| `switch` | `bool` | No | Toggle switch alternative for boolean parameters. | +| `tag-select` | `list(string)` | No | Default for list(string) parameters without options. | +| `textarea` | `string` | No | Multi-line text input field for longer content. | | ### Form Type Examples -
checkbox: A single checkbox for boolean values +
`checkbox`: A single checkbox for boolean values ```tf data "coder_parameter" "enable_gpu" { @@ -501,7 +503,7 @@ data "coder_parameter" "enable_gpu" {
-
dropdown: A searchable select menu for choosing a single option from a list +
`dropdown`: A searchable select menu for choosing a single option from a list ```tf data "coder_parameter" "region" { @@ -524,7 +526,7 @@ data "coder_parameter" "region" {
-
input: A standard text input field +
`input`: A standard text input field ```tf data "coder_parameter" "custom_domain" { @@ -538,7 +540,7 @@ data "coder_parameter" "custom_domain" {
-
key-value: Input for entering key-value pairs +
`key-value`: Input for entering key-value pairs ```tf data "coder_parameter" "environment_vars" { @@ -552,7 +554,7 @@ data "coder_parameter" "environment_vars" {
-
multi-select: Checkboxes for selecting multiple options from a list +
`multi-select`: Checkboxes for selecting multiple options from a list ```tf data "coder_parameter" "tools" { @@ -579,7 +581,7 @@ data "coder_parameter" "tools" {
-
password: A text input that masks sensitive information +
`password`: A text input that masks sensitive information ```tf data "coder_parameter" "api_key" { @@ -593,7 +595,7 @@ data "coder_parameter" "api_key" {
-
radio: Radio buttons for selecting a single option with high visibility +
`radio`: Radio buttons for selecting a single option with high visibility ```tf data "coder_parameter" "environment" { @@ -616,7 +618,7 @@ data "coder_parameter" "environment" {
-
slider: A slider for selecting numeric values within a range +
`slider`: A slider for selecting numeric values within a range ```tf data "coder_parameter" "cpu_cores" { @@ -634,7 +636,7 @@ data "coder_parameter" "cpu_cores" {
-
switch: A toggle switch for boolean values +
`switch`: A toggle switch for boolean values ```tf data "coder_parameter" "advanced_mode" { @@ -648,7 +650,7 @@ data "coder_parameter" "advanced_mode" {
-
textarea: A multi-line text input field for longer content +
`textarea`: A multi-line text input field for longer content ```tf data "coder_parameter" "init_script" { @@ -934,4 +936,3 @@ data "coder_parameter" "cpu_count" { ```
-