Skip to content

feat(coderd/templatebuilder): add exampleID->OS map and base template .tf.tmpl files#26115

Open
jeremyruppel wants to merge 2 commits into
jeremy/devex-272-be-module-catalog-structure-goembed-wiringfrom
jeremy/devex-273-be-exampleid-os-map-base-template-tftmpl-files-docker-k8s
Open

feat(coderd/templatebuilder): add exampleID->OS map and base template .tf.tmpl files#26115
jeremyruppel wants to merge 2 commits into
jeremy/devex-272-be-module-catalog-structure-goembed-wiringfrom
jeremy/devex-273-be-exampleid-os-map-base-template-tftmpl-files-docker-k8s

Conversation

@jeremyruppel
Copy link
Copy Markdown
Contributor

@jeremyruppel jeremyruppel commented Jun 5, 2026

Add the bundled exampleID -> OS Go map for Docker, Kubernetes, and AWS EC2 Linux base templates. Create .tf.tmpl Go template files for each within coderd/templatebuilder/bases/, along with BaseRenderContext and RenderBaseTemplate rendering helpers.

The .tf.tmpl files are independent copies of the example templates with module blocks (code-server, jetbrains) removed, since the template builder composes modules separately into modules.tf. When ImageOptions is provided, the container image field references the Terraform parameter; otherwise it uses the hardcoded value via Go template whitespace control ({{-).

Golden file snapshot tests verify rendered output stability with an -update flag for regeneration.

Depends on #25909

Note

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

… .tf.tmpl files

Add the bundled exampleID to OS map for Docker, Kubernetes, and AWS EC2
Linux base templates. Create .tf.tmpl Go template files for each base
template within coderd/templatebuilder/bases/, along with BaseRenderContext
and RenderBaseTemplate rendering helpers.

The .tf.tmpl files are independent copies of the example templates with
module blocks (code-server, jetbrains) removed, since the template builder
composes modules separately into modules.tf. Golden file snapshot tests
verify rendered output stability.

No changes to the existing examples/ directory or create-from-example path.
- Fix image parameter not consumed: when ImageOptions is set, the
  docker_container and kubernetes_deployment image fields now reference
  data.coder_parameter.container_image.value instead of the hardcoded
  Go template variable.
- Validate exampleID in BaseTemplateFS against known base templates,
  returning a clear error for unknown IDs.
- Unexport baseTemplates map to prevent mutation; add BaseTemplateIDs()
  accessor. Store DefaultContext on BaseTemplate struct to consolidate
  the map and switch into a single data source.
- Remove unused BaseOSWindows constant (can be re-added when needed).
- Rename ctx parameter to renderCtx to avoid shadowing context.Context.
- Add comment documenting Variables field as reserved for DEVEX-277.
- Add Kubernetes WithImageOptions test for parity with Docker.
- Add BaseTemplateFS validation test for unknown IDs.
- Add AllBaseTemplatesHaveDefaults test to catch forgotten entries.
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 5, 2026

DEVEX-273

Copy link
Copy Markdown
Contributor Author

jeremyruppel commented Jun 5, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment on lines +15 to +16
# Last updated 2023-03-14
# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this comment and I'm honestly not sure if we should remove it or update it

@jeremyruppel jeremyruppel marked this pull request as ready for review June 5, 2026 21:30
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.

1 participant