feat: mock data, screenshot script and README #7

Merged
jfro merged 4 commits from feat/4-mock-screenshots into main 2026-11-29 00:44:26 +00:00
Owner

Closes #4, closes #5.

Stacked on #6 (base is feat/1-volumes-images); once #6 merges I'll retarget this to main. The two commits of its own are the last two.

Mock data (--mock, #4)

  • Behind the mock cargo feature (off by default): a plain cargo build compiles none of src/mock.rs or its hooks, so release/live builds carry no mock code or fixtures. On such a build --mock, --screenshots and KRANE_MOCK exit with code 2 and a hint to rebuild with --features mock. Try it with cargo run --features mock -- --mock --show.
  • src/mock.rs holds example data: compose projects shop (web/api/db/cache) and monitoring (grafana running, prometheus stopped), standalone minio and a stopped scratchpad, 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.
  • With --mock (or KRANE_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 mock binary into target/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=1 for 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.
  • Small QML changes for it: the window content sits in a content Rectangle (grabToImage needs a QML item, and this keeps the background in the image), Theme.dark is 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 test and cargo test --features mock (the 3 fixture tests only run with the feature), cargo fmt --check, scripts/screenshots.sh from a clean docs/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
containers

logs
logs

volumes
volumes

images
images

containers-light
containers-light

images-light
images-light

Closes #4, closes #5. **Stacked on #6** (base is `feat/1-volumes-images`); once #6 merges I'll retarget this to `main`. The two commits of its own are the last two. ### Mock data (`--mock`, #4) - **Behind the `mock` cargo feature** (off by default): a plain `cargo build` compiles none of `src/mock.rs` or its hooks, so release/live builds carry no mock code or fixtures. On such a build `--mock`, `--screenshots` and `KRANE_MOCK` exit with code 2 and a hint to rebuild with `--features mock`. Try it with `cargo run --features mock -- --mock --show`. - `src/mock.rs` holds example data: compose projects `shop` (web/api/db/cache) and `monitoring` (grafana running, prometheus stopped), standalone `minio` and a stopped `scratchpad`, 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. - With `--mock` (or `KRANE_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 mock` binary into `target/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=1` for 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. - Small QML changes for it: the window content sits in a `content` Rectangle (grabToImage needs a QML item, and this keeps the background in the image), `Theme.dark` is 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 test` and `cargo test --features mock` (the 3 fixture tests only run with the feature), `cargo fmt --check`, `scripts/screenshots.sh` from a clean `docs/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** ![containers](https://git.knope.dev/attachments/3a9f3423-79a3-47f9-920c-0bf12fa61782) **logs** ![logs](https://git.knope.dev/attachments/7ae8efb9-603c-429c-9170-a3e557343a24) **volumes** ![volumes](https://git.knope.dev/attachments/24fba385-e7a6-4025-9335-17f15fba058c) **images** ![images](https://git.knope.dev/attachments/d4264965-78d2-41ec-be60-9158e45a2cf5) **containers-light** ![containers-light](https://git.knope.dev/attachments/ffccdc12-977a-4ae4-9356-d84a5a3b539c) **images-light** ![images-light](https://git.knope.dev/attachments/f02dfeda-fef4-46b7-b72b-02fb53db486d)
`--mock` (or KRANE_MOCK=1) swaps the Docker engine for built-in example
data in src/mock.rs: two compose projects, standalone containers,
volumes and images, written as Docker API JSON and run through the same
shaping code as real data. Inspect, logs and the engine version are
mocked too; actions do nothing and say so.

`--screenshots <dir>` implies --mock, skips the tray, walks the window
through Containers, a project's Logs, Volumes and Images in dark and
light, saves each as a PNG and exits. scripts/screenshots.sh runs it on
Qt's offscreen platform, so it needs no display or Docker.

KRANE_ICON_THEME picks the icon theme (and adds the XDG icon folders to
the search path) for desktops or platforms that don't provide one.

Closes #4
Closes #5
jfro left a comment

Review from Nye: one low finding, fix applied (posted by Upper Wolfjaw, since Nye's token can't comment)

Reviewed commits 3996969 and 2db0e89 on a Qt 6.8 release build.

  • cargo test: 8/8 pass.
  • scripts/screenshots.sh writes all 8 PNGs headless, with no Docker, and exits 0.
  • --mock --show runs; the pages and the generated screenshots look right.
  • README's Debian 13 packages check out (qt6-declarative-dev pulls in qmlcachegen; ksni 0.3 is zbus, so no libdbus needed).

F2 (low): scripts/screenshots.sh printed "icon theme 'breeze' not found … install breeze-icon-theme" even with Breeze installed. With set -o pipefail, find exits 1 when /usr/local/share/icons or ~/.local/share/icons doesn't exist (both missing on a fresh Debian), so find | grep -q . fails even though grep matched. Fix: check each folder with [[ -d "$dir/$theme" ]]; a theme that's really missing still warns. Applied in 77de0e8.

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: one low finding, fix applied** (posted by Upper Wolfjaw, since Nye's token can't comment) Reviewed commits 3996969 and 2db0e89 on a Qt 6.8 release build. - `cargo test`: 8/8 pass. - `scripts/screenshots.sh` writes all 8 PNGs headless, with no Docker, and exits 0. - `--mock --show` runs; the pages and the generated screenshots look right. - README's Debian 13 packages check out (`qt6-declarative-dev` pulls in qmlcachegen; ksni 0.3 is zbus, so no libdbus needed). **F2 (low):** `scripts/screenshots.sh` printed "icon theme 'breeze' not found … install breeze-icon-theme" even with Breeze installed. With `set -o pipefail`, `find` exits 1 when `/usr/local/share/icons` or `~/.local/share/icons` doesn't exist (both missing on a fresh Debian), so `find | grep -q .` fails even though grep matched. Fix: check each folder with `[[ -d "$dir/$theme" ]]`; a theme that's really missing still warns. Applied in 77de0e8. 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.
jfro left a comment

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.

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.
Normal builds no longer compile src/mock.rs or its hooks; --mock,
--screenshots and KRANE_MOCK exit with a hint on such builds.
scripts/screenshots.sh builds the mock variant into target/mock so it
never replaces a normal build.
jfro changed target branch from feat/1-volumes-images to main 2026-11-29 00:39:40 +00:00
jfro merged commit 52c1ed9f5a into main 2026-11-29 00:44:26 +00:00
Author
Owner

From Nye (review, posted by Upper Wolfjaw):

Verified 19f4351 (mock behind the mock feature). 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> and KRANE_MOCK=1 each exit 2 with the rebuild hint. scripts/screenshots.sh builds 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 "".

**From Nye (review, posted by Upper Wolfjaw):** Verified 19f4351 (mock behind the `mock` feature). 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>` and `KRANE_MOCK=1` each exit 2 with the rebuild hint. `scripts/screenshots.sh` builds 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 "".
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/krane!7
No description provided.