feat: add GET /api/v2/templatebuilder/modules endpoint (#26117)

Implement `GET /api/v2/templatebuilder/modules`, which returns the
filtered list of modules available for a given base template. Reads from
the bundled catalog via `LoadModules()` and applies OS-compatibility
filtering based on the `base` query param.

Computed variables (e.g. `agent_id`) are excluded from the API response
at the `ToSDK()` conversion boundary since they are wired automatically
by the builder. The `Computed` field is removed from the SDK type. Adds
`CompatibleWithOS()` to `ModuleManifest` for OS filtering.

Returns 400 for unknown base IDs and 404 when the template builder is
disabled.

Depends on #26116

> [!NOTE]
> This PR was authored by Coder Agents on behalf of @jeremyruppel.
This commit is contained in:
Jeremy Ruppel
2026-06-12 17:53:48 -04:00
committed by GitHub
parent 776fbfa748
commit 9a6e348f5d
11 changed files with 664 additions and 17 deletions
+126
View File
@@ -12106,6 +12106,132 @@ Restarts will only happen on weekdays in this list on weeks which line up with W
| `disabled` | boolean | false | | |
| `registry_url` | string | false | | |
## codersdk.TemplateBuilderModule
```json
{
"category": "string",
"compatible_os": [
"string"
],
"conflicts_with": [
"string"
],
"description": "string",
"display_name": "string",
"icon": "string",
"id": "string",
"variables": [
{
"default": [
0
],
"description": "string",
"name": "string",
"required": true,
"sensitive": true,
"type": "string"
}
],
"version": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|------------------|-------------------------------------------------------------------------------------------|----------|--------------|-------------|
| `category` | string | false | | |
| `compatible_os` | array of string | false | | |
| `conflicts_with` | array of string | false | | |
| `description` | string | false | | |
| `display_name` | string | false | | |
| `icon` | string | false | | |
| `id` | string | false | | |
| `variables` | array of [codersdk.TemplateBuilderModuleVariable](#codersdktemplatebuildermodulevariable) | false | | |
| `version` | string | false | | |
## codersdk.TemplateBuilderModuleVariable
```json
{
"default": [
0
],
"description": "string",
"name": "string",
"required": true,
"sensitive": true,
"type": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|---------------|------------------------------------------------------------------------------|----------|--------------|-------------|
| `default` | array of integer | false | | |
| `description` | string | false | | |
| `name` | string | false | | |
| `required` | boolean | false | | |
| `sensitive` | boolean | false | | |
| `type` | [codersdk.TemplateBuilderVariableType](#codersdktemplatebuildervariabletype) | false | | |
## codersdk.TemplateBuilderModulesResponse
```json
{
"modules": [
{
"category": "string",
"compatible_os": [
"string"
],
"conflicts_with": [
"string"
],
"description": "string",
"display_name": "string",
"icon": "string",
"id": "string",
"variables": [
{
"default": [
0
],
"description": "string",
"name": "string",
"required": true,
"sensitive": true,
"type": "string"
}
],
"version": "string"
}
]
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|-----------|---------------------------------------------------------------------------|----------|--------------|-------------|
| `modules` | array of [codersdk.TemplateBuilderModule](#codersdktemplatebuildermodule) | false | | |
## codersdk.TemplateBuilderVariableType
```json
"string"
```
### Properties
#### Enumerated Values
| Value(s) |
|----------------------------|
| `bool`, `number`, `string` |
## codersdk.TemplateExample
```json
+64
View File
@@ -38,3 +38,67 @@ curl -X GET http://coder-server:8080/api/v2/templatebuilder/bases \
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.TemplateBuilderBasesResponse](schemas.md#codersdktemplatebuilderbasesresponse) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## List template builder modules
### Code samples
```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/templatebuilder/modules \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`GET /api/v2/templatebuilder/modules`
### Parameters
| Name | In | Type | Required | Description |
|--------|-------|--------|----------|---------------------------------------------------------|
| `base` | query | string | false | Base template example ID for OS-compatibility filtering |
### Example responses
> 200 Response
```json
{
"modules": [
{
"category": "string",
"compatible_os": [
"string"
],
"conflicts_with": [
"string"
],
"description": "string",
"display_name": "string",
"icon": "string",
"id": "string",
"variables": [
{
"default": [
0
],
"description": "string",
"name": "string",
"required": true,
"sensitive": true,
"type": "string"
}
],
"version": "string"
}
]
}
```
### Responses
| Status | Meaning | Description | Schema |
|--------|---------------------------------------------------------|-------------|----------------------------------------------------------------------------------------------|
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.TemplateBuilderModulesResponse](schemas.md#codersdktemplatebuildermodulesresponse) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).