Skip to content

Extract portable Helm metadata transformations - #810

Open
simonchrz wants to merge 1 commit into
git-pkgs:mainfrom
simonchrz:refactor/metadata-helm
Open

simonchrz wants to merge 1 commit into
git-pkgs:mainfrom
simonchrz:refactor/metadata-helm

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Part of #501, the Helm step.

As in #612 for npm, the Helm index transformations move out of internal/handler into internal/metadata/helm:

  • Rewrite: chart URLs pointing at the proxy, OCI references for configured registries pointing at the /v2 routes, cooldown filtering, and leaving out releases that can't be read; it returns the releases kept as chart@digest
  • BuildLookup and Lookup, the HTTP downloads an index lists by digest and each release's first download by chart and version, with Lists
  • ChartProxyURL and OCIProxyReference
  • ParseIndex, IndexEntries, MappingValue and NormalizeDigest

The package takes its inputs explicitly in Options: proxy URL, repository name and upstream URL, OCI registries, the cooldown policy and the time cooldown is evaluated at. It reports releases it leaves out as malformed through OnMalformed, which the handler logs as before. It doesn't depend on handler.Proxy. It has a small copy of the handler's ..-segment check for OCI references, since that lives in internal/handler.

What stays in the handler: fetching, the rewrite cache, the per-repository lookup cache, the refetch for a download the index doesn't list (#800), the download and mirror cooldown checks, and mirroring. The handler's function names stay as thin wrappers, and helmChartLookup, helmRelease and helmOCIRegistry are aliases of the package types, so the handler tests run unchanged against the real routes.

Cooldown in the rewrite is checked with Evaluate at one EvaluatedAt instead of IsAllowed per release, as in internal/metadata/npm. The handler passes time.Now(), so results are the same unless a rewrite runs across a cooldown boundary. Downloads keep IsAllowed.

Portability: GOOS=wasip1 GOARCH=wasm go build ./internal/metadata/helm works. imports_test.go fails on any non-standard import outside an allowlist (cooldown, purl, vers, packageurl-go, internal/packageurl, and gopkg.in/yaml.v3 for the index) and on net, net/http, log/slog or database/sql.

Benchmarks (BenchmarkHelmIndexRequest, main vs this branch, test binaries run alternately, n=8) show no difference beyond run-to-run noise; the machine was busy, so single runs varied a lot.

New tests in internal/metadata/helm cover the URL and OCI rewrites, cooldown evaluated at EvaluatedAt, a disabled and a missing policy, malformed releases and indexes, the lookup (first release per version, OCI releases, Lists), the OCI reference rules and digest normalisation. They were mutation-checked, as was the handler's wiring. go test ./... and golangci-lint run ./... pass.

The Helm index rewrite, the chart lookup built from an index and their
parsing move from internal/handler into internal/metadata/helm, which
takes its inputs explicitly and doesn't depend on handler.Proxy. It
builds for wasip1. The handler keeps fetching, caching, the refetch for
downloads, the download cooldown check and mirroring, with its function
names as thin wrappers.

The rewrite checks cooldown with Evaluate at one EvaluatedAt, as the npm,
PyPI and Composer packages do.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7535714a-aaf9-4000-93d6-1ec9b302c0fe
Commits

Reviewing files that changed from the base of the PR and between be51120 and 79652d9.

Files selected for processing: 6

  • internal/handler/helm.go
  • internal/handler/helm_mirror.go
  • internal/handler/helm_oci.go
  • internal/metadata/helm/imports_test.go
  • internal/metadata/helm/metadata.go
  • internal/metadata/helm/metadata_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant