feat: show template prerequisites in builder UI#26523
Conversation
…mplates Add README.md files to each base template directory (docker, kubernetes, aws-linux) with HTML comment markers (<!-- prerequisites:start --> and <!-- prerequisites:end -->) to delimit the prerequisites section. At boot time, the base catalog loader reads the README and extracts the prerequisites content between the markers using simple string literal matching. This content is served via a new 'prerequisites' field on the GET /api/v2/templatebuilder/bases response. The full README is also included in the composed template tar bundle (README.md) and set on the template version row, so builder-created templates have proper documentation visible in the Coder UI. Part of DEVEX-446
Docs preview📖 View docs preview for |
This comment has been minimized.
This comment has been minimized.
dcbc7b1 to
8560438
Compare
|
|
||
| Provision AWS EC2 VMs as [Coder workspaces](https://coder.com/docs/user-guides/workspace-management) with this example template. | ||
|
|
||
| <!-- prerequisites:start --> |
There was a problem hiding this comment.
these are the markers that need to be added by hand to each README that has prerequisites
| readmeData, err := fs.ReadFile(baseFS, "README.md") | ||
| if err != nil { | ||
| return nil, xerrors.Errorf("read README.md for base %q: %w", manifest.ID, err) | ||
| } | ||
| readme := string(readmeData) |
There was a problem hiding this comment.
base templates should always have a README file, which may or may not contain prerequisites
| t.Run("KnownBasesHaveReadme", func(t *testing.T) { | ||
| t.Parallel() | ||
| for _, id := range templatebuilder.BaseTemplateIDs() { | ||
| readme := templatebuilder.BaseReadme(id) | ||
| require.NotEmpty(t, readme, "base %q should have a README", id) | ||
| } | ||
| }) |
There was a problem hiding this comment.
the is the test-time check for READMEs in each base template; the embed time check will also fail if no README is present in the base template directory
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |

Surface base template prerequisites to admins before they create a template in the Template Builder wizard.
Today, template prerequisites (Docker socket setup, Kubernetes auth, AWS IAM policies) are only visible in the registry README after import. Admins hit opaque provisioner errors and have to hunt for docs. This change extracts the prerequisites from the README and serves them via the API so the frontend can display them inline.
How it works
Each base template README uses HTML comment markers (
<!-- prerequisites:start -->/<!-- prerequisites:end -->) to delimit the prerequisites section. At boot time, the base catalog loader reads the README, extracts the content between markers viastrings.Index, and caches both the full README and the prerequisites string.The prerequisites are served via a new
prerequisitesfield onGET /api/v2/templatebuilder/bases. The full README is included in the composed template tar bundle and stored as the template version readme.Changes
README.mdwith prerequisite markers tocoderd/templatebuilder/bases/{docker,kubernetes,aws-linux}/ExtractPrerequisites()inprerequisites.gousing literal string matchingbases.go: load README at boot, fail loudly if missing, extract prerequisitescompose.go: include README inComposeResultand tar bundlecodersdk: addPrerequisitesfield toTemplateBuilderBaseImplementation notes
strings.Indexfor exact literal marker matching; no regex or AST parser needed since we control the markers.TemplateDocsPagealready strips it at render time viafront-matter.RejectsMissingReadmetest enforces that every base template must include a README.## Prerequisitesand## Required permissions / policy), which is why heading-based parsing was rejected in favor of explicit markers.Generated with the assistance of an AI coding agent. Reviewed by @jeremyruppel.
Relates to https://linear.app/codercom/issue/DEVEX-446