Skip to content

Extract portable Chef Supermarket metadata transformations - #806

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

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

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Part of #501, the Chef step.

As in #612 for npm, the Chef Supermarket metadata transformations move out of internal/handler into internal/metadata/chef:

  • RewriteUniverse, RewriteCookbook and RewriteVersion, which point the universe's location_path and download_url, a cookbook's version URLs, and a version's cookbook and file URLs at the proxy, and RewriteVersionURL for a single version URL
  • APIURL, CookbookURL, VersionURL and DownloadURL, where the proxy serves each document and archive
  • NormalizeVersion, which accepts both 1.2.3 and Berkshelf's 1_2_3
  • EncodeJSON, which keeps dependency constraints such as >= 1.0 unescaped

Chef has no cooldown filtering, so Options only carries the proxy URL. The package doesn't depend on handler.Proxy. The code moves as it was, so the bytes served are the same.

What stays in the handler: fetching, the metadata and rewrite caches, routes, request validation, cache keys and downloads. The handler's functions stay as thin wrappers, so the handler tests run unchanged against the real routes. encodeChefJSON stays as a wrapper too, since the Terraform handler uses it.

Portability: GOOS=wasip1 GOARCH=wasm go build ./internal/metadata/chef works. The package imports only the standard library; imports_test.go fails on any non-standard import and on net, net/http, log/slog or database/sql.

New tests in internal/metadata/chef cover each rewrite, null and unrecognised version URLs, fields left as they are, documents of the wrong shape, name and version escaping, version normalisation and the unescaped encoding. They were mutation-checked, as was the handler's wiring. There are no Chef benchmarks to compare. go test ./... and golangci-lint run ./... pass.

The rewrites of the universe, cookbook and cookbook version documents,
which point download locations at the proxy, move out of
internal/handler into internal/metadata/chef with the proxy URL as an
explicit input. The handler keeps fetching, caching and downloads, and
its functions stay as thin wrappers. The package imports only the
standard library and builds for wasip1.
@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 48 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: a547a36e-f4a5-4c46-a1c3-d1fae877c87d
Commits

Reviewing files that changed from the base of the PR and between be51120 and 5a77eb7.

Files selected for processing: 4

  • internal/handler/chef.go
  • internal/metadata/chef/imports_test.go
  • internal/metadata/chef/metadata.go
  • internal/metadata/chef/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