Documentation
¶
Overview ¶
Package drift compares a resolved plan against the live system. All checks are read-only probes; nothing is installed, written, or ensured.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render writes the drift report. Sections appear in fixed order and only when they have ≥1 finding. Non-OK findings print as ` <module>: <item> — <detail>`; the owning module replaces the status prefix (drift is implied for listed items; unknown items get a (?) suffix). A section whose findings are all OK prints ` ok: all N checks passed`. On a TTY, finding lines are colored by issue type: orange (missing/version drift), red (not-a-symlink/unknown), yellow (content differs). The final line is `no drift` when nothing drifted, otherwise `drift: N item(s)` with `, K unknown` appended when there are unknowns.
Types ¶
type CheckOptions ¶
type CheckOptions struct {
// Jobs bounds concurrent probe workers; <= 0 uses runtime.NumCPU().
Jobs int
// Verbose, when non-nil, receives one "checking <section>: <item>" line
// per probe as it starts. Writes are serialized internally.
Verbose io.Writer
}
CheckOptions controls how Check runs its probes.
type Finding ¶
type Finding struct {
Section string // "packages" | "tools" | "dotfiles" | "mounts" | "smb"
Item string // package name, tool name, target path, unit name, share name
Status Status
Detail string
Module string // owning module ID (empty if unknown)
}
Finding is one checked item. Detail is empty for OK.
func Check ¶
func Check(ctx context.Context, plan *resolve.Plan, profileRoot string, pr Probes, opts CheckOptions) []Finding
Check runs every read-only probe for the plan concurrently (bounded by opts.Jobs; <= 0 → runtime.NumCPU) and returns findings in fixed section order (packages → tools → dotfiles → mounts → smb). Each worker writes only its own indexed result slot, so output order is deterministic regardless of completion order. opts.Verbose, when non-nil, receives one "checking <section>: <item>" line per probe as it starts. A nil plan returns nil.
type Probes ¶
type Probes struct {
IsInstalled func(ctx context.Context, pkg string) (bool, error)
ToolCurrent func(ctx context.Context, tool string) (string, error) // err or "" → Unknown
Run func(ctx context.Context, name string, args ...string) (string, error)
HomeDir string
Readlink func(path string) (string, error)
ReadFile func(path string) ([]byte, error)
StatDir func(path string) (bool, error) // exists and is a directory
}
Probes are the side-effect seams. DefaultProbes fills OS-backed defaults; tests override individual fields. IsInstalled and ToolCurrent have no generic OS default (they need a package backend / mise) and must be set by the caller before Check.
func DefaultProbes ¶
func DefaultProbes() Probes
DefaultProbes returns OS-backed probes for Run, Readlink, ReadFile, StatDir, and HomeDir. IsInstalled and ToolCurrent are left nil — wire them to a package backend and mise before calling Check.