registry

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 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 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

View Source
const (
	MaxIndexBytes = 32 << 20
	FetchTimeout  = 15 * time.Second
)

Limits for loading an index.

View Source
const DefaultURL = "https://openflange.com/index.json"

DefaultURL is the default registry index. It is NOT live yet.

View Source
const EnvVar = "OPENFLANGE_REGISTRY"

EnvVar names the environment variable that overrides the registry location.

View Source
const Spec = "openflange.org/registry/v0.1"

Spec is the registry spec identifier.

Variables

This section is empty.

Functions

func Location

func Location(flag string) string

Location returns the registry location to use: the flag value if set, else $OPENFLANGE_REGISTRY, else DefaultURL.

func SplitRef

func SplitRef(ref string) (publisher, name, rng string, ok bool)

SplitRef splits `<publisher>/<name>[@range]`.

func ValidName

func ValidName(s string) bool

ValidName reports whether s is a valid pipe name.

func ValidPublisher

func ValidPublisher(s string) bool

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

func (e Entry) MarshalJSON() ([]byte, error)

MarshalJSON emits the index element including extension keys.

func (*Entry) UnmarshalJSON

func (e *Entry) UnmarshalJSON(data []byte) error

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

func Load(ctx context.Context, location string) (*Index, error)

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 Parse

func Parse(data []byte) (*Index, error)

Parse decodes an index.json document.

func ParseNDJSON

func ParseNDJSON(data []byte) (*Index, error)

ParseNDJSON decodes an index.ndjson document (one entry per line).

func (*Index) Lookup

func (idx *Index) Lookup(publisher, name string) (*Entry, bool)

Lookup finds an entry by publisher and name.

func (*Index) Resolve

func (idx *Index) Resolve(ref string) (*Resolution, error)

Resolve resolves `<publisher>/<name>[@range]` to the highest non-deprecated version satisfying the range (empty range: highest stable version) and returns the distribution reference for it.

func (*Index) Search

func (idx *Index) Search(q Query) []Result

Search returns the entries matching q, best first. Ranking per term: exact name > name prefix > name substring > keyword > title > description; ties are broken by publisher/name.

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 Result

type Result struct {
	Entry
	Score int `json:"score"`
}

Result is one search hit.

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.

Jump to

Keyboard shortcuts

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