feat: expose container devices to templates#757
Conversation
e1c6fe6 to
4b5e1bc
Compare
|
@JamBalaya56562 please flag AI-generated PR explicitly in the PR description (ie "🤖 Generated with Claude Code" like in this PR) and add the AI agent as co-author of the commits. |
4b5e1bc to
4f1c9cd
Compare
|
Done — added the |
There was a problem hiding this comment.
Pull request overview
This PR adds support for exposing Docker device passthrough configuration (HostConfig.Devices) in the emitted RuntimeContainer context so templates can render forwarded device nodes (e.g., USB serial adapters, webcams).
Changes:
- Introduces a
Devicetype and addsDevices []DevicetoRuntimeContainer(context + README documentation). - Populates
RuntimeContainer.DevicesingetContainersby mappingdocker.Devicefields (includingCgroupPermissions→Permissions). - Adds a unit test covering device extraction via a mock Docker daemon response.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Documents the new Devices field, Device struct, and provides a JSON example. |
| internal/context/context.go | Adds Device and wires Devices []Device into RuntimeContainer. |
| internal/generator/generator.go | Populates RuntimeContainer.Devices from inspected container HostConfig.Devices. |
| internal/generator/generator_test.go | Adds TestGetContainersDevices to assert device passthrough is emitted into context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Martin Koppehel <martin.koppehel@st.ovgu.de> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35fd8d2 to
b601ea9
Compare
Summary
Exposes container device passthrough (
HostConfig.Devices) to templates, reimplementing the stale PR #277 against the currentinternal/layout.Device{PathOnHost, PathInContainer, Permissions}type and aDevices []Devicefield onRuntimeContainer.getContainers, mirroring the existing Mounts loop. go-dockerclient'sDevice.CgroupPermissionsis mapped toDevice.Permissions.Use case: discovering forwarded device nodes (webcams, USB-serial adapters, etc.) from templates.
Notes
HostConfig(introduced in fix: avoid panic on nil container Config/NetworkSettings/HostConfig #748) instead of dereferencingcontainer.HostConfigdirectly, so a container inspected with a nilHostConfigcannot panic.t.Fatal→t.Fatalfchurn from the original PR is dropped.HostConfig.Deviceshas been stable in go-dockerclient since 2018, so no dependency change is required.Tests
Added
TestGetContainersDevices, which drivesgetContainersagainst a mock daemon returning a device and asserts the populatedDevices. Documented theDevicestruct and a JSON example in the README.Reimplements #277
🤖 Generated with Claude Code