Repository navigation
refactor: move the config-hash helpers to internal/confighash - #14405
Merged
Merged
Conversation
ServiceHash, NetworkHash and VolumeHash only serve Compose's own change detection (the config-hash labels stamped on containers, networks and volumes); they have no business being part of the exported API of pkg/compose. Move them, with their tests, to internal/confighash. The hashes are byte-for-byte unchanged (the golden values test moves with the code, and `compose config --hash` prints the same output before and after). The only dependency on the package they came from, a sorted-keys helper, is replaced by slices.Sorted(maps.Keys(...)). This removes exported symbols from the /v5 module: compose.ServiceHash, compose.NetworkHash and compose.VolumeHash. Part of docker#14396 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 of 15 tasks
dock-tor
approved these changes
Oct 29, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does, in one sentence
Moves the
ServiceHash,NetworkHashandVolumeHashhelpers out of the exported API ofpkg/composeinto a newinternal/confighashpackage, without changing a single computed hash.Context
These helpers compute the config-hash labels that Compose stamps on the containers, networks and volumes it creates, and compares on the next run to decide whether a resource must be recreated. They only serve Compose's own change detection, yet they are exported from
pkg/composeand therefore part of the public surface of the/v5module. This is one of the items of the "Public surface" section of #14396.What the PR brings
internal/confighash. Callers inpkg/composeandcmd/composeonly get a qualified call, nothing else changes there.up. The golden-values test that already pinned known hashes moves with the code and passes unchanged, andcompose config --hash '*'run on a sample project with the binary built frommainand from this branch prints the same output.sortedKeyshelper. Rather than exporting it or sharing it, the helper's one use is replaced byslices.Sorted(maps.Keys(...)), which orders string keys identically;sortedKeysstays untouched inreconcile.gofor its other callers./v5module:compose.ServiceHash,compose.NetworkHashandcompose.VolumeHash. That is the intent of the epic item.Plan,Operation,ObservedStateandGraph, which will leave the exported API with the plan-engine extraction, to avoid churn in the files where other PRs are open.Why this is the right next brick
It is a pure move with no dependency on the rest of
pkg/compose, so it shrinks the public surface with no behavioral risk and no conflict with the in-flight reconcile work: the diff in those files is limited to the call sites.Part of #14396
🤖 Generated with Claude Code