mountset

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 23 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 mountset is the set of mounts an agni server or CLI serves, over goapplib storage's mounts registry (agni issue 1759). It reads the --mount and --mount-root flags into fixed folder mounts, keeps the runtime mounts CreateMount makes in --store, resolves a mount:// URI to a host path for the OS-backed adapters, and maps the library's errors onto agni's service errors. The library keeps every path inside its mount. The package is outside internal/ so an embedder can serve the same mounts (C13), and so the datasheet service, a module of its own, can import it (agni issue 744).

Index

Constants

View Source
const BlobsDir = "blobs"

BlobsDir is the folder under --uploads that holds every blob, laid out as goapplib's blobs.Dir keeps them.

View Source
const RecordsDir = "mounts"

RecordsDir is the folder under --store that holds one record per runtime mount.

View Source
const SnapshotsDir = "mounts"

SnapshotsDir is the folder under --uploads that holds the views of runtime mounts. A view is <uploads>/mounts/<name>/<commit>/, hard links to the blobs laid out as the source had them.

Variables

This section is empty.

Functions

func Discover

func Discover(root string) ([]mounts.Mount, error)

Discover turns each immediate SUBDIRECTORY of root into a mount named after it, so a container can expose design folders by bind-mounting them under one path with no flags (`-v ~/boards:/workspace/boards`). Parse is the explicit half, and Merge combines the two.

A missing root is NOT an error and returns no mounts, because the container always passes --mount-root and one with nothing bind-mounted should still start. A root that is a file is an error. Order is os.ReadDir's (sorted by filename), so ListMounts is stable across restarts. Non-directories and dotfiles (.DS_Store, .git) are skipped.

func Err

func Err(err error) error

Err maps an error from goapplib's storage module onto agni's service errors, so the transport classifies it as it classifies agni's own. An error that wraps none of the library's sentinels passes through unchanged. The message is kept.

func Find

func Find(ms []mounts.Mount, name string) (mounts.Mount, bool)

Find returns the mount with the given name from a set of mounts.

func Folder

func Folder(name, dir string) mounts.Mount

Folder is the fixed mount that serves dir, an absolute path, as name.

func Merge

func Merge(discovered, explicit []mounts.Mount) []mounts.Mount

Merge combines discovered mounts with explicitly configured ones. Explicit wins a name collision. The operator typed --mount for this run, and a discovered mount is whatever sat under the mount root. Order is discovered then explicit, so ListMounts is stable.

func Parse

func Parse(specs []string) ([]mounts.Mount, error)

Parse turns repeated `name=path` flag values into fixed folder mounts, each path resolved to an absolute directory. It rejects an empty name or path, a duplicate name, or a path that is not an existing directory. Order is preserved so ListMounts reflects the command line.

Types

type Config

type Config struct {
	// Fixed are the mounts from the flags, in the order ListMounts shows them.
	Fixed []mounts.Mount
	// Uploads is the --uploads folder, "" for none. With Records, it holds runtime mounts' blobs and
	// views.
	Uploads string
	// UploadsMount names the fixed mount that serves the uploaded designs, which a link can't name.
	UploadsMount string
	// Records is the folder of runtime mount records under --store, "" for none.
	Records string
	// Connections is the folder of connection records under --store, "" for none. A runtime mount
	// naming a connection reads its source with that connection's token (agni issue 1724).
	Connections string
	// GitHubAPI and GitHubRaw are GitHub's API root and raw host, set by a test or for GitHub
	// Enterprise. Empty takes the library's defaults.
	GitHubAPI, GitHubRaw string
	// Limits caps a snapshot or a link. Zero takes the library's default of 256 MB and 100,000 files.
	Limits mounts.Limits
	// ReadOnly opens the records and blobs for reading alone, as agnids does over a store agni
	// serve writes. Open then neither rewrites old records nor builds snapshot views.
	ReadOnly bool
	// Log gets a line for each old record Open rewrites or can't, and each view it can't build.
	Log io.Writer
}

Config says what a Table serves.

type Table

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

Table is a server's live mount list over goapplib's mounts registry (agni issues 1735, 1759). The mounts from its flags are fixed. With Records and Uploads it also serves the GitHub mounts CreateMount made, each a record in --store, and every process sharing the store sees them within a second. Every OS-backed adapter resolves through a Table, so a mount made at runtime is reachable at once.

