Skip to content

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

Draft
jeremyruppel wants to merge 1 commit into
jeremy/devex-276-be-get-apiv2templatebuildermodules-endpointfrom
jeremy/devex-274a-scripts-modulegen-generator
Draft

feat(scripts/modulegen): add generator for template builder module catalog#26193
jeremyruppel wants to merge 1 commit into
jeremy/devex-276-be-get-apiv2templatebuildermodules-endpointfrom
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/modulegen/, 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

jeremyruppel commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

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

@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from b1e1078 to 6a591ad Compare June 9, 2026 21:23
…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.
@jeremyruppel jeremyruppel force-pushed the jeremy/devex-274a-scripts-modulegen-generator branch from 6a591ad to e1dff0c Compare June 9, 2026 21:26
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