feat(scripts): add generator for template builder module catalog#26193
Conversation
9b5edc9 to
b1e1078
Compare
| // fetchLatestVersion resolves the latest semver for a module using the | ||
| // Terraform protocol versions endpoint. | ||
| func fetchLatestVersion(ctx context.Context, baseURL, namespace, slug string) (string, error) { | ||
| reqURL := fmt.Sprintf("%s/terraform_protocol/%s/%s/coder/versions", baseURL, namespace, slug) |
There was a problem hiding this comment.
@DevelopmentCats hey! is there another API endpoint I can use to get available module versions? or even better, the latest version? I found this info in this terraform endpoint but I am hoping there's a more obvious place
There was a problem hiding this comment.
We control the registry so we can just make a change in there and then use it in here if you wanna add a TODO
6a591ad to
e1dff0c
Compare
8680465 to
944e5a2
Compare
e1dff0c to
36a2669
Compare
Docs preview📖 View docs preview for |
36a2669 to
04eb9f8
Compare
| var moduleConfigs = map[string]ModuleConfig{ | ||
| "code-server": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{"vscode-web"}}, | ||
| "jetbrains": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "vscode-desktop": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "vscode-web": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{"code-server"}}, | ||
| "cursor": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "windsurf": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "zed": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "kiro": {Category: "IDE", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "claude-code": {Category: "AI Agent", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "aider": {Category: "AI Agent", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "goose": {Category: "AI Agent", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "amazon-q": {Category: "AI Agent", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "git-clone": {Category: "Source Control", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "git-config": {Category: "Source Control", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "git-commit-signing": {Category: "Source Control", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "dotfiles": {Category: "Utility", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "personalize": {Category: "Utility", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "filebrowser": {Category: "Utility", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| "jupyterlab": {Category: "Utility", CompatibleOS: []string{"linux"}, ConflictsWith: []string{}}, | ||
| } |
There was a problem hiding this comment.
unsure if there's a better place for this to live
04eb9f8 to
bf3751c
Compare
944e5a2 to
72c2d54
Compare
|
without the template builder context front of mind, I think "modulegen" is a very confusing name. bit of a mouth full but "templatebuildermodulegen" would at least be very clear about what it does. |
e825063 to
82ef5b9
Compare
72c2d54 to
3498467
Compare
3498467 to
d16f7a1
Compare
82ef5b9 to
323abf2
Compare
d16f7a1 to
01df677
Compare
323abf2 to
29cf034
Compare
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.
29cf034 to
a4865da
Compare
zenithwolf1000
left a comment
There was a problem hiding this comment.
Gave this a pretty relaxed review as it's essentially just a gen script
| "golang.org/x/xerrors" | ||
| ) | ||
|
|
||
| const registryBaseURL = "https://registry.coder.com" |
There was a problem hiding this comment.
Reviewing this with relaxed requirements on abstractions (like templating the uri path or config-ing the base)
| // fetchLatestVersion resolves the latest semver for a module using the | ||
| // Terraform protocol versions endpoint. | ||
| func fetchLatestVersion(ctx context.Context, baseURL, namespace, slug string) (string, error) { | ||
| reqURL := fmt.Sprintf("%s/terraform_protocol/%s/%s/coder/versions", baseURL, namespace, slug) |
There was a problem hiding this comment.
We control the registry so we can just make a change in there and then use it in here if you wanna add a TODO
Merge activity
|

Note
This PR was authored by Coder Agents on behalf of @jeremyruppel.
Adds
scripts/templatebuildermodulegen/, a Go tool that fetches module metadata from the Coder registry HTTP API and generates themodule.jsonmanifests and.tf.tmplfiles used by the template builder catalog.The generator calls
GET /api/modules/{id}for per-module metadata (display name, description, icon, tags, variables) and the Terraform protocol versions endpoint for semver resolution. No git clone or HCL parsing required.Split into four files:
main.go: orchestration, module config map, CLI flagstypes.go: output types (ModuleManifest,ModuleVariable) and API response typesfetch.go: HTTP fetching, version resolution, variable conversion, icon normalizationwrite.go: JSON writer,.tf.tmplGo template and writer