mounts

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 7 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 mounts is the containment boundary of the web tier. It holds the named root folders the server exposes, and the join that keeps every client-supplied path inside its mount. Mounts are checked against the filesystem at parse time. The package is outside cmd/agni so any entrypoint hosting the serve services reuses the same boundary. It is 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

func Resolve(mounts []Mount, uri artifact.URI) (string, error)

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. artifact.Parse decides containment, and a parsed URI cannot escape its mount, so the SafeResolve call below is only an assertion.

func SafeResolve

func SafeResolve(root, rel string) (string, error)

SafeResolve joins a mount-relative path onto root and confirms the result is 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

type Mount struct {
	Name string
	Root string
}

Mount is one configured root folder the web API serves. A client passes Name 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, so the service package can be os-free (CONSTRAINTS C13).

func Discover

func Discover(root string) ([]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. The subdirectories are the mounts rather than root, so each folder has 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 Find

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

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

func Merge

func Merge(discovered, explicit []Mount) []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) ([]Mount, error)

Parse turns repeated `name=path` flag values into validated 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.

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

func NewWorkspace(ms []Mount) *Workspace

NewWorkspace lists folders inside ms, the mount table a server was started with.

func (*Workspace) ListDir

func (w *Workspace) ListDir(_ context.Context, uri artifact.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 configured mounts as the port's runtime-neutral MountInfo.

func (*Workspace) ReadFile

func (w *Workspace) ReadFile(_ context.Context, uri artifact.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