ContributingDevelopment setup
Coding rules
The rules of DESIGN.md apply to each crate. Two commands check the format and the lints.
cargo fmt
cargo clippy --workspace --all-targets -- -D warningsThe two commands must pass. cargo fmt is the formatter: the rustfmt.toml of the repository sets a width of 120 columns. cargo clippy runs the lints.
The rules
The rules come from the section "Coding rules" of DESIGN.md. They apply to each crate.
| Subject | Rule |
|---|---|
| Rust | Rust 2024, stable toolchain. |
unwrap() and expect() | Not outside tests. The only exception is an invariant that a comment explains. |
todo!() | Leave none in the code. |
| Errors | Use ferry_core::Error. Put context in the message: pulling image nginx: …. |
| Logs | Use tracing: info for lifecycle events, debug for detail. Never log secrets. |
| Blocking work | Run tar and heavy filesystem work in spawn_blocking. |
| Public signatures | crates/*/src/lib.rs is the contract between crates. Change a signature on purpose, and say so in the change. You can organize private modules as you want. |
| Dependencies | Add them to the Cargo.toml of the crate, with an explicit version. Do not add them to the workspace root. |
| Crates | A crate must not depend on another crate outside the dependency graph. |
The error gives the HTTP status
The variant of ferry_core::Error decides the HTTP status of the answer. Examples:
| Variant | Status |
|---|---|
Invalid | 400 |
NotFound | 404 |
Conflict | 409 |
Docker | 502 |
Then run the tests.