registry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package registry resolves a tool name to a ToolSpec by merging the user config, relgap's curated entries, mise's registry and an index of the aqua registry.

Index

Constants

View Source
const (
	UniverseReleases = "releases"
	UniverseTags     = "tags"
)

Universe values.

View Source
const (
	PlaceholderVersion   = "{version}"
	PlaceholderMajor     = "{major}"
	PlaceholderMinor     = "{minor}"
	PlaceholderTag       = "{tag}"
	PlaceholderPrevMinor = "{prev_minor}"
	PlaceholderPrevMajor = "{prev_major}"
)

Template placeholders of paths, URLs, refs and anchors.

View Source
const (
	MiseSourceLive     = "live"
	MiseSourceSnapshot = "snapshot"
)

Where mise's registry was read from.

View Source
const (
	MiseSnapshotFile = "mise.json"
	AquaSnapshotFile = "aqua.json"
)

Snapshot file names in internal/registry/snapshot.

Variables

View Source
var (
	ErrUnknownTool = errors.New("unknown tool")
	ErrNoRepo      = errors.New("no GitHub repository")
	ErrUnsupported = errors.New("unsupported tool syntax")
)

Resolution errors.

View Source
var ErrHostNotAllowed = errors.New("host not allowed")

ErrHostNotAllowed is wrapped by CheckURL errors for hosts outside WebHosts.

View Source
var ErrInvalid = errors.New("invalid registry entry")

ErrInvalid is wrapped by every registry entry error.

Functions

func AquaSnapshot

func AquaSnapshot() (SnapshotMeta, []AquaEntry, error)

AquaSnapshot returns the embedded index of the aqua registry.

func CheckURL

func CheckURL(raw string) error

CheckURL returns an error unless raw is an https URL on one of WebHosts.

func WebHosts

func WebHosts() []string

WebHosts returns the hosts that web-doc, structured-json and upgrade-guide URLs may point to. Every other page comes from GitHub through the API.

Types

type AquaEntry

type AquaEntry struct {
	Name          string   `json:"name"`           // package name, such as hashicorp/terraform
	Repo          string   `json:"repo,omitempty"` // empty for packages not hosted on GitHub
	Aliases       []string `json:"aliases,omitempty"`
	VersionPrefix string   `json:"version_prefix,omitempty"`
	VersionFilter string   `json:"version_filter,omitempty"` // an expr-lang expression
	VersionSource string   `json:"version_source,omitempty"` // github_tag or github_release
}

AquaEntry is one package of the aqua registry, reduced to what resolution needs.

type ConfigLayer

type ConfigLayer struct {
	Tools   map[string]string // tool name to owner/repo
	Aliases map[string]string // raw name to tool name
}

ConfigLayer is the part of the user config that takes part in resolution.

type EOL

type EOL struct {
	Product string `json:"product"         yaml:"product"`
	Cycle   string `json:"cycle,omitempty" yaml:"cycle"` // template such as {major}.{minor}
}

EOL names the endoflife.date product of a tool.

type Entry

type Entry struct {
	Name            string       `yaml:"name"`
	Aliases         []string     `yaml:"aliases"`
	Repo            string       `yaml:"repo"`
	MinRelgap       string       `yaml:"min_relgap"`
	Version         VersionSpec  `yaml:"version"`
	Sources         []Source     `yaml:"sources"`
	EOL             *EOL         `yaml:"eol"`
	OSV             []OSVPackage `yaml:"osv"`
	BreakingMarkers []string     `yaml:"breaking_markers"`
	Bin             []string     `yaml:"bin"`
}

Entry is one registry/<name>.yaml file, as defined by schemas/registry-v1.json.

type Inputs

type Inputs struct {
	Config     ConfigLayer
	Entries    []*Entry
	Mise       []misex.RegistryEntry
	MiseSource string
	Aqua       []AquaEntry
}

Inputs are the layers a Resolver merges.

type JSONMap

type JSONMap struct {
	Items   string `json:"items,omitempty"   yaml:"items"`   // dotted path to the array; empty means the document
	Heading string `json:"heading,omitempty" yaml:"heading"` // field whose value groups entries under a heading
	Text    string `json:"text"              yaml:"text"`    // template with {field} placeholders
	Link    string `json:"link,omitempty"    yaml:"link"`    // field holding a URL for the entry
}

JSONMap says how a structured-json document becomes Markdown entries.

type Layer

type Layer string

Layer names where a field of a ToolSpec came from, highest precedence first.

const (
	LayerExplicit Layer = "explicit"
	LayerConfig   Layer = "config"
	LayerRelgap   Layer = "relgap registry"
	LayerMise     Layer = "mise registry"
	LayerAqua     Layer = "aqua registry"
	LayerDefault  Layer = "default"
)

Resolution layers.

type LintError

type LintError struct {
	Problems []yamlschema.Problem
}

LintError lists every problem found in one or more entries. It unwraps to ErrInvalid.

func (*LintError) Error

func (e *LintError) Error() string

func (*LintError) Header

func (*LintError) Header() string

Header introduces the problem list in error output.

func (*LintError) ProblemLines

func (e *LintError) ProblemLines() []string

ProblemLines returns one line per problem, with file:line:column.

func (*LintError) Unwrap

func (*LintError) Unwrap() error

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

Linter validates registry entries against schemas/registry-v1.json and checks what the schema can't: regular expressions, scheme and extract, and the file name.

func NewLinter

func NewLinter() (*Linter, error)

