Documentation
¶
Overview ¶
Package workspace decides where a local workspace folder is mounted in a single-container devcontainer and which container folder is its workspace folder. It follows upstream's getWorkspaceConfiguration (src/spec-node/utils.ts) and reads the host file system only; it never runs git. Compose configurations own their mounts and do not use this package.
Index ¶
Constants ¶
const ( ConsistencyConsistent = "consistent" ConsistencyCached = "cached" ConsistencyDelegated = "delegated" )
Consistency values accepted for bind mounts on Docker Desktop hosts.
Variables ¶
This section is empty.
Functions ¶
func GitRoot ¶
GitRoot returns the top folder of the Git working tree that contains folder, or "" when folder is not inside one. It follows Git's discovery without running git: walking up lexically (so symlinked names are kept, as upstream's `git rev-parse --show-cdup` result is), a .git folder that is a repository marks the root; a .git file marks the root when its gitdir is a repository, and otherwise ends discovery, as Git refuses an invalid gitfile. Environment overrides such as GIT_DIR and GIT_CEILING_DIRECTORIES and Git's ownership check are not applied.
func MountedFolder ¶
MountedFolder returns the container folder at which an existing container shows localWorkspace: the destination of the bind mount whose source is the workspace or its nearest mounted ancestor, with the rest of the workspace path below it. That is where the container placed the workspace, whatever options created it. It returns "" when no bind mount contains the workspace.
Types ¶
type Bind ¶
type Bind struct {
Source, Destination string
}
Bind is an existing container's bind mount: the host source and the container destination, as the Engine reports them.
type Configuration ¶
type Configuration struct {
// WorkspaceFolder is the container workspace folder, or "" when the
// configuration sets workspaceFolder itself.
WorkspaceFolder string
// WorkspaceMount is the workspace bind mount, or nil when the
// configuration declares workspaceMount.
WorkspaceMount *Mount
// AdditionalMount is the linked worktree's common Git folder, if mounted.
AdditionalMount *Mount
}
Configuration is the resolved workspace placement.
func Resolve ¶
func Resolve(localWorkspace string, hasWorkspaceFolder, hasWorkspaceMount bool, opts Options) (Configuration, error)
Resolve places localWorkspace (an absolute host folder). hasWorkspaceFolder and hasWorkspaceMount report whether the configuration declares those properties; when it declares both, nothing is derived.
type Mount ¶
type Mount struct {
Source, Target, Consistency string
}
Mount is a bind mount from a host folder to a container folder.
type Options ¶
type Options struct {
// MountGitRoot mounts the top folder of the workspace's Git working tree
// in place of the workspace folder (upstream default true).
MountGitRoot bool
// MountGitWorktreeCommonDir also mounts the common Git folder of a linked
// worktree whose .git file holds a relative gitdir, so Git works in the
// container. It applies only with MountGitRoot.
MountGitWorktreeCommonDir bool
// Consistency is set on the bind mounts on hosts other than Linux. Empty
// means consistent.
Consistency string
// Platform is the host's GOOS. Linux mounts carry no consistency option,
// as upstream omits it there.
Platform string
}
Options select how the workspace is mounted.
func (Options) BindConsistency ¶
BindConsistency is the consistency option for these options' bind mounts: none on Linux, otherwise Consistency or consistent.