Repository navigation
fix: preserve configured repository order during build, lock, and resolution - #2578
Open
trukhinyuri wants to merge 1 commit into
Open
trukhinyuri wants to merge 1 commit into
trukhinyuri wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Repository precedence incorrectly changes resolution between differently named virtual providers.
2 open findings
What changed in this PR
Preserves configured repository order during image builds, locking, and package resolution.
Changes:
- Deduplicates repositories without sorting.
- Adds repository-order resolution tie-breaking.
- Adds repository-order regression tests.
| File | Description |
|---|---|
pkg/build/apk.go |
Preserves repository order during builds. |
pkg/build/lock.go |
Preserves order in locked configurations. |
pkg/build/build_test.go |
Tests build and lock ordering. |
pkg/apk/apk/repo.go |
Tracks repository indexes for resolution. |
pkg/apk/apk/repo_test.go |
Tests resolution tie-breaking. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
trukhinyuri
force-pushed
the
fix/preserve-repository-order-2559
branch
2 times, most recently
from
October 14, 2026 08:56
63d629d to
fc90ab4
Compare
trukhinyuri
force-pushed
the
fix/preserve-repository-order-2559
branch
from
November 30, 2026 02:44
fc90ab4 to
84a50e8
Compare
Author
|
Rebased onto latest |
…s by repo index Preserve configured repository order across ImageConfiguration locking, extra-repository merging, and package resolution, and break equal-version ties for identical package names by repository order while preserving package-name tie-breaking across distinct virtual providers. Fixes chainguard-dev#2559 Signed-off-by: Yuri (IURII) Trukhin <yuri@trukhin.com>
trukhinyuri
force-pushed
the
fix/preserve-repository-order-2559
branch
from
November 30, 2026 03:50
84a50e8 to
c5df509
Compare
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.

Summary
When multiple repositories provide the same package name and version, APK resolves the first matching repository in
/etc/apk/repositories. Previously:apk.SetRepositoriesdeduplicated via map iteration +slices.Sort, overwriting user-configured repository order with alphabetical sorting.pkg/build/apk.goandpkg/build/lock.gocalleduniqify(which also sorts alphabetically) onic.Contents.Repositoriesandic.Contents.BuildRepositories.This change preserves the first-seen declaration order while deduplicating repositories across
SetRepositories,build, andlock, and breaks ties inResolveWorld/ResolvePackageby repository order when version, pin preference, and provider priority are equal.Fixes #2559
Verification
pkg/apk/apk/repo_test.goandpkg/build/build_test.go.go test -race -v ./pkg/apk/apk ./pkg/build.