Add -l/--list-images to discover OCI archives in a directory
list_oci_images() (src/oci_image.cpp) scans a directory non-recursively for *.tar/*.tar.* files and, for each one that's a valid OCI Image Layout archive, derives a name:tag from its index.json manifest annotations -- io.containerd.image.name if present (a full reference), else org.opencontainers.image.ref.name (conventionally just a bare tag for skopeo/podman-produced archives). Falls back to the archive's filename (.tar and any compression suffix stripped) for the name and "latest" for the tag. Files that aren't OCI archives are skipped quietly, since a directory scan is expected to hit unrelated tars. -l/--list-images <directory> wires this into the CLI, printing "name:tag<TAB>filename" per image. This is also why --log-level lost its short form last session: -l needed to be free for this. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,9 +16,13 @@ this repo as still early-stage.
|
||||
|
||||
Source layout (all under `src/`):
|
||||
- `main.cpp` — CLI entry point, dependency checks, orchestration (`mount_image()`,
|
||||
`run_container()`, `cleanup_image()`, `unmount_image()`).
|
||||
`run_container()`, `cleanup_image()`, `unmount_image()`, `list_images_command()`).
|
||||
- `oci_image.{h,cpp}` — validates/parses the OCI Image Layout tar (libarchive +
|
||||
nlohmann_json) and extracts layer blobs.
|
||||
nlohmann_json) and extracts layer blobs. `list_oci_images()` scans a directory
|
||||
(non-recursively) for `*.tar`/`*.tar.*` files and, for each valid OCI archive,
|
||||
derives an image name/tag from its `index.json` manifest annotations
|
||||
(`io.containerd.image.name` preferred, else `org.opencontainers.image.ref.name`),
|
||||
falling back to the archive's filename and `"latest"` respectively.
|
||||
- `containers_storage.{h,cpp}` — wraps the `containers-storage` CLI (`import-layer`,
|
||||
`mount`, `unmount`, `layer --json`, `delete-layer`), forcing `fuse-overlayfs` as the
|
||||
overlay `mount_program`. `cleanup_layer_chain()` walks a layer's parent chain
|
||||
@@ -60,7 +64,8 @@ Build directory is `buildDir/` (already configured).
|
||||
- Build: `meson compile -C buildDir` (or `ninja -C buildDir`)
|
||||
- Run the executable: `./buildDir/slocker_lite -m <image.tar>` (see `--help` for the
|
||||
full flag list: `-m/--mount`, `-r/--run`, `-u/--umount`, `-c/--cleanup`,
|
||||
`-n/--no-nsenter`, `-t/--test`, `-l/--log-level`, `-h/--help`, `-V/--version`)
|
||||
`-l/--list-images`, `-n/--no-nsenter`, `-t/--test`, `--log-level`, `-h/--help`,
|
||||
`-V/--version`)
|
||||
- Run tests: `meson test -C buildDir`
|
||||
|
||||
## Code style
|
||||
|
||||
Reference in New Issue
Block a user