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
- func Discover(root string) ([]mounts.Mount, error)
- func Err(err error) error
- func Find(ms []mounts.Mount, name string) (mounts.Mount, bool)
- func Folder(name, dir string) mounts.Mount
- func Merge(discovered, explicit []mounts.Mount) []mounts.Mount
- func Parse(specs []string) ([]mounts.Mount, error)
- type Config
- type Table
- func (t *Table) Blobs() *blobs.Dir
- func (t *Table) Connections() connections.Store
- func (t *Table) CreateMount(ctx context.Context, name, source, ref, connection string) (service.MountInfo, error)
- func (t *Table) DeleteMount(ctx context.Context, name string) error
- func (t *Table) Find(name string) (mounts.Mount, bool)
- func (t *Table) Fixed(name string) bool
- func (t *Table) Info(m mounts.Mount) service.MountInfo
- func (t *Table) List() []mounts.Mount
- func (t *Table) MountsUsing(_ context.Context, id string) ([]string, error)
- func (t *Table) Readers(ctx context.Context, name string) (service.MountReader, error)
- func (t *Table) Registry() *mounts.Registry
- func (t *Table) Resolve(uri mounts.URI) (string, error)
- func (t *Table) Root(m mounts.Mount) string
- type Workspace
Constants ¶
const BlobsDir = "blobs"
BlobsDir is the folder under --uploads that holds every blob, laid out as goapplib's blobs.Dir keeps them.
const RecordsDir = "mounts"
RecordsDir is the folder under --store that holds one record per runtime mount.
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 ¶
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 ¶
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 Merge ¶
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.
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 ¶
NewTable returns a table serving fixed and nothing else, for the CLI and for a server with no store.
func Open ¶
Open returns the table cfg describes. With Records and Uploads it first rewrites any record an older agni wrote (see migrate).
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 ¶
DeleteMount forgets a runtime mount and removes its views. Its blobs stay until a sweep finds nothing naming them.
func (*Table) List ¶
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 ¶
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 ¶
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) Resolve ¶
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.
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 ¶
NewWorkspace lists folders inside the mounts t serves, including any made at runtime.
func (*Workspace) ListDir ¶
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.