Documentation
¶
Overview ¶
Package cli holds the conventions every ossein command-line binary follows — the process logger, the --log-level vocabulary, the exit-status convention, the spelling of "the whole host" on --cpus and --memory — so that ossein and its docker-shaped front (cmd/ossein-docker) behave as one product without either importing the other's main package.
Index ¶
Constants ¶
const ExitInternal = 125
ExitInternal is docker's runtime-error exit convention (125): a failure of the tool itself must be distinguishable from a workload that exited 1.
const LogLevels = "debug,info,warn,error"
LogLevels is the accepted --log-level vocabulary, for kong's enum tag. Keep it in sync with NewLogger's switch: the enum is what admits a name, the switch is what it means.
const WholeHost = 0
WholeHost is the --cpus / --memory value that means "everything the host has": docker's own spelling of no limit, and what the docker-shaped front passes when a script sizes nothing. ossein resolves it against what Virtualization.framework allows (pkg/vm HostMaxCPUs, HostMaxMemory); the front never computes it, because only the side that links the framework knows the ceiling.
Variables ¶
var ErrSizeUnit = errors.New("a size needs a unit")
ErrSizeUnit is a size flag given a number with no unit.
Functions ¶
func FormatSize ¶ added in v0.3.0
FormatSize writes size as a count of bytes with its unit, which ParseSize reads back exactly.
func NewLogger ¶
NewLogger installs the process slog logger via primordium: a human-friendly tint handler when stderr is a TTY, structured JSON otherwise. Diagnostics go to stderr; stdout is reserved for machine-readable contracts (BUILDKIT_HOST, digests, version). level is a --log-level value already validated by the kong enum (LogLevels). It returns the installed default logger so the caller can inject it into command Run methods.
func ParseSize ¶ added in v0.3.0
ParseSize reads a size flag in bytes: a number and a unit, "4GiB", "512MiB", "1.5GB", as human.ParseSize reads it (kB to EB count powers of 1000, KiB to EiB powers of 1024, in any case). A bare number is ErrSizeUnit unless it is zero, which is the same in every unit: --memory counted MiB before it took units, and "512" read as bytes would shrink a guest 2^20-fold in silence.
Types ¶
This section is empty.