Skip to content

feat(docker): use docker/go-sdk for daemon client#522

Draft
skevetter wants to merge 1 commit into
mainfrom
hulking-pony
Draft

feat(docker): use docker/go-sdk for daemon client#522
skevetter wants to merge 1 commit into
mainfrom
hulking-pony

Conversation

@skevetter

@skevetter skevetter commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

First incremental step toward adopting github.com/docker/go-sdk. Replaces the hand-rolled Docker daemon client in pkg/docker/client.go with the high-level go-sdk client (pinned to v0.1.0-alpha013).

NewClient now delegates to sdkclient.New, which performs FromEnv configuration, API-version negotiation, and a daemon health check during construction — subsuming the previous two-step (FromEnv → bare fallback) plus manual NegotiateAPIVersion logic. Client embeds sdkclient.SDKClient (which embeds the moby APIClient).

Scope & safety

This is deliberately the only daemon-API seam in the codebase. The single production consumer is the internal BuildKit build strategy (pkg/driver/docker/build.go), which needs DialHijack/Close — both satisfied by the embedded client. The CLI-shellout helper, runtime detection, and compose code are untouched, so podman/nerdctl/buildx support is unaffected.

Migrating the CLI-based paths (inspect/ps/run/pull) is intentionally out of scope: go-sdk is Docker-daemon-only, so those would need runtime gating to avoid regressing non-Docker runtimes.

Note: the SDK is currently alpha (v0.1.0-alpha013); API churn is expected before 1.0.

Verification

  • go build ./... — clean
  • go test ./pkg/docker/... ./pkg/driver/docker/... — pass
  • golangci-lint run --new-from-rev=main pkg/docker/... — 0 issues

Summary by CodeRabbit

  • Bug Fixes

    • Improved Docker client initialization for more reliable connections and better compatibility with newer Docker environments.
    • Removed a fallback path that could lead to inconsistent client setup, helping connection failures surface more clearly.
  • Chores

    • Updated project dependencies to include newer Docker-related and environment parsing libraries.

Replace the hand-rolled docker daemon client in pkg/docker/client.go with
the high-level github.com/docker/go-sdk client (v0.1.0-alpha013).

NewClient now delegates to sdkclient.New, which performs FromEnv
configuration, API-version negotiation, and a daemon health check during
construction, so the previous two-step (FromEnv then bare fallback) plus
manual NegotiateAPIVersion logic is no longer needed.

Client embeds sdkclient.SDKClient, which embeds the moby APIClient. The
only daemon-API consumer is the internal BuildKit build strategy, which
needs DialHijack/Close - both satisfied by the embedded client. The
CLI-shellout helper, runtime detection, and compose code are untouched,
so podman/nerdctl/buildx support is unaffected.
@netlify

netlify Bot commented Jun 24, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 569af19
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a3b33f2fde8cc0008901577

@netlify

netlify Bot commented Jun 24, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 569af19
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a3b33f293ffa500084d6df9

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Migrates the Docker client wrapper from github.com/docker/docker/client to github.com/docker/go-sdk/client. The Client struct now embeds sdkclient.SDKClient, and NewClient is simplified to a direct sdkclient.New(ctx) call, removing the previous environment-based creation, warning log, fallback retry, and NegotiateAPIVersion call. Corresponding module dependencies are added to go.mod.

Changes

Docker SDK Client Migration

Layer / File(s) Summary
Client type and constructor rewrite
pkg/docker/client.go
Client struct embedding changed from dockerclient.CommonAPIClient to sdkclient.SDKClient. NewClient rewritten to call sdkclient.New(ctx) directly and return immediately on error, removing the environment-based creation path, fallback retry, and explicit NegotiateAPIVersion call.
Module dependency additions
go.mod
Adds direct require for github.com/docker/go-sdk/client v0.1.0-alpha013 and indirect requires for github.com/caarlos0/env/v11, github.com/docker/go-sdk/config, github.com/docker/go-sdk/context, github.com/moby/moby/api, and github.com/moby/moby/client.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: switching the Docker daemon client to docker/go-sdk.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@skevetter
skevetter marked this pull request as ready for review June 24, 2026 09:08

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
go.mod (1)

29-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pinning a pre-release (alpha) dependency on a daemon-facing path — track upgrades deliberately.

github.com/docker/go-sdk/client is pre-v1; the maintainers note the public API may change between releases until v1.0.0. Pinning to the exact v0.1.0-alpha013 tag (as done here) is the right mitigation, but plan to watch the changelog and re-validate the SDKClient/DialHijack contract on each bump, since signature changes here directly affect the BuildKit build path. Worth a brief note in the PR/migration docs that this seam depends on an alpha SDK.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@go.mod` at line 29, The dependency on github.com/docker/go-sdk/client is
intentionally pinned to the alpha release, so update the PR/migration notes to
call out that this is a pre-v1, daemon-facing seam that must be tracked
deliberately. Mention the BuildKit path and the SDKClient/DialHijack contract by
name, and add guidance that each version bump should be re-validated against the
changelog before merging.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@go.mod`:
- Line 29: The dependency on github.com/docker/go-sdk/client is intentionally
pinned to the alpha release, so update the PR/migration notes to call out that
this is a pre-v1, daemon-facing seam that must be tracked deliberately. Mention
the BuildKit path and the SDKClient/DialHijack contract by name, and add
guidance that each version bump should be re-validated against the changelog
before merging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 95a584b7-feb8-4275-8407-8a3688484375

📥 Commits

Reviewing files that changed from the base of the PR and between 1bacaf9 and 569af19.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod
  • pkg/docker/client.go

@skevetter
skevetter marked this pull request as draft June 24, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant