Documentation
¶
Overview ¶
Package disk is a storage-attribution diagnostic for StageFreight: it answers "what operational entity (project / registry / runtime) is consuming disk today" rather than "what folders exist". Scanners build a graph of sized Nodes carrying attribution edges; the renderer and the by-project / reclaim views are projections of that one graph. Read-only.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCacheRoot ¶
func DefaultCacheRoot() string
DefaultCacheRoot is the persistent mount as seen inside a CI job container (/stagefreight). On a runner host it is mounted elsewhere (e.g. /opt/docker/gitlab-runner/stagefreight) — pass that to ScanCacheMount.
func DiscoverCacheRoot ¶
func DiscoverCacheRoot() string
DiscoverCacheRoot locates the persistent cache mount when --cache is not given: the container default (/stagefreight) or, on a runner host, a `…/stagefreight` directory carrying toolchains/ + cache/. Returns "" if none found. (Reading a runner's root-owned mount needs sudo.)
Types ¶
type Attribution ¶
type Attribution struct {
Project string // dragonfly, stagefreight, jetpack
Registry string // ghcr.io, cr.pcfae.com, docker.io
Runtime string // cache-mount, docker-host, docker-dind, repo-tree
Tool string // go, rust, trivy
}
Attribution links a storage node to operational entities — the projection axes. Empty fields mean "not attributable on this dimension".
type Flag ¶
type Flag uint8
Flag marks a node for the two operator-facing concerns: attention and reclaim.
type Hint ¶
type Hint struct {
Command string // "docker buildx prune"
Safety string // "safe", "inspect first", "rebuilds"
}
Hint is the reclaim action surfaced in the ledger.
type Node ¶
type Node struct {
Label string
Path string // absolute, when backed by the filesystem
Bytes int64 // self + descendants
Note string // inline diagnosis: versions, tags, "×6 · avg 1.0G"
Attr Attribution
Flags Flag
Hint *Hint
Kids []*Node
}
Node is one sized location in the graph. Everything is the same shape:
label · TOTAL · note → children (biggest-first)
func ScanCacheMount ¶
ScanCacheMount builds the CACHE MOUNT domain from <root>/cache (rebuildable build/scan caches) and <root>/toolchains (versioned tool installs). Returns nil if neither exists.
func ScanDocker ¶
ScanDocker queries reachable Docker daemons and returns the DOCKER domain, or nil if none reachable. The default socket is the "host" daemon. A "dind" CI-build daemon is reached either via DOCKER_HOST or by auto-discovering a running docker:dind container and querying it through `docker exec`.
type ProjectRow ¶
type ProjectRow struct {
Project string
Bytes int64
Parts []*Node // the contributing nodes, biggest-first
}
ProjectRow is one line of the by-project projection.
type RenderOpts ¶
type RenderOpts struct {
MaxKids int // collapse a node's children beyond this into "+ N more" (0 → 8)
BarWidth int // 0 → 16
}
RenderOpts tunes child caps and bar width. Zero value = the default summary.
type Report ¶
Report is the assembled graph: top-level domains under an implicit root.
func Scan ¶
Scan assembles the full report: the cache mount, the Docker daemon(s), and discovered repositories. The three domains are independent, so they run concurrently — wall-clock is the slowest single domain, not their sum. Any domain that finds nothing is omitted. (Docker carries ctx's deadline and starts at t=0 alongside the walks, so the slow cache walk can't starve it.)
func (*Report) ByProject ¶
func (r *Report) ByProject() []ProjectRow
ByProject groups attributed nodes by project. Attribution emerges from independent scanners agreeing on the project key — nobody computes the rollup.
func (*Report) Reclaimable ¶
Reclaimable is the reclaim-ledger projection: every node flagged reclaimable, biggest-first, deduplicated to the highest reclaimable ancestor (we never list both a parent and its child).