feat: add TemplateBuilderCreateTemplate SDK types and client method - #26360
Merged
jeremyruppel merged 9 commits intoJun 15, 2026
Merged
Conversation
Docs preview📖 View docs preview for |
This was referenced Jun 12, 2026
Contributor
Author
This was referenced Jun 12, 2026
jeremyruppel
force-pushed
the
jeremy/devex-278-be-input-validation-sanitization
branch
from
June 15, 2026 13:02
5018709 to
3cd22c6
Compare
jeremyruppel
force-pushed
the
jeremy/devex-279-be-post-apiv2templatebuildercompose-validation-template
branch
2 times, most recently
from
June 15, 2026 13:21
7385ad6 to
a47b263
Compare
jeremyruppel
force-pushed
the
jeremy/devex-278-be-input-validation-sanitization
branch
2 times, most recently
from
June 15, 2026 13:30
58852e9 to
9b66c67
Compare
jeremyruppel
force-pushed
the
jeremy/devex-279-be-post-apiv2templatebuildercompose-validation-template
branch
2 times, most recently
from
June 15, 2026 13:33
6237dee to
9c6139e
Compare
jeremyruppel
force-pushed
the
jeremy/devex-278-be-input-validation-sanitization
branch
from
June 15, 2026 13:33
9b66c67 to
374925a
Compare
jeremyruppel
marked this pull request as ready for review
June 15, 2026 13:38
jeremyruppel
force-pushed
the
jeremy/devex-278-be-input-validation-sanitization
branch
from
June 15, 2026 14:09
374925a to
f77d6bb
Compare
jeremyruppel
force-pushed
the
jeremy/devex-279-be-post-apiv2templatebuildercompose-validation-template
branch
2 times, most recently
from
June 15, 2026 15:10
9c90ded to
80cc7d6
Compare
jeremyruppel
force-pushed
the
jeremy/devex-278-be-input-validation-sanitization
branch
from
June 15, 2026 15:10
f77d6bb to
6c99fc7
Compare
Base automatically changed from
jeremy/devex-278-be-input-validation-sanitization
to
main
June 15, 2026 15:34
Add the compose endpoint that accepts a base template ID and optional modules with variable overrides, renders them into Terraform source files via Compose/BundleTar, and returns the tar archive directly. The handler reads the registry URL from the deployment config (CODER_TEMPLATE_BUILDER_REGISTRY_URL), validates the request, and returns the rendered tar with Content-Type: application/x-tar. Includes swagger annotations, route wiring, and integration tests covering happy path, error cases, and feature-disabled behavior.
The TestEndpointsDocumented test derives expected IDs from summaries. The @id 'compose-template-builder' did not match the kebab-cased summary 'Compose template from base and modules'.
…talog Reusable Go script that reads the Coder registry repo and generates module.json and .tf.tmpl files for the template builder catalog. Parses variable declarations from main.tf, frontmatter from README.md, and pinned versions from git tags. Usage: go run ./scripts/modulegen/ -registry /path/to/registry -output coderd/templatebuilder/modules Handles escaped quotes and heredoc descriptions, skips variables with heredoc defaults (cannot be represented in the builder UI), uses numeric semver sorting for version tags, and exits non-zero on failures.
…t method Add request/response types and client method for the new POST /api/v2/templatebuilder/compose/template endpoint that will compose a template and create it in a single request. The request embeds compose parameters (base_template_id, modules) alongside template creation parameters (organization_id, name, display_name, description, icon, provisioner_tags).
Add ClassifyProvisionerError to detect known terraform init failure modes (DNS resolution, connection refused, i/o timeout, TLS handshake timeout) and return actionable user-facing messages. Unknown errors pass through unchanged.
Add a synchronous endpoint that composes a template from a base and modules, validates it via a provisioner import job, and creates the template in a single request. The handler: composes terraform files, bundles them as a tar archive, inserts the file with hash-based dedup, creates a template version with an import job, waits for the job to complete (2-minute timeout), classifies any errors, then creates the template on success. The waitForProvisionerJob helper uses an exponential backoff poll loop with an onUpdate callback hook for future SSE streaming support. Route: POST /api/v2/templatebuilder/compose/template
Apply canonical HCL formatting to rendered MainTF and ModulesTF output using hclwrite.Format. This produces consistently formatted terraform files regardless of template indentation. The formatHCL helper returns input unchanged if it is empty.
jeremyruppel
force-pushed
the
jeremy/devex-279-be-post-apiv2templatebuildercompose-validation-template
branch
from
June 15, 2026 15:35
80cc7d6 to
c49798e
Compare
zenithwolf1000
approved these changes
Jun 15, 2026
jeremyruppel
deleted the
jeremy/devex-279-be-post-apiv2templatebuildercompose-validation-template
branch
June 15, 2026 22:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
POST /api/v2/templatebuilder/compose/template, a synchronous endpoint that composes a template from a base and modules, validates it via a provisioner import job, and creates the template in a single request.The handler composes terraform files, bundles them as a tar, inserts the file with hash-based dedup, creates a template version with an import job, waits up to 2 minutes for the job to complete, classifies errors for known failure modes (network-unreachable registry, DNS failures), then creates the template on success. Canceled and failed jobs return appropriate error responses.
Also adds
hclwrite.Formatto composed terraform output for canonical HCL formatting.Closes https://linear.app/codercom/issue/DEVEX-279
Implementation notes
codersdk/templatebuilder.gowith validation tags matching the standard template creation path (template_display_name,lt=128)ClassifyProvisionerErrorincoderd/templatebuilder/errors.godetects DNS, connection refused, i/o timeout, and TLS handshake failures and returns actionable messageswaitForProvisionerJobpolls with a ramp-up interval schedule (100ms, 200ms, 500ms, then 1s steady) and accepts anonUpdatecallback for future SSE streaming