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
+64
View File
@@ -7358,6 +7358,42 @@ const docTemplate = `{
]
}
},
"/api/v2/templatebuilder/compose": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/x-tar"
],
"tags": [
"TemplateBuilder"
],
"summary": "Compose template from base and modules",
"operationId": "compose-template-from-base-and-modules",
"parameters": [
{
"description": "Compose request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.TemplateBuilderComposeRequest"
}
}
],
"responses": {
"200": {
"description": "OK"
}
},
"security": [
{
"CoderSessionToken": []
}
]
}
},
"/api/v2/templatebuilder/modules": {
"get": {
"produces": [
@@ -23686,6 +23722,34 @@ const docTemplate = `{
}
}
},
"codersdk.TemplateBuilderComposeModule": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"variables": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
},
"codersdk.TemplateBuilderComposeRequest": {
"type": "object",
"properties": {
"base_template_id": {
"type": "string"
},
"modules": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.TemplateBuilderComposeModule"
}
}
}
},
"codersdk.TemplateBuilderConfig": {
"type": "object",
"properties": {