Skip to content

Commit 1704ddc

Browse files
committed
Add distant-docker backend plugin for Docker container interaction
Introduce the `distant-docker` crate providing a client-side plugin that maps the distant API to Docker container operations via the `bollard` crate: - File operations (read/write/copy/rename/remove) via docker cp and exec - Directory operations (create/list/remove) via exec - Process spawn and kill via exec with PTY support - Search (path/contents) via exec with find/grep - System info and metadata retrieval via container inspect - Watching via polling-based exec approach Additional changes: - Register DockerPlugin in the manager's launch/connect handlers - Add docker test harness (distant-test-harness) with container lifecycle - Configure nextest throttling for docker tests (max-threads = 4) - Add docker feature flag to CI workflow - Add workflow anti-patterns to AGENTS.md (feature branches, commit per-phase, run tests after writing them)
1 parent 5fbddca commit 1704ddc

File tree

20 files changed

+3571
-1
lines changed

20 files changed

+3571
-1
lines changed

.config/nextest.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[test-groups.ssh-integration]
22
max-threads = 4
33

4+
[test-groups.docker-integration]
5+
max-threads = 2
6+
47
[profile.ci]
58
fail-fast = false
69
retries = 4
@@ -11,3 +14,7 @@ final-status-level = "fail"
1114
[[profile.ci.overrides]]
1215
filter = 'binary_id(distant-ssh::lib)'
1316
test-group = 'ssh-integration'
17+
18+
[[profile.ci.overrides]]
19+
filter = 'binary_id(distant-docker::lib)'
20+
test-group = 'docker-integration'

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ jobs:
128128
- name: Ensure /run/sshd exists on Unix
129129
run: sudo mkdir -p /run/sshd
130130
if: matrix.os == 'ubuntu-latest'
131+
- name: Pre-pull Docker test image (Linux)
132+
run: docker pull ubuntu:22.04
133+
if: matrix.os == 'ubuntu-latest'
131134
- name: Run all workspace tests (all features)
132135
run: cargo nextest run --profile ci --release --all-features --workspace
133136
- name: Run all doc tests (all features)

AGENTS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ Keep a list of patterns to **avoid**:
191191
4. Don't run mass parallel SSH integration tests without throttling — use
192192
nextest `test-groups` with `max-threads` (configured in
193193
`.config/nextest.toml`).
194+
5. Always create a **feature branch** before starting multi-file or multi-phase
195+
work — never commit directly to `master`. Use
196+
`git checkout -b feature/<name>` before writing any code.
197+
6. **Commit per-phase** (or at minimum per logical unit of work) — don't
198+
accumulate an entire feature as uncommitted changes across many phases. Each
199+
phase should be a separate commit with `cargo fmt` and `cargo clippy` passing
200+
before the commit is created.
201+
7. Always **run tests** (`cargo test --all-features -p <crate>`) after creating
202+
or modifying test files — don't assume tests compile or pass without actually
203+
executing them.
194204

195205
### Format standards
196206

Cargo.lock

Lines changed: 154 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ license = "MIT OR Apache-2.0"
1515
[workspace]
1616
members = [
1717
"distant-core",
18+
"distant-docker",
1819
"distant-host",
1920
"distant-ssh",
2021
"distant-test-harness",
@@ -31,6 +32,7 @@ strip = true
3132

3233
[features]
3334
default = []
35+
docker = ["dep:distant-docker"]
3436

3537
[dependencies]
3638
anyhow = "1.0.71"
@@ -65,6 +67,9 @@ which = "4.4.0"
6567
winsplit = "0.1.0"
6668
whoami = "1.4.0"
6769

70+
# Optional Docker backend
71+
distant-docker = { version = "=0.20.0", path = "distant-docker", optional = true }
72+
6873
# Native SSH functionality (always enabled)
6974
distant-ssh = { version = "=0.20.0", path = "distant-ssh", default-features = false, features = ["serde"] }
7075

distant-docker/Cargo.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[package]
2+
name = "distant-docker"
3+
description = "Library to enable Docker container interaction for use with distant sessions"
4+
categories = ["network-programming"]
5+
version = "0.20.0"
6+
authors = ["Chip Senkbeil <chip@senkbeil.org>"]
7+
edition = "2024"
8+
homepage = "https://github.com/chipsenkbeil/distant"
9+
repository = "https://github.com/chipsenkbeil/distant"
10+
readme = "README.md"
11+
license = "MIT OR Apache-2.0"
12+
13+
[features]
14+
default = []
15+
16+
[dependencies]
17+
async-once-cell = "0.5.2"
18+
bollard = "0.20"
19+
bytes = "1"
20+
derive_more = { version = "0.99.17", default-features = false, features = ["display", "error"] }
21+
distant-core = { version = "=0.20.0", path = "../distant-core" }
22+
futures = "0.3.28"
23+
log = "0.4.18"
24+
rand = { version = "0.8.5", features = ["getrandom"] }
25+
semver = "1"
26+
tar = "0.4"
27+
tokio = { version = "1.28.2", features = ["full"] }
28+
29+
# Optional serde support for data structures
30+
serde = { version = "1.0.163", features = ["derive"], optional = true }
31+
32+
[dev-dependencies]
33+
anyhow = "1.0.71"
34+
assert_fs = "1.0.13"
35+
distant-test-harness = { path = "../distant-test-harness", features = ["docker"] }
36+
env_logger = "0.10.0"
37+
once_cell = "1.17.2"
38+
predicates = "3.0.3"
39+
rstest = "0.17.0"
40+
test-log = "0.2.11"
41+
42+
[lints.rust]
43+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)'] }

0 commit comments

Comments
 (0)