🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

feat(coderd/templatebuilder): add Compose and BundleTar functions - #26349

Merged
jeremyruppel merged 6 commits into
mainfrom
jeremy/devex-277-phase2-compose
Jun 15, 2026
Merged

feat(coderd/templatebuilder): add Compose and BundleTar functions#26349
jeremyruppel merged 6 commits into
mainfrom
jeremy/devex-277-phase2-compose

Conversation

@jeremyruppel

Copy link
Copy Markdown
Contributor

Note

This PR was authored by Coder Agents on behalf of @jeremyruppel.

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

Adds the core composition and bundling logic for the template builder.

Compose renders a base template and selected modules into Terraform source files. It validates modules before rendering (rejects duplicates, ConflictsWith violations, unknown IDs, OS incompatibility), then for each module merges manifest defaults with caller-supplied variable overrides and renders the module template.

mergeModuleVariables fills in defaults for non-computed, non-sensitive variables from the manifest (with basic JSON type validation via isSimpleJSONValue), uses null for non-required variables without defaults, and leaves required variables absent so missingkey=error catches omissions at render time.

BundleTar packages the result into a tar archive with reproducible timestamps. Writes main.tf always, modules.tf only when modules are present.

Conflict detection is bidirectional so module ordering in the request does not affect validation.

@linear-code

linear-code Bot commented Jun 12, 2026

Copy link
Copy Markdown

DEVEX-277

Implement the bases listing endpoint for the template builder. Returns
base templates from the bundled catalog with OS metadata resolved from
the exampleID->OS map. The endpoint is gated behind the template builder
feature flag and returns 404 when disabled.
…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.
…raction

Add ModuleRenderContext and RenderModuleTemplate for rendering module
.tf.tmpl files with registry URL, pinned version, agent resource name,
and variable values. Nil-guards the Variables map to prevent panics.

Extract shared renderTemplate with missingkey=error so missing variable
keys fail loudly instead of producing "<no value>" in rendered HCL.

Add ExtractAgentResourceName which uses a regex to find the coder_agent
resource name from rendered base HCL. Strips comment lines (# and //)
before matching to avoid false positives. Errors if zero or more than
one agent is found.

Add ModuleTemplateFS to expose module template files from the embedded
catalog, with validation that the expected .tf.tmpl file exists.
Compose renders a base template and selected modules into Terraform
source files. It validates modules before rendering: rejects duplicates,
ConflictsWith violations, unknown IDs, and OS incompatibility. For each
module, mergeModuleVariables fills in manifest defaults for non-computed,
non-sensitive variables (with basic JSON type validation), then overlays
caller-supplied values. Required variables without defaults are left
absent so missingkey=error catches the omission at render time.

BundleTar packages the result into a tar archive with reproducible
timestamps (time.Unix(0,0)). Writes main.tf always, modules.tf only
when modules are present.
@jeremyruppel
jeremyruppel force-pushed the jeremy/devex-277-phase1-module-rendering branch from c7893a9 to f412afb Compare June 12, 2026 22:00

jeremyruppel commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

@jeremyruppel
jeremyruppel changed the base branch from jeremy/devex-277-phase1-module-rendering to graphite-base/26349 June 15, 2026 13:27
@jeremyruppel
jeremyruppel changed the base branch from graphite-base/26349 to main June 15, 2026 13:27
@jeremyruppel
jeremyruppel merged commit 877f4de into main Jun 15, 2026
30 of 31 checks passed
@jeremyruppel
jeremyruppel deleted the jeremy/devex-277-phase2-compose branch June 15, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants