feat: add POST /api/v2/templatebuilder/compose endpoint (#26351)

> [!NOTE]
> This PR was authored by Coder Agents on behalf of @jeremyruppel.

Part 4 of DEVEX-277 (POST /api/v2/templatebuilder/compose).

Adds the HTTP handler, route wiring, and integration tests for the
compose endpoint.

The handler accepts a JSON request with a base template ID and optional
modules with variable overrides, renders them via `Compose`/`BundleTar`,
and returns the tar archive directly with `Content-Type:
application/x-tar`. The registry URL comes from the deployment config
(`CODER_TEMPLATE_BUILDER_REGISTRY_URL`).

RBAC uses `policy.ActionCreate` on
`rbac.ResourceTemplate.AnyOrganization()`.

Integration tests cover: base-only compose, base with modules, unknown
base/module errors, missing base template ID, and feature-disabled 404.
This commit is contained in:
Jeremy Ruppel
2026-06-15 11:07:16 -04:00
committed by GitHub
parent c50cef5ae1
commit b61b62f4b3
8 changed files with 438 additions and 1 deletions
+44
View File
@@ -12090,6 +12090,50 @@ Restarts will only happen on weekdays in this list on weeks which line up with W
|---------|-----------------------------------------------------------------------|----------|--------------|-------------|
| `bases` | array of [codersdk.TemplateBuilderBase](#codersdktemplatebuilderbase) | false | | |
## codersdk.TemplateBuilderComposeModule
```json
{
"id": "string",
"variables": {
"property1": "string",
"property2": "string"
}
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|--------------------|--------|----------|--------------|-------------|
| `id` | string | false | | |
| `variables` | object | false | | |
| » `[any property]` | string | false | | |
## codersdk.TemplateBuilderComposeRequest
```json
{
"base_template_id": "string",
"modules": [
{
"id": "string",
"variables": {
"property1": "string",
"property2": "string"
}
}
]
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|--------------------|-----------------------------------------------------------------------------------------|----------|--------------|-------------|
| `base_template_id` | string | false | | |
| `modules` | array of [codersdk.TemplateBuilderComposeModule](#codersdktemplatebuildercomposemodule) | false | | |
## codersdk.TemplateBuilderConfig
```json
+44
View File
@@ -39,6 +39,50 @@ curl -X GET http://coder-server:8080/api/v2/templatebuilder/bases \
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Compose template from base and modules
### Code samples
```shell
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/templatebuilder/compose \
-H 'Content-Type: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`POST /api/v2/templatebuilder/compose`
> Body parameter
```json
{
"base_template_id": "string",
"modules": [
{
"id": "string",
"variables": {
"property1": "string",
"property2": "string"
}
}
]
}
```
### Parameters
| Name | In | Type | Required | Description |
|--------|------|--------------------------------------------------------------------------------------------|----------|-----------------|
| `body` | body | [codersdk.TemplateBuilderComposeRequest](schemas.md#codersdktemplatebuildercomposerequest) | true | Compose request |
### Responses
| Status | Meaning | Description | Schema |
|--------|---------------------------------------------------------|-------------|--------|
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## List template builder modules
### Code samples