Skip to content

chore(deps): migrate Docker client from docker/docker to moby/moby/client - #150

Merged
christophrj merged 5 commits into
crossplane-contrib:mainfrom
n-losse:add-retrieveDigest-tests
Sep 30, 2026
Merged

christophrj merged 5 commits into
crossplane-contrib:mainfrom
n-losse:add-retrieveDigest-tests

Conversation

@n-losse

@n-losse n-losse commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds unit tests for retrieveDigest by extracting a narrow imageInspector interface and a newDockerClient var (same stub pattern already used in internal/docker), allowing the Docker daemon to be replaced with a fake in tests
  • Migrates github.com/docker/docker v28.5.2+incompatible → github.com/moby/moby/client v0.6.0 (the new standalone module); the old monorepo dep is fully removed from go.mod
  • Uses mobbyclient.New() replacing the deprecated NewClientWithOpts + WithAPIVersionNegotiation (negotiation is now the default in the new client)

Why

Sec scan on repo using xp-testing got vulns in docker.

[High] Security violation: Vulnerabilities detected in docker/docker@v28.5.2

Test plan

  • go test ./pkg/xpenvfuncs/... -run TestRetrieveDigest — all 4 new cases pass
  • go build ./... — compiles clean
  • go test ./... — no regressions

@n-losse
n-losse force-pushed the add-retrieveDigest-tests branch from ee50f47 to 75084b3 Compare September 29, 2026 14:37
@n-losse
n-losse marked this pull request as draft September 29, 2026 14:40
@n-losse
n-losse marked this pull request as ready for review September 29, 2026 14:49

@gergely-szabo-sap gergely-szabo-sap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

Extract a narrow imageInspector interface and newDockerClient var so the
Docker client can be stubbed in tests without a real daemon. Covers the
four meaningful cases: digest extracted, empty RepoDigests, ImageInspect
error, and client construction error.

This also makes the function's behaviour explicit ahead of the planned
github.com/docker/docker → github.com/moby/moby/client migration.

Signed-off-by: Nikolas Losse <nikolas.losse@sap.com>
…ient

Replace github.com/docker/docker v28.5.2+incompatible with the new
standalone module github.com/moby/moby/client v0.6.0. The old monorepo
dep is fully removed from go.mod.

Code changes in pkg/xpenvfuncs:
- Import paths updated to github.com/moby/moby/{client,api/types/image}
- imageInspector interface and newDockerClient var updated to use the new
  ImageInspectResult return type (which embeds image.InspectResponse, so
  RepoDigests access is unchanged)
- newDockerClient uses mobbyclient.New() replacing the deprecated
  NewClientWithOpts+WithAPIVersionNegotiation (negotiation is now the default)

Signed-off-by: Nikolas Losse <nikolas.losse@sap.com>
Signed-off-by: Nikolas Losse <nikolas.losse@sap.com>
@n-losse
n-losse force-pushed the add-retrieveDigest-tests branch from 56e2364 to 1317c13 Compare September 30, 2026 07:53

@christophrj christophrj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @n-losse ❤️ I have only one question regarding the replacement, please see my comment.

Comment thread pkg/xpenvfuncs/xpenvfuncs.go Outdated
mobyclient.New() does not read DOCKER_HOST, DOCKER_API_VERSION,
DOCKER_CERT_PATH or DOCKER_TLS_VERIFY unless FromEnv is passed.
WithAPIVersionNegotiation stays dropped as it is a deprecated no-op.

Signed-off-by: Nikolas Losse <nikolas.losse@sap.com>
Signed-off-by: Nikolas Losse <nikolas.losse@sap.com>
@christophrj
christophrj merged commit 0fcd5c2 into crossplane-contrib:main Sep 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants