Repository navigation
refactor(compose): move images and image pruning to internal/images - #14406
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! |
efbe493 to
9403193
Compare
9403193 to
8a88222
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
8a88222 to
7700dcb
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
glours
left a comment
There was a problem hiding this comment.
No blocker; see inline for the one gap the move opens. Nits, no inline:
internal/images/images.go:57-60redeclaresAPIClient/MaxConcurrency, whichinternal/engine.Backendalready states (be24566). Embedding it would force the fake inimages_test.goto implementContainers/SpecifiedContainer, so a narrowBackendis defensible (asrelay/projectloader) — say so in its doc comment rather than leaving it to look like an oversight.apiVersion148/apiVersion149exist in bothinternal/images/images.go:49,52andpkg/compose/api_versions.go:39,50(the latter still used bycreate.go). A cross-reference in the two comments avoids drift.- Comments in
internal/naming symbols that only exist inpkg/compose:prune.go:76(isOrphaned),prune.go:163,167,175,189(removeResource,removeDanglingImagesOp,removeTaggedImagesOp),prune_test.go:38,79. Namedowninstead. pkg/compose/provider_images.go:133still points toimages.go:279-291, which now lives ininternal/images.internal/images/images.go:231:Summarizeis now exported without a doc comment.internal/images/prune_test.go:132-133still sayImagePruner/ImagePruneOptions; the types arePruner/PruneOptionshere.
Move the images command, the identity of a local image and the removal of project images out of pkg/compose into internal/images, behind a small Backend interface. composeService keeps one-line forwarders so its callers (build, pull, down, watch) don't change, and ImagePruner, ImagePruneOptions and NewImagePruner stay exported as aliases. No behavior change. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
7700dcb to
9f178b8
Compare
…y the move Add TestImagesBackendWiring: the images tests now run against their own fake backend, so nothing checked that the adapter follows the service's concurrency bound and the negotiated API version. Comments only otherwise: say why Backend is narrow rather than embedding engine.Backend, cross-reference the API version constants declared in both packages, name down instead of the pkg/compose symbols, point provider_images to LocalContentDigest, document Summarize, and use the Pruner and PruneOptions names. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
|
Thanks for the review. Addressed in 578ec1c, keeping the PR a move: the wiring test, and the comment-only nits — |
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Clean refactor — no behavioral regressions found. The Backend interface is correctly wired through imagesBackend to the existing composeService fields, the type aliases preserve the public SDK surface, and all moved tests pass through the new Service/Pruner layer correctly.
Lower-confidence findings (not posted inline)
-
[low]
internal/images/images_test.go—anyCancellableContext()usescontext.Background()instead oft.Context()in new test code. A//nolint:forbidigosuppression is in place (the context is used only for a gomock type matcher, not for real test execution), but this deviates from the project convention in AGENTS.md. Considercontext.WithCancel(t.Context())to stay consistent and ensure automatic cancel-on-cleanup. -
[low]
pkg/compose/api_versions.go:33/internal/images/images.go—apiVersion148andapiVersion149are now defined in both packages, enforced in sync only by a comment. This is a maintenance hazard introduced by the split: a future addition to the images package's version gates may not be mirrored inpkg/compose(or vice versa). Consider centralising the two constants in a shared internal package (e.g.,internal/api) once the remaining files move.
What this PR does, in one sentence
Moves the
imagescommand, the identity of a local image and the removal of project images (down --rmi,watch --prune) out ofpkg/composeinto a newinternal/imagespackage, with no change in behavior.Context
pkg/composeis one flat package where every operation is a method of the samecomposeService, so nothing but convention keeps a read-only command likeimagesfrom reaching the lifecycle code. #14396 splits it into focusedinternal/packages, one reviewable move at a time; #14331, #14333 and #14397 settled the pattern.What the PR brings
internal/imagesholds the code ofimages.goandimage_pruner.go. It declares what it needs from the engine as a four-methodBackend(the API client, the concurrency bound, the negotiated API version, and the classification of a removal error shared with the removal of the other resources) and cannot importpkg/compose.composeServiceimplementsBackendand keeps one-line forwarders under the names the rest of the package already calls, sobuild,pull,provider_images,downandwatchare not touched.ImagePruner,ImagePruneOptionsandNewImagePrunerstay exported as aliases, so the SDK surface does not change.composeServiceto aServiceover a small fakeBackend(TestImages,TestImagesMissingImageRecord,TestMatchLocalManifest,TestMatchLocalManifestWithoutImageData,TestInspectLocalImages*,TestInspectLocalContent,TestCanonicalBuiltDigest, and the four pruner tests).TestPlatformPinnedDigestandTestServiceImageDigeststay inpkg/compose:serviceImageDigestdepends on thepinnedImageDigesttype ofbuild.go, so it stays there too. Thee2escenarios touchingimagesanddown --rmipass as well.pull,pushandprovider_images, which are touched by open PRs. The digest helpers they andbuilduse (localContentDigest,inspectLocalContent,canonicalBuiltDigest, ...) are already in the new package, andpkg/composeforwards to them until those files move.internal/concurrencyfor the bounded errgroups,internal/namingfor the project filter, the service selection and the canonical container name. The only things still local to the package are the two Engine API version constants (1.48 and 1.49), whichpkg/composealso keeps privately.Why this is the right next brick
It is the part of the "Images" item of #14396 that no open PR touches.
pull,pushandprovider_imagescan join the same package afterwards, and what they share with it (the image identity helpers) is already there.Part of #14396
🤖 Generated with Claude Code