Files
devvm/internal/backend/usage.go
T
w3cjandClaude Opus 5.5 6128f400e4 refactor(backend): Backend is four role interfaces, and Running replaces StartID, Confined and Lifeline
backend.Backend is Name, Caps and four roles, each required:
- Host: Problems, NameMax, Location, DiskDirs, Floors
- Images: BuildImage, Images, ImageSize, DeleteImage, BuildTools,
  ToolFormat, KeyFiles
- Machines: CreateVM, Start, Running, ProxyURL, Stop, Delete, Rename,
  List, Inspect, Exec, Shell, SSH, ForwardTarget
- Housekeeping: Usage, Strays, DevvmCache, DeleteCache

The optional interfaces Lima implemented (KeyFiles, Storage, Locator,
UsageReporter, StrayFinder, CacheCleaner) are gone into the roles, and
their callers call the methods directly; Forgetter stays the one
optional role, found with backend.As. Running(ctx, vm) returns a
backend.Run (ID, Confined, Lifeline) in place of StartID, Confined and
Lifeline. Space.Check, Space.Warning and LocationOf take a Host.

lima.Lima keeps its fields, Name, Caps and its shared helpers (14
methods), and embeds host, images, machines and housekeeping, each over
the Lima it's part of (withRoles); backendtest.Fake is split the same
way. The guard has every role's methods, its own for the ones it guards.

Structure test: max-methods counts an interface's declared methods too;
Lima and the fake leave largeTypes. Tests: TestRunning, TestGuardRoles,
TestAs (Forgetter), TestFakeRunningAndNone, two TestRulesFail cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:58:19 -07:00

22 lines
683 B
Go

package backend
// Usage is the disk a backend's VMs take on this machine, and its own
// caches, as devvm space shows them (Housekeeping.Usage).
type Usage struct {
// VMs is the disk each of devvm's VMs takes, by name. A VM it can't
// tell is missing.
VMs map[string]int64
// Caches are the backend's own, which devvm's builds fill but which
// can also hold the user's own downloads.
Caches []Cache
}
// Cache is one of a backend's caches.
type Cache struct {
Name string // what it holds, as devvm space shows it
Path string // where it is, "" for one in the backend's engine
Count int // its entries
Size int64 // the disk it takes, when Sized
Sized bool
}