Skip to content

refactor(publish): pin the backend wiring, share the digest resolver - #14501

Merged
glours merged 4 commits into
docker:mainfrom
glours:follow-up-publish-backend
Nov 16, 2026
Merged

glours merged 4 commits into
docker:mainfrom
glours:follow-up-publish-backend

Conversation

@glours

@glours glours commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to the review of #14409.

  • Add a wiring test for publishBackend, modelled on TestImagesBackendWiring.
  • Document on publishBackend.Push why it must stay the unexported push.
  • Move the image digest resolver to registry.ImageDigestResolver, used by pull and internal/publish. This removes the copy in the publish test fake and Backend.ImageDigestResolver, which was redundant with APIClient() + AuthProvider().

No behavior change.

🤖 Generated with Claude Code

@glours
glours requested review from a team as code owners November 13, 2026 10:03
@glours
glours requested a review from ndeloof November 13, 2026 10:03
@glours glours changed the title Follow up publish backend refactor(publish): pin the backend wiring, share the digest resolver Nov 13, 2026

@docker-agent docker-agent 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.

Assessment: 🟢 APPROVE

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/registry/registry.go 72.72% 3 Missing ⚠️
pkg/compose/pull.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ndeloof ndeloof 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.

Needs one fix before merging: the credentials check in internal/registry/registry_test.go is vacuous (inline). One nit inline too.

Comment thread internal/registry/registry_test.go Outdated
const indexDigest = "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
mockAPI.EXPECT().
DistributionInspect(ctx, "docker.io/library/foo:1", gomock.Cond(func(options client.DistributionInspectOptions) bool {
return options.EncodedRegistryAuth != ""

@ndeloof ndeloof Nov 14, 2026 •

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.

EncodedRegistryAuth != "" is always true, since EncodedAuth encodes even an empty AuthConfig: the test stays green if the credentials are dropped, and with the old credentials assertion on the publish side gone, nothing pins them anymore. Decoding the header fixes it (passes on the PR, fails with an empty-auth provider):

gomock.Cond(func(options client.DistributionInspectOptions) bool {
	decoded, err := authconfig.Decode(options.EncodedRegistryAuth)
	return err == nil && decoded.Username == "user" && decoded.Password == "secret"
})

(import github.com/moby/moby/api/pkg/authconfig)

Comment thread internal/publish/publish.go Outdated
}
}
jobsAsServices, err = jobsAsServices.WithImagesResolved(s.backend.ImageDigestResolver(ctx))
jobsAsServices, err = jobsAsServices.WithImagesResolved(registry.ImageDigestResolver(ctx, s.backend.AuthProvider(), s.backend.APIClient()))

@ndeloof ndeloof Nov 14, 2026 •

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.

nit: the resolver is built twice with the same arguments (here and at line 362); build it once at the top of generateImageDigestsOverride.

glours and others added 4 commits November 16, 2026 15:20
The publish tests run against their own fake backend, so nothing checked
the adapter between a composeService and internal/publish. Pin it the way
TestImagesBackendWiring pins the images one: the accessors follow the
service, dry run follows s.dryRun, a refused prompt stays refused, Push
reaches the unexported push with its options (the public Push would open a
second "push" bracket inside the "publish" one), and the image digest
resolver uses the caller's context and the service's credentials.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
Publish already runs inside the "publish" progress bracket, and the public
Push would open a second one. The comment in internal/publish only covers
the other half of that invariant.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
…publish

fakeBackend.ImageDigestResolver in the publish tests was a verbatim copy of
imageDigestResolver in pkg/compose, and Backend.ImageDigestResolver was
redundant with APIClient() + AuthProvider().

Move the resolver to registry.ImageDigestResolver, call it from pull and from
internal/publish, and drop the method from the Backend interface, from
publishBackend and from the fake. The publish digest tests now run on the real
helper. The resolver test moves with it and also pins the caller's context and
a non-empty registry auth, which the publishBackend wiring test used to cover.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
The credentials assertion in TestImageDigestResolverUsesDistributionDigest
was vacuous: EncodedAuth encodes even an empty AuthConfig, so
EncodedRegistryAuth != "" always holds. Decode the header and check the
username and password instead.

Build the digest resolver once in generateImageDigestsOverride rather than
once for the services and once for the jobs.

Move the "registry descriptor digest, not the local content digest"
rationale from the pkg/compose wrapper onto registry.ImageDigestResolver,
where the code now lives.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
@glours
glours force-pushed the follow-up-publish-backend branch from 1d84afd to cc28ee0 Compare November 16, 2026 14:36

@ndeloof ndeloof 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.

@glours
glours merged commit 6430a45 into docker:main Nov 16, 2026
115 of 117 checks passed
@glours
glours deleted the follow-up-publish-backend branch November 16, 2026 15:59
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