feat: config property to set watched namespaces - #3613
Conversation
Adds `josdk.controller.<name>.namespaces` to ConfigLoader, which was previously the only way of configuring watched namespaces that was not available from an external configuration source. The value is a comma-separated list; entries are trimmed and blank ones ignored. The special values JOSDK_ALL_NAMESPACES and JOSDK_WATCH_CURRENT are supported but, as everywhere else, only on their own. Validation happens while building the consumer, so an invalid value fails at wiring time rather than at reconciliation time. Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change adds controller-level watched namespace configuration. ChangesController namespace configuration
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant ConfigLoader
participant ControllerConfigurationOverrider
participant InformerConfiguration
ConfigLoader->>ConfigLoader: Read and parse controller namespaces
ConfigLoader->>ControllerConfigurationOverrider: Apply settingNamespaces(namespaces)
ControllerConfigurationOverrider->>InformerConfiguration: Update watched namespace settings
Merge Risk: ⚪ Minimal · up to The new controller namespace configuration is parsed, validated, applied, and documented consistently, with coverage for default, special, invalid, and multi-controller cases. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified.
Pull request overview
Adds external configuration for controller watched namespaces via josdk.controller.<name>.namespaces.
Changes:
- Parses, trims, and validates comma-separated namespaces.
- Supports
JOSDK_ALL_NAMESPACESandJOSDK_WATCH_CURRENT. - Adds unit, integration, and documentation coverage.
File summaries
| File | Description |
|---|---|
operator-framework/src/test/java/io/javaoperatorsdk/operator/config/loader/ConfigLoaderTest.java |
Tests namespace configuration behavior. |
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/configloader/ConfigLoaderIT.java |
Verifies configuration wiring. |
operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java |
Implements namespace parsing and validation. |
docs/content/en/docs/documentation/operations/configuration.md |
Documents the new property and supported values. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| Consumer<ControllerConfigurationOverrider<R>> buildNamespacesConsumer(String prefix) { | ||
| final var key = prefix + NAMESPACES_SUFFIX; | ||
| final var value = configProvider.getValue(key, String.class); | ||
| if (value.isEmpty()) { |
| java.util.function.Consumer< | ||
| io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider< | ||
| io.fabric8.kubernetes.api.model.ConfigMap>> | ||
| consumer) { | ||
| var overrider = | ||
| io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider.override( | ||
| baseControllerConfig()); |
Adds
josdk.controller.<name>.namespacesto ConfigLoader, which waspreviously the only way of configuring watched namespaces that was not
available from an external configuration source.
The value is a comma-separated list; entries are trimmed and blank ones
ignored. The special values JOSDK_ALL_NAMESPACES and JOSDK_WATCH_CURRENT
are supported but, as everywhere else, only on their own. Validation
happens while building the consumer, so an invalid value fails at wiring
time rather than at reconciliation time.
Signed-off-by: Attila Mészáros a_meszaros@apple.com
Summary by CodeRabbit
New Features
josdk.controller.<name>.namespacesproperty.Documentation