mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: add user-level parameter autofill (#11731)
This PR solves #10478 by auto-filling previously used template values in create and update workspace flows. I decided against explicit user values in settings for these reasons: * Autofill is far easier to implement * Users benefit from autofill _by default_ — we don't need to teach them new concepts * If we decide that autofill creates more harm than good, we can remove it without breaking compatibility
This commit is contained in:
67
docs/api/schemas.md
generated
67
docs/api/schemas.md
generated
@ -4213,31 +4213,32 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
| Value |
|
||||
| --------------------- |
|
||||
| `workspace` |
|
||||
| `workspace_proxy` |
|
||||
| `workspace_execution` |
|
||||
| `application_connect` |
|
||||
| `audit_log` |
|
||||
| `template` |
|
||||
| `group` |
|
||||
| `file` |
|
||||
| `provisioner_daemon` |
|
||||
| `organization` |
|
||||
| `assign_role` |
|
||||
| `assign_org_role` |
|
||||
| `api_key` |
|
||||
| `user` |
|
||||
| `user_data` |
|
||||
| `organization_member` |
|
||||
| `license` |
|
||||
| `deployment_config` |
|
||||
| `deployment_stats` |
|
||||
| `replicas` |
|
||||
| `debug_info` |
|
||||
| `system` |
|
||||
| `template_insights` |
|
||||
| Value |
|
||||
| --------------------------------- |
|
||||
| `workspace` |
|
||||
| `workspace_proxy` |
|
||||
| `workspace_execution` |
|
||||
| `application_connect` |
|
||||
| `audit_log` |
|
||||
| `template` |
|
||||
| `group` |
|
||||
| `file` |
|
||||
| `provisioner_daemon` |
|
||||
| `organization` |
|
||||
| `assign_role` |
|
||||
| `assign_org_role` |
|
||||
| `api_key` |
|
||||
| `user` |
|
||||
| `user_data` |
|
||||
| `user_workspace_build_parameters` |
|
||||
| `organization_member` |
|
||||
| `license` |
|
||||
| `deployment_config` |
|
||||
| `deployment_stats` |
|
||||
| `replicas` |
|
||||
| `debug_info` |
|
||||
| `system` |
|
||||
| `template_insights` |
|
||||
|
||||
## codersdk.RateLimitConfig
|
||||
|
||||
@ -5832,6 +5833,22 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
| ------------ | ---------------------------------------- | -------- | ------------ | ----------- |
|
||||
| `login_type` | [codersdk.LoginType](#codersdklogintype) | false | | |
|
||||
|
||||
## codersdk.UserParameter
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "string",
|
||||
"value": "string"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| ------- | ------ | -------- | ------------ | ----------- |
|
||||
| `name` | string | false | | |
|
||||
| `value` | string | false | | |
|
||||
|
||||
## codersdk.UserQuietHoursScheduleConfig
|
||||
|
||||
```json
|
||||
|
51
docs/api/users.md
generated
51
docs/api/users.md
generated
@ -513,6 +513,57 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/appearance \
|
||||
|
||||
To perform this operation, you must be authenticated. [Learn more](authentication.md).
|
||||
|
||||
## Get autofill build parameters for user
|
||||
|
||||
### Code samples
|
||||
|
||||
```shell
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/users/{user}/autofill-parameters?template_id=string \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /users/{user}/autofill-parameters`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | In | Type | Required | Description |
|
||||
| ------------- | ----- | ------ | -------- | ------------------------ |
|
||||
| `user` | path | string | true | User ID, username, or me |
|
||||
| `template_id` | query | string | true | Template ID |
|
||||
|
||||
### Example responses
|
||||
|
||||
> 200 Response
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"name": "string",
|
||||
"value": "string"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
| Status | Meaning | Description | Schema |
|
||||
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------- |
|
||||
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.UserParameter](schemas.md#codersdkuserparameter) |
|
||||
|
||||
<h3 id="get-autofill-build-parameters-for-user-responseschema">Response Schema</h3>
|
||||
|
||||
Status Code **200**
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| -------------- | ------ | -------- | ------------ | ----------- |
|
||||
| `[array item]` | array | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» value` | string | false | | |
|
||||
|
||||
To perform this operation, you must be authenticated. [Learn more](authentication.md).
|
||||
|
||||
## Get user Git SSH key
|
||||
|
||||
### Code samples
|
||||
|
@ -177,14 +177,14 @@
|
||||
"title": "Resource metadata",
|
||||
"description": "Show information in the workspace about template resources",
|
||||
"path": "./templates/resource-metadata.md"
|
||||
},
|
||||
{
|
||||
"title": "Parameters",
|
||||
"description": "Prompt the user for additional information about a workspace",
|
||||
"path": "./templates/parameters.md"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Parameters",
|
||||
"description": "Prompt the user for additional information about a workspace",
|
||||
"path": "./templates/parameters.md"
|
||||
},
|
||||
{
|
||||
"title": "Administering templates",
|
||||
"description": "Configuration settings for template admins",
|
||||
|
12
docs/templates/parameters.md
vendored
12
docs/templates/parameters.md
vendored
@ -281,3 +281,15 @@ variable "CLOUD_API_KEY" {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Create Autofill
|
||||
|
||||
When the template doesn't specify default values, Coder may still autofill
|
||||
parameters.
|
||||
|
||||
1. Coder will look for URL query parameters with form `param.<name>=<value>`.
|
||||
This feature enables platform teams to create pre-filled template creation
|
||||
links.
|
||||
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`.
|
||||
|
Reference in New Issue
Block a user