Skip to content

fix: validate absolute volume paths on WASM/non-Unix#220

Draft
maximeborges wants to merge 2 commits into
containers:mainfrom
maximeborges:wasm-support
Draft

fix: validate absolute volume paths on WASM/non-Unix#220
maximeborges wants to merge 2 commits into
containers:mainfrom
maximeborges:wasm-support

Conversation

@maximeborges

Copy link
Copy Markdown

Why

This is the follow-up I mentioned in #219. Now that podlet builds as a library, I wanted to actually run it in the browser (wasm32-unknown-unknown). It compiles fine, but compose files with absolute volume paths (e.g. /data:/data) fail to convert: compose_spec validates them with Path::is_absolute(), which returns false for /-prefixed paths on non-Unix targets, so they get rejected.
The actual fix lives upstream in k9withabone/compose_spec_rs#42. Until that's released, this patches compose_spec to that branch so conversion is correct on WASM.

What

  • A [patch.crates-io] pointing compose_spec at the fixed branch; temporary, to be dropped once the upstream fix is released
  • A short WebAssembly section in the README on using the library in the browser (can be removed)

Note: [patch] only applies when building podlet itself, so projects that depend on podlet and target WASM need to replicate it in their own Cargo.toml; the README calls that out.

No behavior change on native; cargo test/clippy/fmt are green, and cargo build --lib --target wasm32-unknown-unknown builds clean.

Stacked on #219; best reviewed/merged after it and after compose_spec is fixed so we can avoid delivering a crate with a patch at all.

Split the crate into a library (`src/lib.rs`) and a thin binary
(`src/main.rs`) so podlet can be used as a dependency. The library exposes
a small, string-based public API for in-memory compose -> Quadlet/Kubernetes
conversion, keeping internals private:

- `compose_to_files(yaml, ComposeOptions) -> Vec<GeneratedFile>`
- `Cli::try_into_generated_files()` for all subcommands
- `GeneratedFile`, `ComposeOptions`

Split `Compose::try_into_files` into an I/O part and a pure `into_files`
that takes an already-parsed `compose_spec::Compose`.

Patch `compose_spec` (k9withabone/compose_spec_rs#42) so absolute volume
paths validate on non-Unix targets.

Signed-off-by: Maxime Borges <contact@maximeborg.es>
Patch `compose_spec` to k9withabone/compose_spec_rs#42 so Podman-style
absolute volume paths (starting with `/`) validate correctly on non-Unix
targets such as `wasm32-unknown-unknown`, allowing the library to convert
compose files in the browser.

Document WASM library usage and the required downstream patch in the README.

Note: `[patch]` only applies when building podlet itself; downstream
consumers targeting WASM must replicate it in their own workspace.

Signed-off-by: Maxime Borges <contact@maximeborg.es>
@maximeborges maximeborges marked this pull request as draft July 9, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant