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
- Variables
- func AquaSnapshot() (SnapshotMeta, []AquaEntry, error)
- func CheckURL(raw string) error
- func WebHosts() []string
- type AquaEntry
- type ConfigLayer
- type EOL
- type Entry
- type Inputs
- type JSONMap
- type Layer
- type LintError
- type Linter
- type Match
- type MiseLister
- type Name
- type OSVPackage
- type Resolution
- type Resolver
- type SnapshotMeta
- type Source
- type ToolSpec
- type VersionSpec
Constants ¶
const ( UniverseReleases = "releases" UniverseTags = "tags" )
Universe values.
const ( PlaceholderVersion = "{version}" PlaceholderMajor = "{major}" PlaceholderMinor = "{minor}" PlaceholderTag = "{tag}" PlaceholderPrevMinor = "{prev_minor}" PlaceholderPrevMajor = "{prev_major}" )
Template placeholders of paths, URLs, refs and anchors.
const ( MiseSourceLive = "live" MiseSourceSnapshot = "snapshot" )
Where mise's registry was read from.
const ( MiseSnapshotFile = "mise.json" AquaSnapshotFile = "aqua.json" )
Snapshot file names in internal/registry/snapshot.
Variables ¶
var ( ErrUnknownTool = errors.New("unknown tool") ErrNoRepo = errors.New("no GitHub repository") ErrUnsupported = errors.New("unsupported tool syntax") )
Resolution errors.
var ErrHostNotAllowed = errors.New("host not allowed")
ErrHostNotAllowed is wrapped by CheckURL errors for hosts outside WebHosts.
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.
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.
type LintError ¶
type LintError struct {
Problems []yamlschema.Problem
}
LintError lists every problem found in one or more entries. It unwraps to ErrInvalid.
func (*LintError) ProblemLines ¶
ProblemLines returns one line per problem, with file:line:column.
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.
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 (*Resolver) Identify ¶
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.
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 ¶
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.