cli

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 8 Imported by: 0

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

View Source
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.

View Source
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.

View Source
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

View Source
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

func FormatSize(size uint64) string

FormatSize writes size as a count of bytes with its unit, which ParseSize reads back exactly.

func NewLogger

func NewLogger(level string) *slog.Logger

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

func ParseSize(value string) (uint64, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL