registry

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GzipTextFiles

func GzipTextFiles(outputDir string) (int, error)

GzipTextFiles walks the output directory and gzip-compresses all files except .tar.gz archives (which are already compressed). Files are compressed in-place, keeping their original names. This is intended for pre-compressed uploads to S3/GCS with Content-Encoding: gzip.

func InvalidationPathsForModuleRebuild

func InvalidationPathsForModuleRebuild(registryPath string, versions []*semver.Version, htmlEnabled bool, indexFile string, dirsEnabled bool) []string

InvalidationPathsForModuleRebuild returns CDN paths to invalidate when rebuilding all versions of a module. Every version's download and HTML pages are included since they are all regenerated. registryPath is the 3-segment path used in URLs.

func InvalidationPathsForNewVersion

func InvalidationPathsForNewVersion(registryPath string, htmlEnabled bool, indexFile string, dirsEnabled bool) []string

InvalidationPathsForNewVersion returns CDN paths to invalidate when publishing a single new tag. The new version's own files (download, HTML) are excluded because they are brand-new URLs that have never been cached. registryPath is the 3-segment path used in URLs.

func WriteInvalidationFile

func WriteInvalidationFile(paths []string, filePath string, format InvalidationFormat) error

WriteInvalidationFile writes the collected invalidation paths to a file in the given format.

Types

type DevServer

type DevServer struct {
	Git         *git.Runner
	RepoRoot    string
	ModulesPath string
	HTMLEnabled bool
	// contains filtered or unexported fields
}

DevServer serves module archives built on the fly from the current working tree. Every download request returns the current state of the module directory, regardless of which version was requested. This lets developers swap the registry domain to localhost and test uncommitted changes without tagging.

func NewDevServer

func NewDevServer(gitRunner *git.Runner, repoRoot, modulesPath, namespace string, moduleMappings map[string]string) (*DevServer, error)

NewDevServer creates a DevServer.

func (*DevServer) Handler

func (s *DevServer) Handler() http.Handler

Handler returns an http.Handler that implements the dev registry.

type HTMLGenerator

type HTMLGenerator struct {
	Git                 *git.Runner
	OutputDir           string
	IndexFile           string
	BaseURL             string
	RepositoryURL       string
	RepositoryPrefix    string
	RepositoryRef       string
	RepositoryTagPrefix string
	ReadmeReader        ReadmeReader
	// contains filtered or unexported fields
}

HTMLGenerator creates HTML documentation pages for the registry.

func NewHTMLGenerator

func NewHTMLGenerator(gitRunner *git.Runner, outputDir, indexFile string) *HTMLGenerator

NewHTMLGenerator creates a new HTMLGenerator.

func (*HTMLGenerator) GenerateAll

func (g *HTMLGenerator) GenerateAll(grouped map[string][]module.TagInfo) error

GenerateAll generates the complete HTML documentation tree.

func (*HTMLGenerator) GenerateForModule

func (g *HTMLGenerator) GenerateForModule(modPath string, tags []module.TagInfo, allGrouped map[string][]module.TagInfo) error

GenerateForModule generates HTML pages for a single module (module index + every version page) and updates the root index.

func (*HTMLGenerator) GenerateForVersion

func (g *HTMLGenerator) GenerateForVersion(tag module.TagInfo, moduleTags []module.TagInfo, allGrouped map[string][]module.TagInfo) error

GenerateForVersion generates the HTML page for a single new version, updates the module index (to show it in the version list), and updates the root index.

func (*HTMLGenerator) LoadBaseTemplate

func (g *HTMLGenerator) LoadBaseTemplate(path string) error

LoadBaseTemplate loads a custom base HTML template from a file path. The template must contain {{.Title}} and {{.Content}} placeholders.

type InvalidationFormat

type InvalidationFormat string

InvalidationFormat defines the output format for the invalidation file.

const (
	InvalidationFormatJSON       InvalidationFormat = "json"
	InvalidationFormatTxt        InvalidationFormat = "txt"
	InvalidationFormatCloudFront InvalidationFormat = "cloudfront"
)

func ParseInvalidationFormat

func ParseInvalidationFormat(s string) (InvalidationFormat, error)

ParseInvalidationFormat parses a string into an InvalidationFormat.

type ModuleVersionList

type ModuleVersionList struct {
	Versions []VersionEntry `json:"versions"`
}

ModuleVersionList contains the versions for a single module.

type ModuleVersions

type ModuleVersions struct {
	Modules []ModuleVersionList `json:"modules"`
}

ModuleVersions is the response format for the versions endpoint.

type Publisher

type Publisher struct {
	Git         *git.Runner
	OutputDir   string
	BaseURL     string
	ModulesPath string
}

Publisher generates static registry files.

func NewPublisher

func NewPublisher(gitRunner *git.Runner, outputDir, baseURL, modulesPath string) *Publisher

NewPublisher creates a new Publisher.

func (*Publisher) GenerateServiceDiscovery

func (p *Publisher) GenerateServiceDiscovery() error

GenerateServiceDiscovery creates the .well-known/terraform.json file.

func (*Publisher) GenerateVersionsJSON

func (p *Publisher) GenerateVersionsJSON(registryPath string, versions []*semver.Version) error

GenerateVersionsJSON creates the versions file for a module. registryPath is the 3-segment path used for the output directory structure.

func (*Publisher) PublishVersion

func (p *Publisher) PublishVersion(tag module.TagInfo) error

PublishVersion generates all files for a single module version. It creates: the archive, the download HTML, and returns the version string. The caller is responsible for generating the versions after all versions are published. tag.ModulePath is used for git operations; tag.RegistryPath for output paths and URLs.

func (*Publisher) PublishVersionFromWorkTree

func (p *Publisher) PublishVersionFromWorkTree(repoRoot, modulePath, registryPath string, version *semver.Version) error

PublishVersionFromWorkTree generates all files for a module version using the current filesystem (working tree) instead of a git tag. modulePath is the directory path (for filesystem operations); registryPath is the 3-segment path (for output structure and URLs).

type ReadmeReader

type ReadmeReader func(modulePath, tag string) string

ReadmeReader returns the raw markdown content of a README for a given module path and git tag. The tag is used by git-based readers to read from the correct commit. Filesystem-based readers ignore the tag parameter.

func EnrichedReadmeReader

func EnrichedReadmeReader(base ReadmeReader, repoRoot string, gitRunner *git.Runner) ReadmeReader

EnrichedReadmeReader wraps a base ReadmeReader and enriches the output with terraform-docs generated documentation. Module .tf files are read from the git tag (so each version gets its own docs), while .terraform-docs.yml config is read from the current filesystem (so config changes are retroactive).

func FilesystemReadmeReader

func FilesystemReadmeReader(repoRoot string) ReadmeReader

FilesystemReadmeReader returns a ReadmeReader that reads READMEs from the filesystem. The tag parameter is ignored.

func GitReadmeReader

func GitReadmeReader(gitRunner *git.Runner) ReadmeReader

GitReadmeReader returns a ReadmeReader that reads READMEs from the git tag specified in each call.

type ServiceDiscovery

type ServiceDiscovery struct {
	ModulesV1 string `json:"modules.v1"`
}

ServiceDiscovery represents the .well-known/terraform.json file.

type VersionEntry

type VersionEntry struct {
	Version string `json:"version"`
}

VersionEntry represents a single version in the versions file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL