refactor(provisioner): remove reflection from multi-provisioner tests#6219
Conversation
The multi-provisioner tests reached into the Kind provisioner's unexported kubeConfig/kindConfig fields via reflection, coupling them to internal field names and layout. Introduce a package-level, injectable Kind factory seam (swapped in tests via SetKindProvisionerFactory) so the tests assert the kindConfig and kubeconfig arguments the minimal path passes to the factory directly, with no reflection. Production always uses kindprovisioner.CreateProvisioner, so behaviour is unchanged. Fixes #6049 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Readiness / tried-as-a-user (test-refactor): the exercisable surface of this change is the test suite itself, and I exercised it directly:
Production is unchanged — |
✅MegaLinter analysis: Success✅ Linters with no issuesactionlint, bash-exec, git_diff, hadolint, jscpd, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, shellcheck, shfmt, stylelint, syft, trivy-sbom, trufflehog, v8r, v8r, yamllint Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts
|
Code Coverage OverviewLanguages: Go Go / code-coverage/goThe overall coverage in the branch remains at 67%, unchanged from the branch. Show a code coverage summary of the most impacted files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
@coderabbitai review |
|
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughAdds a package-level Kind provisioner factory seam that defaults to the existing constructor and can be replaced by tests with a restore closure. Updates Vanilla-Kind tests to capture kubeconfig and 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
Readiness record (self-promotion @
Promoting and merging. |

Why
The multi-provisioner tests inspected the Kind provisioner's private fields via reflection, so a routine rename or re-layout of those internals would silently break the tests — brittle coupling to another package's internals.
What
Adds a small injectable Kind-factory seam so the tests assert the config and kubeconfig arguments the minimal path hands to the factory directly, with no reflection. Production behaviour is unchanged (it always uses the real Kind factory). Test-only refactor — no runtime behaviour change, no flag needed.
Fixes #6049