refactor: split main.rs into registry, build, and qemu modules #5

Merged
marvin merged 1 commits from refactor/modules into master 2026-08-26 22:20:38 +02:00
Collaborator

Follow-up to #4 — main.rs (288 lines) was getting cramped, so the functions live in modules now. Stacked on #4; rebase to master once that merges.

Layout

  • src/main.rs (43 lines) — CLI definition and dispatch only
  • src/registry.rsvalidate_image_name, registry_dir + the unit tests
  • src/build.rsmount_image, build_artifacts (podman unshare pipeline, vmlinuz extraction, cpio→gzip initrd)
  • src/qemu.rsrun (direct-kernel-boot launch + exit-status handling)

Pure code movement: no behavior change, no new logic. One stale comment ("5-second timeout") removed since master's rework dropped the timeout wrapper.

Verification

  • cargo fmt --check, cargo clippy -- -D warnings, cargo test (2 tests, now registry::tests::*) pass
  • slim build mock-vm → succeeds end-to-end
  • slim run '../../evil' → rejected, exit 1
  • slim run nonexistent → proper missing-artifact error

@hulthe please review — will not merge until approved (and after #4).

Follow-up to #4 — main.rs (288 lines) was getting cramped, so the functions live in modules now. **Stacked on #4**; rebase to master once that merges. ## Layout - `src/main.rs` (43 lines) — CLI definition and dispatch only - `src/registry.rs` — `validate_image_name`, `registry_dir` + the unit tests - `src/build.rs` — `mount_image`, `build_artifacts` (podman unshare pipeline, vmlinuz extraction, cpio→gzip initrd) - `src/qemu.rs` — `run` (direct-kernel-boot launch + exit-status handling) Pure code movement: no behavior change, no new logic. One stale comment ("5-second timeout") removed since master's rework dropped the `timeout` wrapper. ## Verification - `cargo fmt --check`, `cargo clippy -- -D warnings`, `cargo test` (2 tests, now `registry::tests::*`) pass - `slim build mock-vm` → succeeds end-to-end - `slim run '../../evil'` → rejected, exit 1 - `slim run nonexistent` → proper missing-artifact error @hulthe please review — will not merge until approved (and after #4).
hulthe approved these changes 2026-08-26 22:18:19 +02:00
marvin changed target branch from fix/registry-path-validation to master 2026-08-26 22:20:31 +02:00
marvin added 1 commit 2026-08-26 22:20:31 +02:00
refactor: split main.rs into registry, build, and qemu modules
CI / build (pull_request) Successful in 10s
CI / build (push) Successful in 11s
37f537184c
main.rs keeps only the CLI definition and command dispatch:
- registry.rs: image-name validation + XDG registry path handling (tests)
- build.rs: podman mount/unmount, vmlinuz extraction, cpio/gzip initrd
- qemu.rs: direct-kernel-boot VM launch

No behavior change; cargo fmt/clippy/test pass, build/run paths
verified against the mock-vm image.
marvin merged commit 37f537184c into master 2026-08-26 22:20:38 +02:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hulthe/boco#5