mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
> [!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.