Documentation
¶
Overview ¶
Package stack derives everything about a stack that follows from its worktree and its compose file without asking Docker: names, labels, routes and the override siding writes. Everything here is a pure function.
Index ¶
Constants ¶
const ( LabelRepo = "dev.siding.repo" LabelBranch = "dev.siding.branch" LabelWorktree = "dev.siding.worktree" LabelMachine = "dev.siding.machine" LabelAgent = "dev.siding.agent" LabelGitDir = "dev.siding.gitdir" LabelBudget = "dev.siding.budget" LabelBuilds = "dev.siding.builds" LabelIdle = "dev.siding.idle" // LabelHostAlias, on siding-proxy, is what host.docker.internal resolves to in it. LabelHostAlias = "dev.siding.host-alias" LabelRoute = "dev.siding.route" LabelPort = "dev.siding.port" // LabelProject is Compose's own label naming a container's project. LabelProject = "com.docker.compose.project" // LabelService is Compose's own label naming a container's service. LabelService = "com.docker.compose.service" )
Labels siding puts on what it creates. The conventions in CLAUDE.md list them.
const OverrideFile = ".siding/override.yml"
OverrideFile is where siding writes the override, relative to the worktree.
const ProxyNetworkKey = "siding_proxy"
ProxyNetworkKey is the key of the proxy network in the override. It differs from every network name a user is likely to pick, so the override never redefines one of theirs.
const ServiceHeader = "X-Siding-Service"
ServiceHeader is the response header every siding router adds, naming <project>/<service>. A response that carries it came from the service, not from the proxy (design D9).
Variables ¶
This section is empty.
Functions ¶
func DotEnvValues ¶
DotEnvValues returns the values a .env file defines, read with Compose's rules: KEY=VALUE per line, an optional "export ", comments starting with #, single or double quotes.
func MachineID ¶
MachineID returns the stable id for dev.siding.machine: a one-way hash of the operating system's machine id, so the raw id never appears in a label. Without one it uses, and on first use writes, a random id in <home>/.siding/machine-id.
func OSMachineID ¶
func OSMachineID() string
OSMachineID returns the operating system's machine id: /etc/machine-id on Linux, the platform UUID on macOS, or "" when there is none.
Types ¶
type Identity ¶
type Identity struct {
Repo string // repository name, e.g. shop
Branch string // branch name, e.g. feature/login
Worktree string // absolute path of the worktree
Machine string // stable machine id
Agent string // optional agent name
// GitDir is the repository's common git directory, so gc can still ask git about the branch
// when the worktree is gone.
GitDir string
}
Identity names one stack.
func FromLabels ¶
FromLabels reads an Identity back from a container's labels.
func (Identity) BranchSlug ¶
BranchSlug is the slug of the branch.
func (Identity) ContainerLabels ¶
ContainerLabels are the labels of the stack's containers: Labels plus the git directory and the agent, if any. Those two stay off networks and volumes: they are new in v0.2 or change between ups, and Compose recreates a network whose labels changed.
func (Identity) Labels ¶
Labels are the labels of the stack's networks and volumes. They never change between two ups of one project: Compose recreates a network whose labels changed.
func (Identity) ServiceHost ¶
ServiceHost is the host of one service, <service>.<repo-slug>.<branch-slug>.localhost.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor replaces known secret values in log lines with ***.
func NewRedactor ¶
NewRedactor redacts the given values except short ones, numbers and booleans.
type Route ¶
type Route struct {
Service string
// Port is the container port the proxy sends requests to.
Port int
// Path is the service's path on the stack's host ("/" for the root), or "" when it has
// only its service host.
Path string
}
Route says how the proxy reaches one HTTP service.