Repository navigation
fix: generate apko_image .lock target for root-package and lock-less configs - #429
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
…configs
The apko_image macro adds a companion `<name>.lock` target (and the
deprecated `<name>.resolve`) when the config is a `.yaml` file in the
same package. That code broke in two layouts:
1. It checked for `<config>.lock.json` with `native.glob([...])` and no
`allow_empty`. Bazel 8 turned `--incompatible_disallow_empty_glob` on
by default, so any package whose apko_image config has no lock file
next to it (for example, when the lock lives in another package or
has another name) failed to load with "glob pattern 'apko.lock.json'
didn't match anything". The `.resolved.json` glob next to it already
had `allow_empty = True`. The lock glob now has it too, so the
companion target is just skipped.
2. The output path was built as "{package}/{lock}". In the root package
that gives `--output=/apko.lock.json`, so `bazel run //:<image>.lock`
wrote to the filesystem root rather than the workspace root, where
apko_run starts apko. This is the bug fixed for apko_lock in chainguard-dev#163. Both
targets now use paths.join, which keeps the path workspace-relative.
Tests (e2e/smoke):
- lock_in_other_package/ builds an apko_image whose config has no
adjacent lock file and uses //:apko.lock.json. Without the fix, the
package fails to load on Bazel 8+.
- lock_target_output_test runs genquery on //:lock.lock and checks that
the lock is written to "apko.lock.json". Without the fix it sees
"/apko.lock.json" and fails.
The README now says when the `.lock` target exists and points to
apko_lock for other layouts.
Fixes chainguard-dev#428
Rodrigo-Munoz-Salas
added a commit
that referenced
this pull request
Nov 30, 2026
## What Regenerates the four lock files that pin Alpine `musl-1.2.5-r11`, which `dl-cdn.alpinelinux.org` no longer serves: - `e2e/smoke/apko.lock.json` - `e2e/smoke/multifile_config/apko.generated.lock.json` - `e2e/smoke/multifile_config/base_config.apko.lock.json` - `examples/lock/apko.lock.json` They now pin `musl-1.2.5-r12`. The toolchain's apko (v1.4.6) also records each keyring's content in the lock, so that appears in the diff too. ## Why Since 2026-11-09, every build that fetches these locks fails with a 404 on `musl-1.2.5-r11.apk`. That keeps CI red on main and on every open pull request, including the apko bump in #407, and blocks the weekly release. The BCR presubmit runs `e2e/smoke //...`, so it would fail the same way for any release that ships these locks (#408). ## How - `examples/lock/apko.lock.json` and `apko.generated.lock.json` come from their lock targets, `bazel run //examples/lock:lock.lock` and `bazel run //multifile_config:lock_from_generated_config` in `e2e/smoke`. - `e2e/smoke/apko.lock.json` and `base_config.apko.lock.json` come from the same apko binary, run with `apko lock` from the repository root so each keeps its original `config.name`. The root-package lock target (`//:lock.lock` in `e2e/smoke`) writes to `/apko.lock.json` and fails, which #429 fixes. ## Testing - `bazel test //...` in `e2e/smoke`: 4 of 4 pass. - `bazel test //...` at the repository root: 6 of 6 pass, including `//examples/lock:test`. - No lock file in the repository pins `musl-1.2.5-r11` any more. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #428.
The
apko_imagemacro adds a companion<name>.locktarget when its config is a.yamlfile in the same package. That code broke in two layouts:native.glob([lock_json_name])withoutallow_empty. Bazel 8 turned on--incompatible_disallow_empty_globby default, so the package failed to load when the lock was in another package or had another name. It now passesallow_empty = True, as the.resolved.jsonglob below it already did, and the.locktarget is just not generated."{package}/{lock}", which turns into--output=/apko.lock.jsonwhen the package is"", sobazel run //:<image>.lockwrote to the filesystem root. Both.lockand.resolvenow usepaths.join, the same fix Update apko_lock.bzl #163 made inapko_lock.The README now says when the
.locktarget exists and points toapko_lockfor other layouts.Tests
Both new tests are in
e2e/smoke, and both fail onmain://lock_in_other_package:testbuilds anapko_imagewhose config is a copy of//:apko.yamland has no adjacent lock file. It uses@example_lock//:contents, which comes from//:apko.lock.json. Onmainthe package fails to load withError in glob: glob pattern 'apko.lock.json' didn't match anything.//:lock_target_output_testrunsgenqueryon//:lock.lockand checks that it writes to"--output=apko.lock.json". Onmainthe query shows"--output=/apko.lock.json", and the test fails.Validation
bazel run //:lock.lockine2e/smokeranapko lock ./apko.yaml '--output=apko.lock.json'and updatede2e/smoke/apko.lock.jsonin the workspace.bazel test //...ine2e/smokepasses on Bazel 9.1.0, 8.3.0 and 7.6.1 (6/6), and the CI aquery check still finds nono-remote-exec. Without theapko_image.bzlchange, the glob error and the failinglock_target_output_testboth come back.//apko/tests,//docs(unchanged),//examples/simpleand//examples/wolfi-basepass, and//.github/workflows:buildifier.checkis clean.Note: Alpine has removed
musl-1.2.5-r11, which the checked-ine2e/smokeandexamples/locklock files pin. With a cold repository cache those repos 404 onmaintoo, which is why the7.6.1, e2e/smokelane fails there. For the local runs above I relocked the two e2e lock files on my machine and did not commit them. I left relocking out of this PR because #418 already touches those files.