Documentation
¶
Overview ¶
Package mounts is the containment boundary of the web tier, the named root folders the server exposes plus the join that keeps every client-supplied path inside its mount. Mounts are checked against the filesystem at parse time. It lives outside cmd/agni so any entrypoint hosting the serve services reuses the same boundary, and outside internal/ because one of those entrypoints, the datasheet service, is in a module of its own (agni issue 744).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Resolve ¶
Resolve maps an artifact URI to an absolute host path inside its mount, for the OS-backed service adapters. An unknown mount returns service.ErrNotFound, so the service classifies without importing os. Containment is decided by artifact.Parse, and a parsed URI cannot escape its mount, so the SafeResolve call below is only an assertion.
func SafeResolve ¶
SafeResolve joins a mount-relative path onto root and confirms the result stays inside root, returning the cleaned absolute path. It rejects absolute inputs and any path that escapes the mount via "..". Resolve is its only non-test caller.
Types ¶
type Mount ¶
Mount is one configured root folder the web API serves. Name is the handle a client passes back to address the mount, and Root is the resolved absolute host path. Clients never send absolute paths. They send an artifact.URI naming a mount and a mount-relative path, which Resolve joins. The OS-backed service adapters in cmd/agni hold these, and the service package stays os-free (CONSTRAINTS C13).
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. The subdirectories are the mounts rather than root, so each folder keeps its own handle in ListMounts.
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 Merge ¶
Merge combines discovered mounts with explicitly configured ones. Explicit wins a name collision, since --mount is what the operator typed for this run and a discovered mount is whatever sat under the mount root. Order is discovered then explicit, so ListMounts stays stable.
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 os.ReadDir. Both the engine's server and the datasheet service list folders through it (agni issue 744).
func NewWorkspace ¶
NewWorkspace lists folders inside ms, the mount table a server was started with.
func (*Workspace) ListDir ¶
ListDir resolves the URI and reads one directory level. The service maps an error wrapping service.ErrInvalidPath to InvalidArgument and any other, including an unknown mount or a missing directory, to NotFound.