Add --delete-volume and --delete-volume-full
--delete-volume <name> removes a volume's config entry only. --delete-volume-full <name> also recursively deletes its host directory -- fails before touching the config if that deletion errors, so a failed directory delete never silently drops the config entry; warns instead of failing if the directory was already gone. Both are long-only, following the --list-volumes precedent, and slot into the existing multi-mode getopt dispatch the same way -v/--volume already does. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
@@ -17,16 +17,20 @@ status); this file stays the dense, file-by-file reference. Still early-stage.
|
||||
Source layout (all under `src/`):
|
||||
- `main.cpp` — CLI entry point, dependency checks, orchestration (`mount_image()`,
|
||||
`run_container()`, `cleanup_image()`, `unmount_image()`, `list_images_command()`,
|
||||
`create_volume_command()`, `list_volumes_command()`). `run_container()`
|
||||
unconditionally calls `read_oci_image_config()` and reuses the result for two
|
||||
independent defaults: the command to run (`Entrypoint ++ Cmd`) when none is given
|
||||
on the command line, and, when `--user` wasn't given, the sandboxed process's
|
||||
user/group (`config.User`, split into `OciImageConfig::user`/`group`) — an
|
||||
explicit `--user`/`--group` on the command line always takes precedence.
|
||||
`create_volume_command()`, `list_volumes_command()`, `delete_volume_command()`).
|
||||
`run_container()` unconditionally calls `read_oci_image_config()` and reuses the
|
||||
result for two independent defaults: the command to run (`Entrypoint ++ Cmd`) when
|
||||
none is given on the command line, and, when `--user` wasn't given, the sandboxed
|
||||
process's user/group (`config.User`, split into `OciImageConfig::user`/`group`) —
|
||||
an explicit `--user`/`--group` on the command line always takes precedence.
|
||||
`create_volume_command()` implements `-v/--volume <name> <directory>`;
|
||||
`list_volumes_command()` implements `--list-volumes` (same tab-alignment scheme as
|
||||
`list_images_command()`, reused as-is) — see `config_file.{h,cpp}` below for what a
|
||||
"volume" means here (a distinct concept from `OciImageConfig::volumes`).
|
||||
`list_images_command()`, reused as-is); `delete_volume_command()` implements both
|
||||
`--delete-volume <name>` (config entry only) and `--delete-volume-full <name>`
|
||||
(also `std::filesystem::remove_all()`s the host directory — errors out before
|
||||
touching the config if that fails, warns instead of failing if the directory was
|
||||
already gone) — see `config_file.{h,cpp}` below for what a "volume" means here (a
|
||||
distinct concept from `OciImageConfig::volumes`).
|
||||
- `oci_image.{h,cpp}` — validates/parses the OCI Image Layout tar (libarchive +
|
||||
nlohmann_json) and extracts layer blobs. `list_oci_images()` scans a directory
|
||||
(non-recursively) for `*.tar`/`*.tar.*` files and, for each valid OCI archive,
|
||||
@@ -155,7 +159,8 @@ Build directory is `buildDir/` (already configured).
|
||||
- Run the executable: `./buildDir/slocker-lite -m <image.tar>` (see `--help` for the
|
||||
full flag list: `-m/--mount`, `-r/--run`, `-u/--umount`, `-c/--cleanup`,
|
||||
`-l/--list-images`, `-n/--no-nsenter`, `--user`, `--group`, `-v/--volume`,
|
||||
`--list-volumes`, `-t/--test`, `--log-level`, `-h/--help`, `-V/--version`)
|
||||
`--list-volumes`, `--delete-volume`, `--delete-volume-full`, `-t/--test`,
|
||||
`--log-level`, `-h/--help`, `-V/--version`)
|
||||
- Run tests: `meson test -C buildDir`
|
||||
|
||||
## Code style
|
||||
|
||||
Reference in New Issue
Block a user