Repository navigation
Allow container socket paths to be configured via config file - #4943
Conversation
|
@claude deep review of branch please |
|
Claude finished @kantord's task in 2m 27s —— View job Deep Code Review
Summary: This PR adds support for configuring container socket paths (Docker, Podman, Colima) via the ToolHive config file ( 🔴 Critical — Build broken on Windows
func findPlatformContainerSocket(rt runtime.Type) (string, runtime.Type, error) {But return findPlatformContainerSocket(rt, overrides)This is a compile error on Windows. The Windows implementation needs to be updated to accept 🔴 High — Config overrides ignore the
|
| Severity | Issue |
|---|---|
| 🔴 Build-breaking | Windows compile error — client_windows.go not updated to new signature |
| 🔴 Runtime bug | Config overrides don't gate on rt, blocking runtime fallback |
| 🟡 Usability | container_runtime fields missing from main Config struct |
| 🟡 Correctness | loadSocketOverrides ignores custom --config path |
| 🟡 Maintainability | Parallel config type risks drifting from main schema |
| 🟡 Correctness | Colima override returns TypeDocker vs TypeColima in auto-detection |
| 🟡 Test coverage | No tests for Podman/Colima overrides, invalid paths, or rt-mismatch cases |
| 🟢 Cosmetic | makeTempSocket creates a regular file, not a socket |
| 🟢 Process | PR description is empty |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4943 +/- ##
==========================================
+ Coverage 82.10% 82.12% +0.01%
==========================================
Files 931 931
Lines 94306 94330 +24
==========================================
+ Hits 77434 77468 +34
+ Misses 16867 16857 -10
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jhrozek
left a comment
There was a problem hiding this comment.
A few observations from reviewing the socket-override threading.
|
@kantord I think this is still worth merging, could you take a look at the conflicts and comments? |
absolutely, sorry for the delay |
|
Hi @jhrozek sorry for the delayed response! I kept delaying it because your suggestions seemed to make a lot of sense, but also a good understanding of Go and the codebase 😄 But I never got the time to actually sit down and do it properly. Would you mind actually pushing your suggestions directly to the branch? |
|
Support. I originally treated this as Linux-only docker.sock config. That was wrong: The April Claude review that said Windows would not compile is stale. The current head already updates the Windows signature. What still looks open from a Windows box:
Rebase is more than conflict markers. On current main, Follow-up, not a reason to NACK: if someone puts a I will not open a second PR on #4612 while this one is open. If a Windows DialPipe test plus an |
# Conflicts: # pkg/config/config.go # pkg/container/docker/sdk/client_unix.go # pkg/container/docker/sdk/client_unix_test.go # pkg/container/docker/sdk/client_windows.go # pkg/container/docker/sdk/factory.go
Rework the config-file socket overrides on top of main's multi-candidate socket discovery and address review feedback: - Each runtime now only consults its own container_runtime field, so a stale podman_socket no longer fails the Docker and Colima probes in NewDockerClient's per-runtime loop (Unix and Windows). - A Colima override reports runtime.TypeColima, matching auto-detection and the TOOLHIVE_COLIMA_SOCKET env var on main. - Read the config file without xdg.ConfigFile's directory-creation side effect, and document why pkg/config's Provider cannot be used (import cycle). - Cover per-runtime gating, env-over-config precedence, override replacing auto-detection, the best-effort YAML loader, and container_runtime surviving a config rewrite. - Document the config file entries alongside the env var overrides. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Summary
Users with non-standard container socket paths have to set
TOOLHIVE_DOCKER_SOCKET,TOOLHIVE_PODMAN_SOCKET, orTOOLHIVE_COLIMA_SOCKETin every shell session or wrapper script. GUI and CLI processes can inherit environment variables differently depending on how they are launched, so it is easy to misconfigure and hard to debug (user report in #4612).container_runtimeblock to~/.config/toolhive/config.yamlso socket paths can be set once and apply however ToolHive is launched.podman_socketrules out Podman but does not stop Docker or Colima detection inNewDockerClient's per-runtime loop. This applies on Unix and Windows.runtime.TypeColima, the same as auto-detection andTOOLHIVE_COLIMA_SOCKET.ContainerRuntimetoconfig.Configso a config write (thv config set-*,UpdateConfig) keeps a hand-editedcontainer_runtimeblock instead of dropping it.Fixes #4612
Type of change
Test plan
task test). The only local failures were inpkg/plugins/pluginsvcSSRF tests. They also fail on cleanmainwhenTOOLHIVE_DEVis set in the shell, and pass with it unset.golangci-linton the touched packages, includingGOOS=windowsforpkg/container/docker/sdk. A full localtask lint-fixhits an unrelated staticcheck panic with the go1.27 toolchain.)New tests:
TestFindPlatformContainerSocket_ConfigOverride: Podman, Docker, and Colima overrides are used and report the right runtime type. A nonexistent path returns an error.TestFindPlatformContainerSocket_ConfigOverrideOnlyAppliesToItsRuntime: a stalepodman_socketfails the Podman probe, and Docker auto-detection still runs.TestFindPlatformContainerSocket_ConfigOverrideReplacesAutoDetection: a configured socket is the only candidate.TestFindPlatformContainerSocket_EnvOverridesConfig: the env var wins over the config file.TestLoadSocketConfigFromPath: covers a missing file, an empty file, malformed YAML, a missing block, a block with the wrong shape, a partial block, and a full block.TestUpdateConfigAtPath_PreservesContainerRuntime:container_runtimesurvives a config rewrite.Does this introduce a user-facing change?
Yes.
Before: socket paths could only be overridden with
TOOLHIVE_*_SOCKETenvironment variables.After: they can also be set in
~/.config/toolhive/config.yaml:Environment variables still take precedence. On Windows,
docker_socketandpodman_sockettake named pipe paths andcolima_socketis ignored. This is documented indocs/arch/01-deployment-modes.md.Special notes for reviewers
TOOLHIVE_*_SOCKETvariable applies to every runtime probe, which is existing behavior onmainthat this PR leaves unchanged. Config entries only apply to their own runtime, so a broken entry for one runtime cannot block the others.pkg/config's Provider:pkg/configimportspkg/container/docker/sdktransitively (throughpkg/transport→pkg/container), so the SDK package reads thecontainer_runtimeblock of the default XDG config file directly. As a result, providers injected throughconfig.RegisterProviderFactorydo not supply socket overrides. This is noted in theloadSocketConfigdoc comment.SocketConfiglives inpkg/container/runtimeso both packages share one type.xdg.ConfigFileso the probe does not create directories.GOOS=windowsbut not exercised at runtime.thv configsubcommands to set these values, and handlingunix://URLs for AF_UNIX sockets on Windows.🤖 Generated with Claude Code