feat(mirror): thread recipe-bound DataProvider through manifest reads#1123
Conversation
`extractManifestImages` was reading manifest files via `recipe.GetManifestContentWithContext(ctx, nil, ...)`, which always falls back to the package-global embedded provider. The sibling component-values call uses the recipe-bound provider, so `aicr mirror --data <dir>` was reading values from the overlay but manifests from embedded — inconsistent with `aicr bundle --data` and surprising when an overlay manifest shadows an embedded path. Plumb `rec.DataProvider()` through both ManifestFiles and PreManifestFiles call sites. A nil provider keeps the embedded fallback inside `recipe.GetManifestContentWithContext`, preserving back-compat for recipes built outside the Builder path. Tests cover both the overlay-honored path (in-memory provider supplies the only copy of the manifest) and the embedded-fallback path (no bound provider, embedded manifest still resolves). Mirror package coverage 68.1% -> 71.2%. Docs updated: mirror godoc, air-gap-mirror.md, cli-reference.md (mirror list flag table now lists `--data`). Closes #1122
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR threads the recipe-bound Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Coverage Report ✅
Coverage BadgeMerging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. |
Summary
pkg/mirror.extractManifestImagesnow reads ManifestFiles / PreManifestFiles through the recipe's boundDataProvider, soaicr mirror --data <dir>honors overlay-provided manifests the same way it already honors overlay-provided component values.Motivation / Context
extractManifestImageswas callingrecipe.GetManifestContentWithContext(ctx, nil, mPath)— thenilfalls back to the package-global embedded provider. The sibling component-values call (rec.GetValuesForComponentWithContext) already uses the recipe-bound provider, so mirror was reading values from--databut manifests from embedded. That inconsistency was flagged by @yuanchen8911 during PR #1121 review and predates #1121.Fixes: #1122
Related: #1109, #1121
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)docs/,examples/)pkg/mirrorImplementation Notes
Lister.Discoverreadsrec.DataProvider()once per component and passes it down toextractManifestImagesfor bothManifestFilesandPreManifestFilesloops.extractManifestImagesgained adp recipe.DataProviderparameter. A nil provider keeps the embedded fallback insiderecipe.GetManifestContentWithContext, so recipes loaded outside the Builder path (no bound provider) still resolve embedded manifests unchanged.Discover— overlay-aware manifest reading happens automatically when the recipe was built via aBuilderbound withWithDataProvider, which is whataicr mirror --dataalready does.Testing
go test -race ./pkg/mirror/... ./pkg/recipe/... golangci-lint run -c .golangci.yaml ./pkg/mirror/...TestDiscover_HonorsRecipeBoundDataProviderForManifestsproves a recipe-bound in-memory provider supplying a manifest atcomponents/network-operator/manifests/overlay-only.yamlis what mirror actually reads (image extracted, no warnings).TestDiscover_NilDataProviderFallsBackToEmbeddedpins the back-compat path: no bound provider, embeddednfd-network-rule.yamlstill resolves.pkg/mirrorpackage coverage: 68.1% → 71.2% (+3.1%).pkg/recipetests pass (no API change required there —RecipeResult.DataProvider()already existed).Risk Assessment
Rollout notes: Pure bug fix.
Lister.Discoversignature unchanged;extractManifestImagesis package-private. Recipes loaded outside the Builder path keep the embedded fallback throughGetManifestContentWithContext's nil-provider handling.Checklist
make testwith-race)make lint)docs/user/air-gap-mirror.md,docs/user/cli-reference.md)git commit -S)