Skip to content

feat(mirror): thread recipe-bound DataProvider through manifest reads#1123

Merged
mchmarny merged 1 commit into
mainfrom
feat/mirror-data-provider-manifest-1122
May 30, 2026
Merged

feat(mirror): thread recipe-bound DataProvider through manifest reads#1123
mchmarny merged 1 commit into
mainfrom
feat/mirror-data-provider-manifest-1122

Conversation

@mchmarny

Copy link
Copy Markdown
Member

Summary

pkg/mirror.extractManifestImages now reads ManifestFiles / PreManifestFiles through the recipe's bound DataProvider, so aicr mirror --data <dir> honors overlay-provided manifests the same way it already honors overlay-provided component values.

Motivation / Context

extractManifestImages was calling recipe.GetManifestContentWithContext(ctx, nil, mPath) — the nil falls 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 --data but manifests from embedded. That inconsistency was flagged by @yuanchen8911 during PR #1121 review and predates #1121.

Fixes: #1122
Related: #1109, #1121

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)
  • Docs/examples (docs/, examples/)
  • Other: pkg/mirror

Implementation Notes

  • Lister.Discover reads rec.DataProvider() once per component and passes it down to extractManifestImages for both ManifestFiles and PreManifestFiles loops.
  • extractManifestImages gained a dp recipe.DataProvider parameter. A nil provider keeps the embedded fallback inside recipe.GetManifestContentWithContext, so recipes loaded outside the Builder path (no bound provider) still resolve embedded manifests unchanged.
  • No new behavior surface for callers of Discover — overlay-aware manifest reading happens automatically when the recipe was built via a Builder bound with WithDataProvider, which is what aicr mirror --data already does.

Testing

go test -race ./pkg/mirror/... ./pkg/recipe/...
golangci-lint run -c .golangci.yaml ./pkg/mirror/...
  • New TestDiscover_HonorsRecipeBoundDataProviderForManifests proves a recipe-bound in-memory provider supplying a manifest at components/network-operator/manifests/overlay-only.yaml is what mirror actually reads (image extracted, no warnings).
  • New TestDiscover_NilDataProviderFallsBackToEmbedded pins the back-compat path: no bound provider, embedded nfd-network-rule.yaml still resolves.
  • pkg/mirror package coverage: 68.1% → 71.2% (+3.1%).
  • All pkg/recipe tests pass (no API change required there — RecipeResult.DataProvider() already existed).

Risk Assessment

  • Low — Isolated change, well-tested, easy to revert

Rollout notes: Pure bug fix. Lister.Discover signature unchanged; extractManifestImages is package-private. Recipes loaded outside the Builder path keep the embedded fallback through GetManifestContentWithContext's nil-provider handling.

Checklist

  • Tests pass locally (make test with -race)
  • Linter passes (make lint)
  • I did not skip/disable tests to make CI green
  • I added/updated tests for new functionality
  • I updated docs if user-facing behavior changed (mirror godoc, docs/user/air-gap-mirror.md, docs/user/cli-reference.md)
  • Changes follow existing patterns in the codebase
  • Commits are cryptographically signed (git commit -S)

`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
@mchmarny mchmarny requested a review from a team as a code owner May 30, 2026 11:16
@mchmarny mchmarny self-assigned this May 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 9493a203-76b6-4496-86c5-35b53ea4e3b2

📥 Commits

Reviewing files that changed from the base of the PR and between 94149a9 and c07523f.

📒 Files selected for processing (4)
  • docs/user/air-gap-mirror.md
  • docs/user/cli-reference.md
  • pkg/mirror/discover.go
  • pkg/mirror/discover_test.go

📝 Walkthrough

Walkthrough

The PR threads the recipe-bound DataProvider through manifest image extraction in mirror discovery, ensuring --data overlays are honored for manifests alongside component values. Documentation clarifies that aicr mirror list scans referenced manifests and applies --data overlays to both values and manifests. New tests validate extraction with and without a bound data provider, including an in-memory test double.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • NVIDIA/aicr#1016: Migrates manifest-content reads to use the recipe-bound DataProvider across bundler/deployer/component subsystems, sharing the same provider-plumbing pattern as this PR's mirror discovery changes.

Suggested labels

enhancement, size/M, area/docs, documentation

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: threading the recipe-bound DataProvider through manifest reads in the mirror package.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the motivation, implementation, testing, and risk assessment.
Linked Issues check ✅ Passed The PR fully addresses issue #1122's acceptance criteria by threading the recipe-bound DataProvider through manifest reads, enabling aicr mirror --data to honor overlay-provided manifests, and includes comprehensive tests.
Out of Scope Changes check ✅ Passed All changes are directly scoped to addressing the DataProvider threading objective: pkg/mirror implementation, tests, and documentation updates for the mirror feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mirror-data-provider-manifest-1122

Comment @coderabbitai help to get the list of available commands and usage tips.

@mchmarny mchmarny merged commit a1fc3ab into main May 30, 2026
36 checks passed
@mchmarny mchmarny deleted the feat/mirror-data-provider-manifest-1122 branch May 30, 2026 11:25
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report ✅

Metric Value
Coverage 76.6%
Threshold 75%
Status Pass
Coverage Badge
![Coverage](https://img.shields.io/badge/coverage-76.6%25-green)

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/NVIDIA/aicr/pkg/mirror 71.22% (+3.08%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/NVIDIA/aicr/pkg/mirror/discover.go 75.52% (+4.40%) 143 (+1) 108 (+7) 35 (-6) 👍

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mirror): thread recipe-bound DataProvider through extractManifestImages

1 participant