workspace

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package workspace defines workspace values and detached storage locations.

Index

Constants

View Source
const (
	CurrentManifestVersion = 1
)

Variables

View Source
var (
	ErrInvalidManifest     = errors.New("workspace manifest is invalid")
	ErrManifestNotFound    = errors.New("workspace manifest was not found")
	ErrManifestConflict    = errors.New("workspace manifest binds a different workspace")
	ErrInvalidRepositoryID = errors.New("repository identity is invalid")
)
View Source
var (
	ErrInvalidName = errors.New("workspace name is invalid")
	// ErrInvalidID reports a workspace identity that does not match the
	// manifest format.
	ErrInvalidID = errors.New("workspace identity is invalid")
)
View Source
var (
	ErrWorkspaceNotRegistered = errors.New("workspace is not registered")
	ErrWorkspaceExists        = errors.New("workspace already exists")
	ErrInvalidRegistry        = errors.New("workspace registry is invalid")
)
View Source
var (
	// ErrInvalidStorageRoot reports a configured XDG data root that is not an
	// absolute filesystem path.
	ErrInvalidStorageRoot = errors.New("workspace storage root is invalid")
	// ErrStorageRootUnavailable reports that the operating system did not
	// provide the home directory needed for its default storage location.
	ErrStorageRootUnavailable = errors.New("workspace storage root is unavailable")
)

Functions

func FindWorkspaceByID added in v0.0.8

func FindWorkspaceByID(root string, id ID) (string, error)

FindWorkspaceByID resolves a manifest's immutable workspace identity to its detached repository state.

func ManifestPath added in v0.0.8

func ManifestPath(repositoryRoot string) (string, error)

ManifestPath returns the checkout-owned manifest path.

func RepositoryPath

func RepositoryPath(storageRoot string, id ID) (string, error)

RepositoryPath returns the deterministic detached repository directory for id below storageRoot. It performs no filesystem access or symlink resolution.

func StorageRoot

func StorageRoot() (string, error)

StorageRoot returns Spool's platform-appropriate detached storage root.

XDG_DATA_HOME, when configured, takes precedence on every platform. Unix defaults to the XDG data location; Windows uses its conventional per-user application-data location when no XDG override is present.

func UpdateRegistry

func UpdateRegistry(root string, update func(*Registry) error) (err error)

UpdateRegistry serializes catalog provisioning updates.

func WriteManifest added in v0.0.8

func WriteManifest(repositoryRoot string, manifest Manifest) (err error)

WriteManifest atomically writes a validated checkout manifest. Existing local repository control state is never overwritten.

Types

type ID

type ID string

ID identifies a workspace independently of checkout paths and names.

func NewID

func NewID() (ID, error)

NewID creates a random durable workspace identity.

func (ID) Validate

func (id ID) Validate() error

Validate reports whether id matches the workspace-ID format.

type Manifest added in v0.0.8

type Manifest struct {
	FormatVersion int    `toml:"format_version"`
	RepositoryID  string `toml:"repository_id"`
	WorkspaceID   ID     `toml:"workspace_id"`
}

Manifest declares the portable workspace binding for a checkout.

func DiscoverManifest added in v0.0.8

func DiscoverManifest(workingDirectory string) (repositoryRoot string, manifest Manifest, found bool, err error)

DiscoverManifest searches workingDirectory and its ancestors for a workspace manifest. A local Spool repository config without workspace_id is ignored.

func (Manifest) Validate added in v0.0.8

func (manifest Manifest) Validate() error

Validate rejects host paths and incomplete or unsupported manifest data.

type Name

type Name string

Name is the user-selected name used only for explicit workspace provisioning.

func ParseName

func ParseName(value string) (Name, error)

ParseName validates the explicit provisioning name.

func (Name) Validate

func (name Name) Validate() error

type Registry

type Registry struct {
	Version    int                `toml:"version"`
	Workspaces map[Name]Workspace `toml:"workspaces"`
}

Registry is the central detached-state catalog. Names are used solely by explicit provisioning commands; checkout resolution uses only workspace IDs.

func LoadRegistry

func LoadRegistry(root string) (Registry, error)

type Workspace

type Workspace struct {
	ID       ID     `toml:"id"`
	StateDir string `toml:"state_dir"`
}

Jump to

Keyboard shortcuts

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