NewLinter compiles the registry schema.

func (*Linter) Lint

func (l *Linter) Lint(origin string, b []byte) (*Entry, []yamlschema.Problem, error)

Lint parses one entry. origin is the file path used in problems and to check the name. It returns the entry, or the problems found.

func (*Linter) LoadFS

func (l *Linter) LoadFS(fsys fs.FS, dir string) ([]*Entry, error)

LoadFS lints and loads every *.yaml entry in fsys. Problems from all files are returned together as a LintError.

type Match

type Match struct {
	By    string `json:"by"` // name, alias, config alias, env var name, repo or aqua package
	Value string `json:"value"`
	Layer Layer  `json:"layer"`
}

Match says how the input was identified.

type MiseLister

type MiseLister interface {
	Registry(ctx context.Context) ([]misex.RegistryEntry, error)
}

MiseLister lists mise's registry; misex.Client implements it.

type OSVPackage

type OSVPackage struct {
	Ecosystem string `json:"ecosystem" yaml:"ecosystem"`
	Name      string `json:"name"      yaml:"name"`
}

OSVPackage is a package name in an OSV ecosystem.

type Resolution

type Resolution struct {
	Input      string             `json:"input"`
	Match      Match              `json:"match"`
	Tool       ToolSpec           `json:"tool"`
	Provenance map[string][]Layer `json:"provenance"` // field path to layers
	MiseSource string             `json:"mise_source"`
}

Resolution is a resolved tool with the layer that supplied each field.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver maps tool names to [ToolSpec]s.

func Load

func Load(ctx context.Context, logger *slog.Logger, mise MiseLister, cfg ConfigLayer) (*Resolver, error)

Load builds a resolver from the embedded entries and snapshots. With a non-nil mise, the live `mise registry --json` replaces the mise snapshot when it works.

func NewResolver

func NewResolver(in Inputs) *Resolver

NewResolver indexes the layers in in.

func (*Resolver) Identify

func (r *Resolver) Identify(input string) (string, bool)

Identify returns the name `relgap digest` accepts for input without merging layers: the registry name when a registry knows the tool, otherwise the github: or aqua: form itself.

func (*Resolver) Resolve

func (r *Resolver) Resolve(input string) (*Resolution, error)

Resolve identifies input and merges every layer that knows the tool. input is a name, an alias, a NAME_VERSION variable, github:owner/repo or aqua:package.

type SnapshotMeta

type SnapshotMeta struct {
	Source     string `json:"source"`
	Commit     string `json:"commit"`
	CommitDate string `json:"commit_date"` // RFC 3339
}

SnapshotMeta records where a snapshot came from.

func MiseSnapshot

func MiseSnapshot() (SnapshotMeta, []misex.RegistryEntry, error)

MiseSnapshot returns the embedded copy of mise's registry.

type Source

type Source struct {
	Kind           string   `json:"kind"                      yaml:"kind"`
	PathTemplate   string   `json:"path_template,omitempty"   yaml:"path_template"`
	URLTemplate    string   `json:"url_template,omitempty"    yaml:"url_template"`
	Ref            string   `json:"ref,omitempty"             yaml:"ref"`
	Heading        string   `json:"heading,omitempty"         yaml:"heading"`
	IgnoreSections []string `json:"ignore_sections,omitempty" yaml:"ignore_sections"`
	FromHeading    string   `json:"from_heading,omitempty"    yaml:"from_heading"`
	Content        string   `json:"content,omitempty"         yaml:"content"` // web-doc: selector of the element to convert
	Strip          []string `json:"strip,omitempty"           yaml:"strip"`   // web-doc: selectors of elements to drop
	Anchor         string   `json:"anchor,omitempty"          yaml:"anchor"`  // web-doc: id template of a version's element
	JSON           *JSONMap `json:"json,omitempty"            yaml:"json"`
}

Source is one changelog source of a tool.

type ToolSpec

type ToolSpec struct {
	Name            string       `json:"name"`
	Aliases         []string     `json:"aliases"`
	Repo            string       `json:"repo"`
	Version         VersionSpec  `json:"version"`
	Sources         []Source     `json:"sources"` // empty means auto-discovery
	EOL             *EOL         `json:"eol,omitempty"`
	OSV             []OSVPackage `json:"osv"`
	BreakingMarkers []string     `json:"breaking_markers"`
	Bin             []string     `json:"bin"` // executable names; empty means the tool name
}

ToolSpec is a resolved tool: where it lives, how its versions are read and where its notes are.

func SpecFromEntry

func SpecFromEntry(e *Entry) ToolSpec

SpecFromEntry returns the tool spec of one entry on its own, with defaults for the fields it leaves out, as `relgap registry test` runs a file that isn't embedded yet.

type VersionSpec

type VersionSpec struct {
	Scheme    string `json:"scheme"               yaml:"scheme"`
	Extract   string `json:"extract,omitempty"    yaml:"extract"`
	TagPrefix string `json:"tag_prefix,omitempty" yaml:"tag_prefix"`
	Exclude   string `json:"exclude,omitempty"    yaml:"exclude"`
	Universe  string `json:"universe"             yaml:"universe"` // releases or tags
	Line      string `json:"line"                 yaml:"line"`     // none, major or minor
}

VersionSpec says how a tool's tags become versions.

func (VersionSpec) Rules

func (v VersionSpec) Rules() (version.Rules, error)

Rules builds the version rules for this spec.

Jump to

Keyboard shortcuts

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