Repository navigation
Make declarative config parsing and mapping pluggable - #8983
ash-thakur-rh wants to merge 9 commits into
Conversation
Add parser and mapper SPIs, and move the Jackson 2 mapper into an optional adapter module. Signed-off-by: Ashish Thakur <ashishth@redhat.com>
Signed-off-by: Ashish Thakur <ashishth@redhat.com>
Pull request dashboard statusWaiting on the author · refreshed 2026-11-11 13:14 UTC Two things need attention:
Status above doesn't look right?
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8983 +/- ##
============================================
+ Coverage 90.33% 90.36% +0.02%
- Complexity 11017 11034 +17
============================================
Files 1021 1025 +4
Lines 30124 30168 +44
Branches 3933 3939 +6
============================================
+ Hits 27214 27261 +47
+ Misses 1953 1947 -6
- Partials 957 960 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Ashish Thakur <ashishth@redhat.com>
jack-berg
left a comment
There was a problem hiding this comment.
This is pretty close to the shape I imagined. Couple of things to think through tho.
| * This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
| * any time. | ||
| */ | ||
| public final class SnakeYamlDeclarativeConfigurationParser |
There was a problem hiding this comment.
Interesting.. so we have a dedicated jackson module, but build the snakeyaml implementation into declarative-config directly despite it being pluggable via SPI.
I think we need to think this through and be consistent.
There was a problem hiding this comment.
yes, I agree. we can move the snakeyaml impl to its own. For now, I will have sankeyaml impl in declarative-config until we think this through.
There was a problem hiding this comment.
Ok upon further thought, I think we need to either rip out the DeclarativeConfigurationYamlParser SPI or split the snakeyaml out into its own module now.
The argument to rip out the yaml SPI is that nobody has reported issues with snakeyaml yet so its possible its stable enough / ubiquitous enough that nobody wants it pluggable. The argument to keep it and split snakeymal into its own module is that there are other YAML parsers out there and it may be inevitable that someone eventually takes issue with snakeyaml and wants to bring their own.
I still lean towards keeping the yaml SPI since it buys a mitigation step in case snakeyaml library falls into disrepair or has some other issue that makes it a toxic dependency. So let's break out a snakeyaml module.
Thanks @jack-berg , will take care of the things suggested. |
Signed-off-by: Ashish Thakur <ashishth@redhat.com>
Signed-off-by: Ashish Thakur <ashishth@redhat.com>
Signed-off-by: Ashish Thakur <ashishth@redhat.com>
Signed-off-by: Ashish Thakur <ashishth@redhat.com>
Signed-off-by: Ashish Thakur <ashishth@redhat.com>
This comment has been minimized.
This comment has been minimized.
|
/dashboard route:reviewers |
|
@ash-thakur-rh, this pull request was routed to reviewers. The handoff remains active across pushes until newer actionable human feedback arrives. Top-level feedback through this request will not return; unresolved review threads remain open. |
| * @param <T> the target type | ||
| * @return the converted value | ||
| */ | ||
| <T> T convert(Object value, Class<T> targetType); |
There was a problem hiding this comment.
The new SPI methods convert / toMap / DeclarativeConfigurationYamlParser.parse throw under certain conditions. We should standardize the throws contract so callers can catch in a consistent way regardless of implementation.
| Logger.getLogger(DeclarativeConfigProviderLoader.class.getName()); | ||
|
|
||
| private static final ComponentLoader COMPONENT_LOADER = | ||
| ComponentLoader.forClassLoader(DeclarativeConfigProperties.class.getClassLoader()); |
There was a problem hiding this comment.
We need to find a way for ComponentLoader to be a part of the contract and passed through from the caller. Every time we've loaded SPIs previously using a convenient class loader available to us, we eventually get an issue opened where someone needs that class loader to be configurable. That's why you see setComponentLoader style methods everywhere.
This is going to be disruptive for ExtensionPropertyUtil, which calls DeclarativeConfigurationMapper, and maybe the contracts in DeclarativeConfiguration itself since the parse operation currently doesn't have any overload which includes a ComponentLoader. If it proves too disruptive, let's skip and open an issue to followup.
| MessageFormat.format( | ||
| "Multiple {0} providers found. Please include only one, or specify preference " | ||
| + "setting {1} to the FQCN of the preferred provider.", | ||
| spiClass.getSimpleName(), configProperty)); |
There was a problem hiding this comment.
We don't use this MessageFormat style anywhere in this repo so let's not start
| MessageFormat.format( | |
| "Multiple {0} providers found. Please include only one, or specify preference " | |
| + "setting {1} to the FQCN of the preferred provider.", | |
| spiClass.getSimpleName(), configProperty)); | |
| "Multiple {0} providers found. Please include only one, or specify preference " | |
| + "setting {1} to the FQCN of the preferred provider.", | |
| new Object[]{spiClass.getSimpleName(), configProperty}); |
| * This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
| * any time. | ||
| */ | ||
| public final class SnakeYamlDeclarativeConfigurationParser |
There was a problem hiding this comment.
Ok upon further thought, I think we need to either rip out the DeclarativeConfigurationYamlParser SPI or split the snakeyaml out into its own module now.
The argument to rip out the yaml SPI is that nobody has reported issues with snakeyaml yet so its possible its stable enough / ubiquitous enough that nobody wants it pluggable. The argument to keep it and split snakeymal into its own module is that there are other YAML parsers out there and it may be inevitable that someone eventually takes issue with snakeyaml and wants to bring their own.
I still lean towards keeping the yaml SPI since it buys a mitigation step in case snakeyaml library falls into disrepair or has some other issue that makes it a toxic dependency. So let's break out a snakeyaml module.
| api(project(":sdk:all")) | ||
| api(project(":api:incubator")) | ||
| compileOnly(project(":sdk-extensions:autoconfigure-spi")) | ||
| api(project(":sdk-extensions:autoconfigure-spi")) |
There was a problem hiding this comment.
This should be an implementation dependency on spi unless any spi classes are part of declarative config public facing API contracts
| * The built-in SnakeYAML parser and Jackson 2 mapper work by default. The mapper is supplied by | ||
| the `declarative-config-jackson2` module (`opentelemetry-sdk-extension-declarative-config-jackson2` | ||
| artifact). If you exclude that module, register a mapper provider of your own; otherwise, | ||
| operations that need mapping fail with a `DeclarativeConfigException`. |
Description:
Closes #8820