feat: add Linux and Podman socket detection to platform.js#269
feat: add Linux and Podman socket detection to platform.js#269brianwtaylor wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughDetects container runtime and sockets: introduces Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
d286cde to
0299e48
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/runner.test.js (1)
43-53: Consider adding a test for Docker Desktop vs native Linux priority.The test suite verifies Docker Desktop is preferred over Podman, and Colima is preferred over native Linux, but there's no explicit test that Docker Desktop is preferred over
/run/docker.sock. This would complete the priority chain verification.🧪 Suggested test addition
it("prefers Docker Desktop over native Linux socket", () => { const dockerDesktopPath = "/home/test/.docker/run/docker.sock"; const result = detectContainerSocket({ home: "/home/test", existsSync: (p) => p === dockerDesktopPath || p === "/run/docker.sock", uid: 1000, }); assert.equal(result, dockerDesktopPath); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/runner.test.js` around lines 43 - 53, Add a unit test to confirm detectContainerSocket prefers Docker Desktop over the native Linux socket by adding a test case (e.g., it("prefers Docker Desktop over native Linux socket")) that calls detectContainerSocket with home="/home/test", uid=1000 and an existsSync stub that returns true for "/home/test/.docker/run/docker.sock" and "/run/docker.sock", then assert the result equals the Docker Desktop path; this mirrors the existing Podman and Colima tests and completes the priority chain coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/runner.test.js`:
- Around line 43-53: Add a unit test to confirm detectContainerSocket prefers
Docker Desktop over the native Linux socket by adding a test case (e.g.,
it("prefers Docker Desktop over native Linux socket")) that calls
detectContainerSocket with home="/home/test", uid=1000 and an existsSync stub
that returns true for "/home/test/.docker/run/docker.sock" and
"/run/docker.sock", then assert the result equals the Docker Desktop path; this
mirrors the existing Podman and Colima tests and completes the priority chain
coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2338b4ef-f6f1-4fa2-a0fd-f6b4d221f8b0
📒 Files selected for processing (3)
bin/lib/onboard.jsbin/lib/runner.jstest/runner.test.js
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/runner.test.js (1)
20-148: Consider a small helper to reduce repeated setup boilerplate.Most tests repeat the same
detectContainerSocket({ home, existsSync, uid })scaffolding. A tiny helper would make additions easier and reduce copy/paste noise.♻️ Optional refactor sketch
+const detect = (existsSync, { home = "/home/test", uid = 1000 } = {}) => + detectContainerSocket({ home, existsSync, uid }); - const result = detectContainerSocket({ - home: "/home/test", - existsSync: (p) => p === dockerDesktopPath, - uid: 1000, - }); + const result = detect((p) => p === dockerDesktopPath);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/runner.test.js` around lines 20 - 148, Extract the repeated test scaffolding into a small helper function (e.g., makeDetectArgs or runDetect) used by all test cases so each test calls detectContainerSocket(makeDetectArgs({ home: "/home/test", existsSync: ..., uid: ... })) or runDetect({...}) to reduce duplication; update all test cases to call the helper instead of repeating the object literal, keeping the existing uses of detectContainerSocket and preserving custom existsSync/uid values per test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/runner.test.js`:
- Around line 66-87: Add a unit test to assert native Docker socket is preferred
over Podman by calling detectContainerSocket with both "/var/run/docker.sock"
and the Podman path present (simulate existsSync returning true for both) and
asserting the returned path equals "/var/run/docker.sock"; place it alongside
the existing Colima/Podman tests and mirror their structure (use home,
existsSync, uid) to lock in the native-over-Podman priority.
---
Nitpick comments:
In `@test/runner.test.js`:
- Around line 20-148: Extract the repeated test scaffolding into a small helper
function (e.g., makeDetectArgs or runDetect) used by all test cases so each test
calls detectContainerSocket(makeDetectArgs({ home: "/home/test", existsSync:
..., uid: ... })) or runDetect({...}) to reduce duplication; update all test
cases to call the helper instead of repeating the object literal, keeping the
existing uses of detectContainerSocket and preserving custom existsSync/uid
values per test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 66c422a8-b5b2-47aa-a395-8294f905ddaf
📒 Files selected for processing (1)
test/runner.test.js
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/runner.test.js (1)
142-149: Add a direct/var/run/docker.sockover Podman priority test.Line 142 currently validates
/var/run/docker.sockonly as a standalone fallback. Add a paired test where both/var/run/docker.sockand Podman exist, so native-over-Podman priority is covered for both native socket paths.✅ Suggested test addition
+ it("prefers /var/run/docker.sock over Podman", () => { + const podmanPath = "/home/test/.local/share/containers/podman/machine/podman.sock"; + const result = detectContainerSocket({ + home: "/home/test", + existsSync: (p) => p === "/var/run/docker.sock" || p === podmanPath, + uid: 1000, + }); + assert.equal(result, "/var/run/docker.sock"); + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/runner.test.js` around lines 142 - 149, Add a new test in test/runner.test.js that calls detectContainerSocket with existsSync returning true for both "/var/run/docker.sock" and the Podman socket path (e.g., "/run/podman/podman.sock" or the code's Podman candidate) and assert the result is "/var/run/docker.sock"; this complements the existing standalone fallback test and ensures detectContainerSocket prefers the native Docker socket over Podman when both exist (refer to detectContainerSocket to locate the socket candidates and use the same test harness pattern as the existing cases).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/runner.test.js`:
- Around line 142-149: Add a new test in test/runner.test.js that calls
detectContainerSocket with existsSync returning true for both
"/var/run/docker.sock" and the Podman socket path (e.g.,
"/run/podman/podman.sock" or the code's Podman candidate) and assert the result
is "/var/run/docker.sock"; this complements the existing standalone fallback
test and ensures detectContainerSocket prefers the native Docker socket over
Podman when both exist (refer to detectContainerSocket to locate the socket
candidates and use the same test harness pattern as the existing cases).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 451790b8-8d2a-433e-94eb-25ac3fe56298
📒 Files selected for processing (1)
test/runner.test.js
819445a to
8fcff22
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/runner.test.js (1)
12-17: Optional: extract a small helper to reduce repetitive test scaffolding.Most test bodies repeat the same
detectContainerSocket({ home, existsSync, uid })shape; a local helper would make cases shorter and easier to scan.♻️ Example refactor
describe("detectContainerSocket", () => { + function detectWith({ home = "/home/test", existsSync, uid = 1000 }) { + return detectContainerSocket({ home, existsSync, uid }); + } + it("returns null when no sockets exist", () => { - const result = detectContainerSocket({ - home: "/nonexistent", - existsSync: () => false, - uid: 1000, - }); + const result = detectWith({ home: "/nonexistent", existsSync: () => false }); assert.equal(result, null); });Also applies to: 23-29, 35-41, 47-53, 58-64, 70-76, 81-87, 92-98, 104-110, 115-121, 125-131, 134-140, 143-149, 153-159
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/runner.test.js` around lines 12 - 17, Extract a small test helper to reduce repetition: add a local function (e.g., runDetect or makeDetectInput) in the test file that supplies the common shape detectContainerSocket expects (home, existsSync, uid) and accepts overrides, then replace repeated calls like detectContainerSocket({ home: "/nonexistent", existsSync: () => false, uid: 1000 }) with the helper (e.g., runDetect({ home: "/nonexistent", existsSync: () => false, uid: 1000 }) or runDetect({ uid: 1000 }) using defaults). Update all test cases referencing detectContainerSocket to use this helper to keep tests shorter and easier to scan while preserving the same assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bin/lib/runner.js`:
- Around line 12-13: Update the docstring that currently reads "Detect a
container runtime socket (Colima first, then Docker Desktop, then Podman)." to
match the actual detection order implemented in the code: mention Colima first,
then native Docker sockets, then Podman (i.e., "Colima -> Docker (native) ->
Podman"); locate and edit the comment block that begins with "Detect a container
runtime socket (Colima first, then Docker Desktop, then Podman)." so the text
accurately reflects the implemented detection sequence.
---
Nitpick comments:
In `@test/runner.test.js`:
- Around line 12-17: Extract a small test helper to reduce repetition: add a
local function (e.g., runDetect or makeDetectInput) in the test file that
supplies the common shape detectContainerSocket expects (home, existsSync, uid)
and accepts overrides, then replace repeated calls like detectContainerSocket({
home: "/nonexistent", existsSync: () => false, uid: 1000 }) with the helper
(e.g., runDetect({ home: "/nonexistent", existsSync: () => false, uid: 1000 })
or runDetect({ uid: 1000 }) using defaults). Update all test cases referencing
detectContainerSocket to use this helper to keep tests shorter and easier to
scan while preserving the same assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5b8a32b5-3cbf-4553-99d6-1fdfd4f3fb31
📒 Files selected for processing (3)
bin/lib/onboard.jsbin/lib/runner.jstest/runner.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
- bin/lib/onboard.js
After the platform.js refactor in #295, getDockerSocketCandidates() returns an empty array on Linux, so detectDockerHost() never finds a socket on native Linux or WSL2 unless DOCKER_HOST is already set. Add the standard Linux Docker socket paths (/run/docker.sock, /var/run/docker.sock), Docker Desktop for Linux, and three Podman socket paths (machine, rootless, QEMU) with the priority order: Docker Desktop > native Docker > Podman Includes 9 new tests covering Linux detection, priority chain, rootless Podman UID substitution, and fallback behavior.
c39110f to
55f8559
Compare
Summary
The
platform.jsmodule introduced in #295 provides socket detection for macOS (Colima and Docker Desktop) but does not yet include Linux candidates —getDockerSocketCandidates()returns an empty array on non-Darwin platforms. This meansdetectDockerHost()relies entirely onDOCKER_HOSTbeing pre-set on Linux, WSL2, and Podman environments.This adds the standard Linux socket paths and Podman support to complete cross-platform coverage.
Addresses #137
Changes
bin/lib/platform.js— ExtendgetDockerSocketCandidates()for Linux with:~/.docker/run/docker.sock(Docker Desktop for Linux)/run/docker.sock(native Docker / WSL2)/var/run/docker.sock(native Docker fallback)~/.local/share/containers/podman/machine/podman.sock(Podman machine)/run/user/<uid>/podman/podman.sock(rootless Podman)~/.local/share/containers/podman/machine/qemu/podman.sock(Podman QEMU)Priority: Docker Desktop > native Docker > Podman
test/platform.test.js— 8 new tests (1 upstream test replaced), covering Linux candidate list, UID substitution, native Docker detection, /var/run fallback, Docker Desktop > native priority, native > Podman priority, Podman fallback, and rootless Podman.Test plan
Automated Tests
22 tests (15 existing, 1 replaced, 8 added). All pass.