feat(coderd/templatebuilder): add exampleID->OS map and base template .tf.tmpl files - #26115
Merged
jeremyruppel merged 3 commits intoJun 12, 2026
Conversation
Contributor
Author
This was referenced Jun 5, 2026
jeremyruppel
commented
Jun 5, 2026
Comment on lines
+15
to
+16
| # Last updated 2023-03-14 | ||
| # aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort' |
Contributor
Author
There was a problem hiding this comment.
I saw this comment and I'm honestly not sure if we should remove it or update it
Contributor
There was a problem hiding this comment.
Seems like maybe it was meant to replace the hard coded list of aws regions below?
jeremyruppel
marked this pull request as ready for review
June 5, 2026 21:30
This was referenced Jun 9, 2026
jeremyruppel
force-pushed
the
jeremy/devex-273-be-exampleid-os-map-base-template-tftmpl-files-docker-k8s
branch
from
June 9, 2026 22:06
dc0261b to
4a8bb2a
Compare
jeremyruppel
force-pushed
the
jeremy/devex-272-be-module-catalog-structure-goembed-wiring
branch
from
June 9, 2026 22:06
7bead3b to
09a6bf6
Compare
Base automatically changed from
jeremy/devex-272-be-module-catalog-structure-goembed-wiring
to
main
June 12, 2026 13:40
… .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.
jeremyruppel
force-pushed
the
jeremy/devex-273-be-exampleid-os-map-base-template-tftmpl-files-docker-k8s
branch
from
June 12, 2026 17:20
4a8bb2a to
a99cffd
Compare
This was referenced Jun 12, 2026
zenithwolf1000
approved these changes
Jun 12, 2026
zenithwolf1000
left a comment
Contributor
There was a problem hiding this comment.
Potential optimization, but lgtm otherwise
Comment on lines
+15
to
+16
| # Last updated 2023-03-14 | ||
| # aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort' |
Contributor
There was a problem hiding this comment.
Seems like maybe it was meant to replace the hard coded list of aws regions below?
…e.json and pre-parse templates
Replace the hardcoded baseTemplates map with data-driven base.json
manifests in each bases/{id}/ directory, following the same pattern
used by the module catalog (catalog.go). Templates are pre-parsed
at first access via sync.OnceValues, so parse errors surface early
instead of at render time.
- Add base.json to docker, kubernetes, and aws-linux base directories
- Parse and validate manifests with DisallowUnknownFields at load time
- Pre-parse all .tf.tmpl files into *template.Template objects
- Change RenderBaseTemplate to use cached templates (no per-call I/O)
- Add bases_internal_test.go with parsing and validation tests
jeremyruppel
commented
Jun 12, 2026
Comment on lines
-28
to
-47
| // baseTemplates is the canonical map of example IDs to their metadata. | ||
| // Maintained manually because TemplateExample.Tags are freeform and | ||
| // container/Kubernetes templates carry no OS tag. | ||
| // Do not mutate this map; use the exported accessors to read from it. | ||
| var baseTemplates = map[string]BaseTemplate{ | ||
| "docker": { | ||
| OS: BaseOSLinux, | ||
| DefaultContext: BaseRenderContext{ | ||
| ContainerImage: "codercom/enterprise-base:ubuntu", | ||
| }, | ||
| }, | ||
| "kubernetes": { | ||
| OS: BaseOSLinux, | ||
| DefaultContext: BaseRenderContext{ | ||
| ContainerImage: "codercom/enterprise-base:ubuntu", | ||
| }, | ||
| }, | ||
| "aws-linux": { | ||
| OS: BaseOSLinux, | ||
| }, |
Contributor
Author
There was a problem hiding this comment.
now that we're embedding .tf.tmpls, we also need to embed a little metadata, so that's what the new json files are for
jeremyruppel
deleted the
jeremy/devex-273-be-exampleid-os-map-base-template-tftmpl-files-docker-k8s
branch
June 12, 2026 21: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.

Add the bundled
exampleID -> OSGo map for Docker, Kubernetes, and AWS EC2 Linux base templates. Create.tf.tmplGo template files for each withincoderd/templatebuilder/bases/, along withBaseRenderContextandRenderBaseTemplaterendering helpers.The
.tf.tmplfiles are independent copies of the example templates with module blocks (code-server, jetbrains) removed, since the template builder composes modules separately intomodules.tf. WhenImageOptionsis 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
-updateflag for regeneration.Depends on #25909
Note
This PR was authored by Coder Agents on behalf of @jeremyruppel.