Documentation
¶
Index ¶
- Constants
- func CachePath(elem ...string) (string, error)
- func EnsureLogReadable(path, what, name string) error
- func HasEntitlement(key string) bool
- func OwnCodeRequirement() (string, error)
- func PrivateSize(path string) (int64, error)
- func ProcessAlive(pid int) bool
- func StreamLogFile(path string, out io.Writer, opts TailOptions) error
- type Logger
- type TailOptions
Constants ¶
const ( LvlTrace = iota LvlInfo LvlWarn LvlError )
Log level constants — numeric for comparison, string labels for output.
const EntitlementHostNetworking = "com.apple.vm.networking"
EntitlementHostNetworking is the entitlement Apple requires for using VZBridgedNetworkDeviceAttachment (i.e. host/bridged network mode).
Variables ¶
This section is empty.
Functions ¶
func CachePath ¶
CachePath returns a path under the monolith root, ~/.monolith. It does not create anything.
func EnsureLogReadable ¶
EnsureLogReadable returns a friendly error if the log file is missing.
func HasEntitlement ¶
HasEntitlement reports whether the currently running binary has been codesigned with the given entitlement key set to true.
The result is cached for the lifetime of the process. On any error reading the signature (binary not signed, codesign missing, etc.) it returns false. This is intended for best-effort pre-flight checks; the authoritative enforcement happens inside Virtualization.framework at VM startup.
func OwnCodeRequirement ¶
OwnCodeRequirement returns a code signing requirement that matches only the currently running binary (`cdhash H"<hash>"`). Network daemons and VM daemons run the same binary, so each side uses this to authenticate the other when sharing a vmnet network over XPC. Rebuilding or re-signing the binary changes the hash, so daemons from an older build won't match.
func PrivateSize ¶
PrivateSize is the space a file takes that isn't shared with APFS clones of it: for a container's disk, what the container wrote on top of its image (what removing it gives back). du and stat count shared blocks too.
func ProcessAlive ¶
ProcessAlive checks if a process with the given PID is still running. On Unix, sending signal 0 to a process checks for existence without actually sending a signal.
func StreamLogFile ¶
func StreamLogFile(path string, out io.Writer, opts TailOptions) error
StreamLogFile prints the contents of the log file at path to out, with optional tail/follow semantics analogous to `tail -F`. When Follow is true, it keeps reading the file as the daemon appends to it. The function exits when out returns an error (e.g. the user closes stdout) or, if Follow is false, after the existing content has been written.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes structured log lines with timestamps and levels. It supports multiple output sinks, each with an independent minimum level. It is safe for concurrent use.
func (*Logger) AddSink ¶
AddSink adds an additional output writer that receives messages at or above minLevel.
type TailOptions ¶
type TailOptions struct {
// Lines is the number of trailing lines to print before streaming.
// Zero means "print everything from the start of the file".
// A negative value means "skip the existing backlog entirely".
Lines int
// Follow keeps reading new content appended to the file until ctx
// is cancelled or the writer to out returns an error.
Follow bool
}
TailOptions controls how StreamLogFile reads a log file.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
container
Package container implements `monolith container`: each container runs in its own small VM (Kata's kernel, monolith-init as PID 1, the image's filesystem as root), in the style of Apple's container tool.
|
Package container implements `monolith container`: each container runs in its own small VM (Kata's kernel, monolith-init as PID 1, the image's filesystem as root), in the style of Apple's container tool. |
|
docker
Package docker implements `monolith docker`: container host VMs for the docker CLI (docker engine) or nerdctl (containerd engine), in the style of Colima.
|
Package docker implements `monolith docker`: container host VMs for the docker CLI (docker engine) or nerdctl (containerd engine), in the style of Colima. |
|
sandbox
Package sandbox implements `monolith sandbox`: run a repo's commands in a lith, isolated from the Mac, the way a virtualenv scopes a project.
|
Package sandbox implements `monolith sandbox`: run a repo's commands in a lith, isolated from the Mac, the way a virtualenv scopes a project. |
|
cmd
|
|
|
monolith
command
|
|
|
monolith-init
command
monolith-init is PID 1 of a container VM (`monolith container`).
|
monolith-init is PID 1 of a container VM (`monolith container`). |
|
Package containerinit is shared by monolith-init, the PID 1 of container VMs (cmd/monolith-init), and the daemon that runs them: the container's process spec and the logic that turns an image's config into a process (command, user, environment, PATH lookup, signals).
|
Package containerinit is shared by monolith-init, the PID 1 of container VMs (cmd/monolith-init), and the daemon that runs them: the container's process spec and the logic that turns an image's config into a process (command, user, environment, PATH lookup, signals). |
|
agentpb
Code generated by protoc-gen-go-ttrpc.
|
Code generated by protoc-gen-go-ttrpc. |
|
internal
|
|
|
ansi
Package ansi has the terminal helpers shared by monolith's live views: whether to colour, SGR painting, the terminal's width, and turning raw console output into plain text.
|
Package ansi has the terminal helpers shared by monolith's live views: whether to colour, SGR painting, the terminal's width, and turning raw console output into plain text. |
|
steps
Package steps shows a task as a list of steps the way `docker buildx` does: the running step streams its output in a small scrolling window, and folds to one line with its duration when it finishes.
|
Package steps shows a task as a list of steps the way `docker buildx` does: the running step streams its output in a small scrolling window, and folds to one line with its duration when it finishes. |
|
Package oci keeps container images for `monolith container`: it pulls them from registries and converts each into an ext4 disk image that a container VM boots as its root filesystem.
|
Package oci keeps container images for `monolith container`: it pulls them from registries and converts each into an ext4 disk image that a container VM boots as its root filesystem. |
|
Package update finds monolith's latest GitHub release and installs a release over the running binary, with the checks install.sh makes: the archive's sha256 against the release's checksums.txt, then the binary's code signature and virtualization entitlement.
|
Package update finds monolith's latest GitHub release and installs a release over the running binary, with the checks install.sh makes: the archive's sha256 against the release's checksums.txt, then the binary's code signature and virtualization entitlement. |
|
guestinit
Package guestinit embeds monolith-init (cmd/monolith-init, built for linux/arm64 by `make build`) and packs it into the initrd container VMs boot from.
|
Package guestinit embeds monolith-init (cmd/monolith-init, built for linux/arm64 by `make build`) and packs it into the initrd container VMs boot from. |