artifact

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 3 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 artifact defines how the engine NAMES a stored artifact. An artifact is a design, a board export, a datasheet, a checklist, or anything else the injected Loader resolves to bytes.

A name is one string, in one field.

mount://boards/designs/gateway/gateway.edn

It replaces a `(mount, path)` pair that 24 request messages carried as two fields (#179).

Why the authority is always `mount`

Not `s3://` or `db://`. The authority is the mount NAME, a key in a server-defined namespace, and the deployment decides what it resolves to. A per-store scheme would put the storage kind in the client's hands. The Loader and ProjectStore ports exist to prevent that.

Why a URI rather than a path

The mount is the containment boundary and `..` cannot escape it. Related files resolve against each other through one specified operation, such as a KiCad schematic naming its sub-sheets or a symbol library referenced from inside a file. A URI path is always slash-separated. `formats.Loader` warns about a platform-separator split, and that split cannot break a sibling lookup on Windows.

Grouping is NOT expressed here. A design's relationship to its board companion is DECLARED in a `design.yaml`, not encoded in a path or inferred from a stem.

Index

Constants

View Source
const Scheme = "mount"

Scheme is the only scheme an artifact URI uses. See the package doc for why it is fixed.

Variables

This section is empty.

Functions

This section is empty.

Types

type URI

type URI struct {
	// Mount is the authority, a key in a server-defined namespace and never a host path.
	Mount string
	// Path is the mount-relative path, cleaned, slash-separated, with no leading slash. The mount
	// ROOT is the empty string. A directory listing of a whole mount asks for that path.
	Path string
}

URI is a parsed artifact URI. It holds its mount and the mount-relative path within that mount.

A parsed URI is a CONTAINED one. Parse rejects anything that escapes its mount, so callers can pass a value of this type around without re-checking containment.

func New

func New(mount, p string) (URI, error)

New builds a URI from a mount and a mount-relative path, applying the same containment rules as Parse. Code holding the two halves calls it, such as an adapter reading a config flag or a test. That code then cannot assemble a string that Parse would reject.

func Parse

func Parse(s string) (URI, error)

Parse reads an artifact URI.

Parse refuses a bare path, an absolute path, a different scheme, and a path escaping its mount. Each is an error rather than a best-effort reading, because this is the containment boundary. A permissive parse here is a path traversal everywhere above it. The error names the broken rule, since these arrive from a wire and a client needs to fix its own call.

func (URI) Base

func (u URI) Base() string

Base returns the final path element, the way path.Base does, and "" for a mount root.

func (URI) Dir

func (u URI) Dir() URI

Dir returns the URI of the directory containing this one, or the mount root for a top-level entry.

func (URI) IsZero

func (u URI) IsZero() bool

IsZero reports whether the URI names nothing. An absent optional field reads as a zero URI.

func (URI) Join

func (u URI) Join(elem ...string) (URI, error)

Join returns the URI of a child of this one.

func (URI) Resolve

func (u URI) Resolve(rel string) (URI, error)

Resolve returns the URI naming `rel` interpreted RELATIVE to this one, the way a browser resolves a relative href against the page it is on.

A reader calls this when a schematic names its sub-sheets or a symbol library. A reference is resolved against this URI's DIRECTORY, so resolving "sub/sheet1.kicad_sch" against ".../designs/gateway/gateway.kicad_sch" yields ".../designs/gateway/sub/sheet1.kicad_sch".

A result outside the mount is an error, so a file naming "../../etc/passwd" cannot leave the mount it was read from.

func (URI) String

func (u URI) String() string

String renders the URI. It round-trips with Parse.

Jump to

Keyboard shortcuts

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