Skip to content

feat(scripts): add generator for template builder module catalog#26193

Merged
jeremyruppel merged 3 commits into
mainfrom
jeremy/devex-274a-scripts-modulegen-generator
Jun 15, 2026
Merged

feat(scripts): add generator for template builder module catalog#26193
jeremyruppel merged 3 commits into
mainfrom
jeremy/devex-274a-scripts-modulegen-generator

Conversation

@jeremyruppel

@jeremyruppel jeremyruppel commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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 the module.json manifests and .tf.tmpl files 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 flags
  • types.go: output types (ModuleManifest, ModuleVariable) and API response types
  • fetch.go: HTTP fetching, version resolution, variable conversion, icon normalization
  • write.go: JSON writer, .tf.tmpl Go template and writer

// 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)

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.

@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch 2 times, most recently from 6a591ad to e1dff0c Compare June 9, 2026 21:26
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-276-be-get-apiv2templatebuildermodules-endpoint branch from 8680465 to 944e5a2 Compare June 9, 2026 22:06
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from e1dff0c to 36a2669 Compare June 9, 2026 22:06
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/reference/api/schemas.md

@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from 36a2669 to 04eb9f8 Compare June 9, 2026 22:09
Comment on lines +22 to +42
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{}},
}

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.

unsure if there's a better place for this to live

@jeremyruppel jeremyruppel marked this pull request as ready for review June 9, 2026 22:11
@jeremyruppel jeremyruppel changed the base branch from jeremy/devex-276-be-get-apiv2templatebuildermodules-endpoint to graphite-base/26193 June 9, 2026 22:18
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from 04eb9f8 to bf3751c Compare June 9, 2026 22:19
@jeremyruppel jeremyruppel force-pushed the graphite-base/26193 branch from 944e5a2 to 72c2d54 Compare June 9, 2026 22:19
@jeremyruppel jeremyruppel changed the base branch from graphite-base/26193 to jeremy/devex-276-be-get-apiv2templatebuildermodules-endpoint June 9, 2026 22:19
@aslilac

aslilac commented Jun 11, 2026

Copy link
Copy Markdown
Member

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.

@jeremyruppel jeremyruppel changed the title feat(scripts/modulegen): add generator for template builder module catalog feat(scripts): add generator for template builder module catalog Jun 11, 2026
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from e825063 to 82ef5b9 Compare June 12, 2026 17:20
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-276-be-get-apiv2templatebuildermodules-endpoint branch from 72c2d54 to 3498467 Compare June 12, 2026 17:20
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-276-be-get-apiv2templatebuildermodules-endpoint branch from 3498467 to d16f7a1 Compare June 12, 2026 21:20
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from 82ef5b9 to 323abf2 Compare June 12, 2026 21:20
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-276-be-get-apiv2templatebuildermodules-endpoint branch from d16f7a1 to 01df677 Compare June 12, 2026 21:42
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from 323abf2 to 29cf034 Compare June 12, 2026 21:42
Base automatically changed from jeremy/devex-276-be-get-apiv2templatebuildermodules-endpoint to main June 12, 2026 21:53
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.

@zenithwolf1000 zenithwolf1000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gave this a pretty relaxed review as it's essentially just a gen script

"golang.org/x/xerrors"
)

const registryBaseURL = "https://registry.coder.com"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

jeremyruppel commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jun 15, 1:24 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 15, 1:24 PM UTC: Graphite couldn't merge this PR because it failed optional checks and "ignore optional checks" was not selected.
  • Jun 15, 1:25 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 15, 1:25 PM UTC: @jeremyruppel merged this pull request with Graphite.

@jeremyruppel jeremyruppel merged commit 809bd61 into main Jun 15, 2026
28 of 29 checks passed
@jeremyruppel jeremyruppel deleted the jeremy/devex-274a-scripts-modulegen-generator branch June 15, 2026 13:25
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.

3 participants