Skip to content

Add RegisterProviderFactory extension point to pkg/config#4340

Merged
aponcedeleonch merged 1 commit intomainfrom
add-provider-factory-extension-point
Mar 24, 2026
Merged

Add RegisterProviderFactory extension point to pkg/config#4340
aponcedeleonch merged 1 commit intomainfrom
add-provider-factory-extension-point

Conversation

@aponcedeleonch
Copy link
Copy Markdown
Member

Summary

  • NewProvider() currently hard-codes the selection between KubernetesProvider and DefaultProvider with no way for downstream consumers to inject a custom Provider implementation without forking
  • This adds a ProviderFactory registration hook (RegisterProviderFactory) so that callers can register a custom factory at startup, and NewProvider() will consult it before falling back to the built-in logic
  • The two-step nil check ensures a factory that intentionally returns nil triggers the fallback rather than a nil-pointer dereference

Type of change

  • Enhancement (non-breaking change that adds functionality)

Changes

File Change
pkg/config/factory.go New file — ProviderFactory type, registeredFactory var, RegisterProviderFactory func
pkg/config/interface.go Updated NewProvider() to consult registeredFactory before built-in logic
pkg/config/factory_test.go New file — unit tests for factory registration and fallback behaviour

Test plan

  • Unit tests pass (go test ./pkg/config/)
  • Linter passes (task lint)
  • Tests cover: no factory registered, factory returns non-nil, factory returns nil (fallback), second registration overwrites first, factory overrides Kubernetes detection

Generated with Claude Code

NewProvider() currently hard-codes the selection between KubernetesProvider
and DefaultProvider with no way for downstream consumers to inject a custom
Provider implementation. This adds a ProviderFactory registration hook so
that callers can register a custom factory at startup, and NewProvider()
will use it before falling back to the built-in logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Mar 24, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.92%. Comparing base (ce4123e) to head (5ff981b).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4340      +/-   ##
==========================================
- Coverage   69.30%   68.92%   -0.39%     
==========================================
  Files         478      479       +1     
  Lines       48425    48489      +64     
==========================================
- Hits        33559    33419     -140     
- Misses      12271    12335      +64     
- Partials     2595     2735     +140     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aponcedeleonch aponcedeleonch merged commit ccb98c3 into main Mar 24, 2026
68 of 69 checks passed
@aponcedeleonch aponcedeleonch deleted the add-provider-factory-extension-point branch March 24, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants