* model.ParseSize / FormatSizeBytes: pinned with table tests in
internal/model/types_test.go (TestParseSize 22 cases,
TestFormatSizeBytes 11 cases, TestParseSizeFormatRoundTrip 7
boundaries). Fixed the long-suffix regression: "4GiB", "512MiB",
"4KiB" now parse correctly (parser strips trailing IB before
inspecting the unit byte). Pinned current behaviour for
no-suffix input ("1024" treated as MiB) and FormatSizeBytes(0).
commands_image.go --size flag-help updated to show 4GiB now
that the parser accepts it.
* vm ports --json: matches the JSON-vs-table inconsistency between
vm stats (always JSON) and vm ports (always table). --json on
vm ports flips to the same printJSON path as vm stats. Default
table output unchanged. Other vm subcommands (show, stats,
logs, health, ping) didn't fit the identical pattern; left
alone.
* docs/oci-import.md architecture section moved to a new
docs/oci-import-internals.md (precedent: internal/daemon/
ARCHITECTURE.md). User-facing oci-import.md keeps a one-line
pointer for advanced reading.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.1 KiB
2.1 KiB
OCI import — internals
Advanced reading. This document describes implementation details of the OCI import pipeline. It is not needed for day-to-day use of
banger image pull. User-facing documentation is indocs/oci-import.md.
Architecture
internal/imagepull/ owns the mechanics:
Pullwrapsgo-containerregistry'sremote.Imagewith thelinux/amd64platform pinned. Layer blobs cache under~/.cache/banger/oci/blobs/and populate lazily during flatten.Flattenreplays layers oldest-first into a staging directory, applies whiteouts, rejects unsafe paths plus filenames that banger's debugfs ownership fixup cannot encode safely. Returns aMetadatamap of per-file uid/gid/mode from tar headers.BuildExt4runsmkfs.ext4 -F -d <staging> -E root_owner=0:0at the size of the pre-truncated file — no mount, no sudo, no loopback. Requirese2fsprogs ≥ 1.43.ApplyOwnershipstreams a batchedset_inode_fieldscript todebugfs -wto rewrite per-file uid/gid/mode to the captured tar- header values.InjectGuestAgentsuses the samedebugfsscripting to drop banger's guest assets into the ext4 with root ownership: vsock agent binary, network bootstrap + unit, first-boot script + unit,multi-user.target.wantssymlinks, vsock modules-load config,/var/lib/banger/first-boot-pendingmarker.
internal/daemon/images_pull.go orchestrates pullFromOCI:
- Parse + validate the OCI ref, derive a default name when
--nameis omitted (debian-bookwormfromdocker.io/library/debian:bookworm). - Resolve kernel info via
resolveKernelInputs(auto-pulls fromkernelcatif--kernel-refnames a catalog entry that isn't yet local). - Stage at
<ImagesDir>/<id>.staging; extract layers to a temp tree under$TMPDIR. BuildExt4→ApplyOwnership→InjectGuestAgents.imagemgr.StageBootArtifactsstages the kernel triple alongside.- Atomic
os.Renamepublishes the artifact dir. - Persist a
model.Image{Managed: true, …}record.