Documentation
¶
Overview ¶
Package registry reads an OpenFlange registry index (openflange.org/registry/v0.1): the generated `index.json` (or `index.ndjson`) of a Git-backed registry. It loads the index from a local path or a URL, searches it, and resolves `<publisher>/<name>[@range]` references to a distribution reference (git:, npm:, https:, ...).
The default registry URL is not live yet; everything works from a local path, and a network failure yields a clear error instead of a hang.
Index ¶
Constants ¶
const ( MaxIndexBytes = 32 << 20 FetchTimeout = 15 * time.Second )
Limits for loading an index.
const DefaultURL = "https://openflange.com/index.json"
DefaultURL is the default registry index. It is NOT live yet.
const EnvVar = "OPENFLANGE_REGISTRY"
EnvVar names the environment variable that overrides the registry location.
const Spec = "openflange.org/registry/v0.1"
Spec is the registry spec identifier.
Variables ¶
This section is empty.
Functions ¶
func Location ¶
Location returns the registry location to use: the flag value if set, else $OPENFLANGE_REGISTRY, else DefaultURL.
func ValidPublisher ¶
ValidPublisher reports whether s is a valid publisher (lower-case GitHub login).
Types ¶
type Deprecation ¶
type Deprecation struct {
Deprecated bool
Reason string
ReplacedBy string // registry id <publisher>/<name> of the replacement
}
Deprecation is the `deprecated` member of an entry or version record: `false`, `true`, or `{reason, replacedBy}`. It marshals back to the same shapes (an object when a reason or replacement is known).
func (Deprecation) MarshalJSON ¶
func (d Deprecation) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*Deprecation) UnmarshalJSON ¶
func (d *Deprecation) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Distribution ¶
type Distribution struct {
Type string `json:"type"` // git | npm | http | pypi | cran | oci
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
Package string `json:"package,omitempty"`
Ref string `json:"ref,omitempty"` // informative
}
Distribution says where a pipe's package lives.
type Entry ¶
type Entry struct {
ID string `json:"id"`
Spec string `json:"spec"`
Publisher string `json:"publisher"`
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
License string `json:"license,omitempty"`
Keywords []string `json:"keywords"`
Languages []string `json:"languages"`
Runtimes []string `json:"runtimes"`
MediaTypes []string `json:"mediaTypes"`
Distribution Distribution `json:"distribution"`
Deprecated Deprecation `json:"deprecated"`
Latest string `json:"latest"`
Versions []Version `json:"versions"`
// Extensions holds the entry's `x-` keys; they are carried through.
Extensions map[string]json.RawMessage `json:"-"`
}
Entry is one element of the index: a pipe entry with defaults filled in, plus `id` and `latest` (registry/v0.1 §7.1). Its JSON form is the index element shape and the stable `--json` shape of `openflange search`.
func (Entry) MarshalJSON ¶
MarshalJSON emits the index element including extension keys.
func (*Entry) UnmarshalJSON ¶
UnmarshalJSON decodes an index element. Reading is lenient about unknown keys (`x-` keys are kept as Extensions), accepts `latest` as a string or as an object with `version`, and accepts an npm package under `name` as well as `package`; it is strict about the types of known members.
type Index ¶
type Index struct {
Spec string `json:"spec"`
GeneratedAt string `json:"generatedAt,omitempty"`
Commit string `json:"commit,omitempty"`
Pipes []Entry `json:"pipes"`
// Warnings lists entries that were skipped while loading.
Warnings []string `json:"-"`
// Source is the location the index was loaded from.
Source string `json:"-"`
}
Index is a loaded registry index.
func Load ¶
Load reads a registry index from a local file, a directory containing index.json, a file:// URL, or an http(s) URL (bounded: 15 s, 32 MiB, SSRF-safe; plain HTTP only for loopback). A path ending in `.ndjson` is read as one entry per line. Errors are *errs.Error; network failures carry a hint about using a local registry and never hang.
func ParseNDJSON ¶
ParseNDJSON decodes an index.ndjson document (one entry per line).
type Query ¶
type Query struct {
Text string
Language string
Runtime string
License string
Distribution string
MediaType string
IncludeDeprecated bool
Limit int
}
Query is a search request. Text terms are ANDed; filters are exact, case-insensitive membership tests.
type Resolution ¶
type Resolution struct {
Entry *Entry
Version Version
// Reference is the distribution as a pipe reference (baseline §4), e.g.
// `git:https://github.com/o/r#<commit>:path` or `npm:pkg@1.2.3`.
Reference string
// Warning is set when the selected pipe or version is deprecated.
Warning string
}
Resolution is the outcome of resolving a registry reference.
type Version ¶
type Version struct {
Version string `json:"version"`
Manifest string `json:"manifest,omitempty"`
Revision string `json:"revision,omitempty"`
Integrity string `json:"integrity,omitempty"` // sha256 of the manifest file bytes
PublishedAt string `json:"publishedAt,omitempty"`
Deprecated Deprecation `json:"deprecated"`
}
Version is one published version of a registry entry.