Repository navigation
refactor(publish): pin the backend wiring, share the digest resolver - #14501
Conversation
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| const indexDigest = "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" | ||
| mockAPI.EXPECT(). | ||
| DistributionInspect(ctx, "docker.io/library/foo:1", gomock.Cond(func(options client.DistributionInspectOptions) bool { | ||
| return options.EncodedRegistryAuth != "" |
There was a problem hiding this comment.
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)
| } | ||
| } | ||
| jobsAsServices, err = jobsAsServices.WithImagesResolved(s.backend.ImageDigestResolver(ctx)) | ||
| jobsAsServices, err = jobsAsServices.WithImagesResolved(registry.ImageDigestResolver(ctx, s.backend.AuthProvider(), s.backend.APIClient())) |
There was a problem hiding this comment.
nit: the resolver is built twice with the same arguments (here and at line 362); build it once at the top of generateImageDigestsOverride.
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>
1d84afd to
cc28ee0
Compare
Follow-up to the review of #14409.
publishBackend, modelled onTestImagesBackendWiring.publishBackend.Pushwhy it must stay the unexportedpush.registry.ImageDigestResolver, used bypullandinternal/publish. This removes the copy in the publish test fake andBackend.ImageDigestResolver, which was redundant withAPIClient()+AuthProvider().No behavior change.
🤖 Generated with Claude Code