func NewTable

func NewTable(fixed ...mounts.Mount) *Table

NewTable returns a table serving fixed and nothing else, for the CLI and for a server with no store.

func Open

func Open(cfg Config) (*Table, error)

Open returns the table cfg describes. With Records and Uploads it first rewrites any record an older agni wrote (see migrate).

func (*Table) Blobs

func (t *Table) Blobs() *blobs.Dir

Blobs is the blob store under --uploads, nil without one.

func (*Table) Connections

func (t *Table) Connections() connections.Store

Connections is the store of connection records, nil for a table with none.

func (*Table) CreateMount

func (t *Table) CreateMount(ctx context.Context, name, source, ref, connection string) (service.MountInfo, error)

CreateMount snapshots a github://<owner>/<repo> source at ref and serves it as name. A file:// source is refused, because a client must not choose which folder on the server's disk is served.

func (*Table) DeleteMount

func (t *Table) DeleteMount(ctx context.Context, name string) error

DeleteMount forgets a runtime mount and removes its views. Its blobs stay until a sweep finds nothing naming them.

func (*Table) Find

func (t *Table) Find(name string) (mounts.Mount, bool)

Find returns the mount named name.

func (*Table) Fixed

func (t *Table) Fixed(name string) bool

Fixed reports whether name is a mount from the flags.

func (*Table) Info

func (t *Table) Info(m mounts.Mount) service.MountInfo

Info is m as the service port describes it.

func (*Table) List

func (t *Table) List() []mounts.Mount

List returns every mount the table serves: the fixed ones in configuration order, then the runtime ones by name. A store that fails after a good read keeps the last good list.

func (*Table) MountsUsing

func (t *Table) MountsUsing(_ context.Context, id string) ([]string, error)

MountsUsing names the runtime mounts that read through the connection id, sorted, so a connection in use isn't deleted under them.

func (*Table) Readers

func (t *Table) Readers(ctx context.Context, name string) (service.MountReader, error)

Readers is the service.MountReaders a linked artifact reads through (agni issues 1723, 1759). Each reader is the registry's ResolveAt, ListAt and FetchAt for one mount. A GitHub mount lists a commit's files with their git blob ids and downloads only what the blobs lack. A folder from the flags is read as it is now. The uploads mount holds uploaded files and can't be linked.

func (*Table) Registry

func (t *Table) Registry() *mounts.Registry

Registry is the goapplib registry the table serves from.

func (*Table) Resolve

func (t *Table) Resolve(uri mounts.URI) (string, error)

Resolve maps uri to a host path inside its mount, for the OS-backed adapters. An unknown mount is service.ErrNotFound and a path that leaves its mount is service.ErrInvalidPath. A path may run into an archive, which archivefs reads as a folder (agni issue 1591). The library resolves the archive file, and the rest of the path is joined on for archivefs to read.

func (*Table) Root

func (t *Table) Root(m mounts.Mount) string

Root returns the host folder m serves from: a folder mount's own path, or a GitHub snapshot's view, built on first use. It returns "" for a mount with no folder here.

type Workspace

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

Workspace is the OS-backed service.Workspace over a mount table. It resolves a URI to a host path with Resolve, which keeps it inside the mount root, and lists it with archivefs.OSReadDir, which lists an archive as a folder. Both the engine's server and the datasheet service list folders through it (agni issue 744).

func NewWorkspace

func NewWorkspace(t *Table) *Workspace

NewWorkspace lists folders inside the mounts t serves, including any made at runtime.

func (*Workspace) ListDir

func (w *Workspace) ListDir(_ context.Context, uri mounts.URI) ([]service.DirEntry, error)

ListDir resolves the URI and reads one directory level. The service maps an error wrapping service.ErrInvalidPath to InvalidArgument. It maps any other error to NotFound, including an unknown mount or a missing directory.

func (*Workspace) Mounts

func (w *Workspace) Mounts() []service.MountInfo

Mounts returns the served mounts as the port's runtime-neutral MountInfo.

func (*Workspace) ReadFile

func (w *Workspace) ReadFile(_ context.Context, uri mounts.URI) ([]byte, error)

ReadFile reads one file inside its mount, for service.FileReader. A directory is an error.

Jump to

Keyboard shortcuts

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