Repository navigation
Conversation
* Add the `helm_charts` module extension with a `chart(name, url, sha256)` tag. It takes the digest from the tag, the stored facts or the registry manifest, then declares `helm_import_repository` with it. On Bazel 8.5+ a looked-up digest is stored as a fact in `MODULE.bazel.lock`. Older Bazel records the repository and its digest in the lockfile instead. * Move the registry code from `import.bzl` to `oci_chart.bzl` so it runs with `repository_ctx` or `module_ctx`. `import_authn.bzl` blanks a file where `module_ctx` has no `delete`. * Take the chart name and version from an `oci://` url, and split an http file name at the first dash followed by a version number. A version such as `1.21.0-beta.0` no longer gives the target `cert-manager-1.21.0`. * Add unit tests for the helpers, and chart tests for a looked-up, a pinned and a pre-release chart.
rdark
force-pushed
the
richard/helm-charts-extension-facts
branch
from
October 30, 2026 13:56
2f7df94 to
f8d296e
Compare
Owner
Author
|
Opened on periareon/rules_helm instead: periareon#310 |
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.
Stacked on periareon#307. Merge that first; this PR's base is its branch.
periareon#307 lets
helm_import_repositoryfetch a pinnedoci://chart from the repository cache without contacting the registry. A review comment there asked whether the digest could be saved tofactswhensha256is not set.factsexists only for module extensions, andhelm_import_repositoryis a repository rule, so the rule cannot write them. This PR adds an extension that does.Change
helm_chartsis a new extension inhelm/extensions.bzlwith one tag:For each tag the extension takes the digest from
sha256, else from the stored facts, else from the registry manifest. It declareshelm_import_repositorywith that digest, so the cached-blob path from periareon#307 applies.MODULE.bazel.lock, keyed by the chart url. Later evaluations make no registry request for it.sha256, the extension is marked non-reproducible there, so the lockfile records the repository together with its digest.The extension is separate from
helmso that an unreachable registry cannot stop toolchain resolution.Supporting changes:
import.bzlmoved tohelm/private/oci_chart.bzland runs withrepository_ctxormodule_ctx. The rule makes the same requests in the same order with the same error messages.import_authn.bzlcalledrepository_ctx.delete, whichmodule_ctxlacks. It now blanks the file there, so a token does not stay on disk.helm/private/chart_utils.bzl, so unit tests can reach them.Behaviour change in
helm_import_repositoryThe rule recovered the chart name and version by splitting the file name
<name>-<version>.tgzat the last dash. A version that contains a dash, such as1.21.0-beta.0, gave the targetcert-manager-1.21.0instead ofcert-manager, and a wrongversioninattrs_for_reproducibility.An
oci://url now supplies the name and version exactly. An http file name is split at the first dash that is followed by a version number. Names without such a version split at the last dash, as before.Testing
tests/helm_charts/chart_utils_test.bzlcover the file name split, the url and digest checks, and the digest choice. Making the helper drop the lookup result fails the digest test, and restoring the old split fails the split test.tests/helm_charts: a looked-up chart on quay.io, a second looked-up chart on ghcr.io, a pinned chart, and a pinned pre-release chart whose target must be namedcert-manager.bazel test //...and--config=stricton macOS with Bazel 9.3.1: 70 pass, 3 skipped (the Linux-onlywith_image_deps_imgtests). I excludedtests/with_image_deps_ocilocally, because the Docker credential helper on my machine fails to pull its base image; the base branch fails the same way. On 7.7.1,//tests/helm_charts,//tests/with_external_depsand//helm/privatepass..bazelrcsets--lockfile_mode=off, so CI never stores a fact. I checked the lockfile behaviour by hand:--lockfile_mode=errorand downloads disabled fetches the chart from the lockfile without a lookup.Limits
sha256skips the lookup.sha256, the digest comes from the same registry as the chart, so it is trusted on first use.@<name>does not resolve to the chart; use@<name>//:<chart>. The alias is named with the canonical repository name, as it was before this change.429, pinsha256on the second chart.