feat: mock data, screenshot script and README #7
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/4-mock-screenshots"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #4, closes #5.
Stacked on #6 (base is
feat/1-volumes-images); once #6 merges I'll retarget this tomain. The two commits of its own are the last two.Mock data (
--mock, #4)mockcargo feature (off by default): a plaincargo buildcompiles none ofsrc/mock.rsor its hooks, so release/live builds carry no mock code or fixtures. On such a build--mock,--screenshotsandKRANE_MOCKexit with code 2 and a hint to rebuild with--features mock. Try it withcargo run --features mock -- --mock --show.src/mock.rsholds example data: compose projectsshop(web/api/db/cache) andmonitoring(grafana running, prometheus stopped), standaloneminioand a stoppedscratchpad, 9 volumes (named, compose, anonymous, unused) and 11 images (multi-tag, unused, one dangling). It's written as Docker API JSON and deserialized into bollard's types, so it runs through the same shaping code as real data. Times are relative to now, so "Up 3 hours" / "2 days ago" read the same every run.--mock(orKRANE_MOCK=1) container/volume/image lists,inspect, image inspect, logs (per-service canned lines) and the engine version come from the fixtures. Actions do nothing and the toast says "Mock data: nothing was changed".Screenshot script (#4)
--screenshots <dir>implies--mock, skips the tray, walks the window through Containers, a project's Logs, Volumes and Images in dark then light, saves each PNG and exits.scripts/screenshots.sh [dir]builds a release--features mockbinary intotarget/mock(so it never replaces a normal build) and runs that on Qt's offscreen platform at 2x, so it needs no display, no DBus and no Docker.SCALE=1for 1x,ICON_THEME=to change icons.KRANE_ICON_THEME(new, also usable day to day) sets the icon theme and adds the XDG icon folders to Qt's search path, which the offscreen platform otherwise skips.contentRectangle (grabToImage needs a QML item, and this keeps the background in the image),Theme.darkis writable so the light pass can flip it, and the two pages have ids.README (#5)
README.md: what Krane is, features, screenshots (dark, with light in a collapsible), build deps for Debian/Ubuntu, Fedora and Arch, how to run, the options (--show,--mock,--screenshots,KRANE_ICON_THEME), how to regenerate screenshots, and a short map of the source.docs/screenshots/has the 8 generated PNGs (2.5 MB).Tried
cargo testandcargo test --features mock(the 3 fixture tests only run with the feature),cargo fmt --check,scripts/screenshots.shfrom a cleandocs/screenshots(all 8 written, exits on its own), and the release build against a real (sandbox) Docker daemon to check nothing in normal mode changed.Screenshots (generated by the script)
containers

logs

volumes

images

containers-light

images-light

Review from Nye: one low finding, fix applied (posted by Upper Wolfjaw, since Nye's token can't comment)
Reviewed commits
3996969and2db0e89on a Qt 6.8 release build.cargo test: 8/8 pass.scripts/screenshots.shwrites all 8 PNGs headless, with no Docker, and exits 0.--mock --showruns; the pages and the generated screenshots look right.qt6-declarative-devpulls in qmlcachegen; ksni 0.3 is zbus, so no libdbus needed).F2 (low):
scripts/screenshots.shprinted "icon theme 'breeze' not found … install breeze-icon-theme" even with Breeze installed. Withset -o pipefail,findexits 1 when/usr/local/share/iconsor~/.local/share/iconsdoesn't exist (both missing on a fresh Debian), sofind | grep -q .fails even though grep matched. Fix: check each folder with[[ -d "$dir/$theme" ]]; a theme that's really missing still warns. Applied in77de0e8.Non-blocking: in mock mode, container stop/start just spins for 30s (the pruneBusy timeout) with no message, unlike the resource actions' "Mock data: nothing was changed" toast. Fine to leave.
Nye will approve once the F2 proof reruns clean on
77de0e8.Review from Nye (posted by Upper Wolfjaw, since Nye's token can't comment). Verdict: Approved.
Approved. F2 is fixed in
77de0e8, and the proof script passes. I re-ran screenshots.sh on a Qt 6.8 release build: it writes 8 PNGs headless with exit 0 and no false icon warning, and ICON_THEME=nosuchtheme still warns. All 8 cargo tests pass. Non-blocking: in mock mode, container actions spin for about 30s with no feedback. Merge after #6.From Nye (review, posted by Upper Wolfjaw):
Verified
19f4351(mock behind themockfeature). I built both variants on Qt 6.8. The default release binary has none of the mock data (minio-data, shop_pgdata, shop-api-1, acme/shop-api, "Mock mode": 0 hits from strings).--mock,--screenshots <dir>andKRANE_MOCK=1each exit 2 with the rebuild hint.scripts/screenshots.shbuilds into target/mock and writes all 8 PNGs headless. Proof C7.Non-blocking follow-up: the QML screenshot driver in Main.qml (screenshotScenes, with the mock names) still ships in default builds. It's inert, since screenshotDir() returns "".