[yamlcomposer] YAML Composer Add-on for Enhanced YAML Preprocessing - #20305
Conversation
4f4bab4 to
824a362
Compare
There was a problem hiding this comment.
Pull request overview
Introduces a new YAML Composer IO add-on that preprocesses “enhanced” YAML from OPENHAB_CONF/yamlcomposer/ into plain YAML output under OPENHAB_CONF/yaml/composed/, including documentation and OSGi integration tests.
Changes:
- Adds the
org.openhab.io.yamlcomposerbundle (processing pipeline, placeholders/processors, watch service, logging aggregation). - Registers the add-on in build/reactor, Karaf feature metadata, i18n, and CODEOWNERS.
- Adds a dedicated OSGi integration test module for the watch service behavior.
Reviewed changes
Copilot reviewed 64 out of 65 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/static-code-analysis/spotbugs/suppressions.xml | Suppresses a SpotBugs SLF4J format warning for the new BufferedLogger wrapper. |
| itests/pom.xml | Adds the YAML Composer integration-test module to the itests reactor. |
| itests/org.openhab.io.yamlcomposer.tests/pom.xml | New Maven module for YAML Composer OSGi integration tests. |
| itests/org.openhab.io.yamlcomposer.tests/itest.bndrun | New bndrun defining the OSGi test runtime composition for YAML Composer tests. |
| itests/org.openhab.io.yamlcomposer.tests/NOTICE | Notice file for the new itests module. |
| itests/org.openhab.io.yamlcomposer.tests/src/main/java/org/openhab/io/yamlcomposer/internal/YamlComposerWatchServiceOSGiTest.java | OSGi integration tests for watch-triggered compilation and delete behavior. |
| bundles/pom.xml | Adds the YAML Composer bundle to the add-ons bundles reactor. |
| bundles/org.openhab.io.yamlcomposer/pom.xml | New bundle POM including dependencies (SnakeYAML Engine, Jinjava, etc.). |
| bundles/org.openhab.io.yamlcomposer/src/main/feature/feature.xml | New Karaf feature definition for installing the YAML Composer bundle. |
| bundles/org.openhab.io.yamlcomposer/src/main/resources/OH-INF/addon/addon.xml | Add-on metadata registration (type/name/description/service-id). |
| bundles/org.openhab.io.yamlcomposer/src/main/resources/OH-INF/i18n/yamlcomposer.properties | Adds i18n name/description for the add-on. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/YamlComposerWatchService.java | WatchService listener to compile sources into composed YAML and track include dependencies. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/YamlComposer.java | Core load/compile pipeline: parse, variables/templates, includes/inserts, packages, overrides, output model. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/ComposerConfig.java | Centralizes config/source/output paths and composer constants/limits. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/ComposerUtils.java | YAML load/dump utilities, alias breaking, formatting, and compiled output writing. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/StringInterpolator.java | ${...} interpolation and expression evaluation plumbing with configurable delimiters. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/ExpressionEvaluator.java | Jinjava-backed expression evaluation with custom filters and warning tracking. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/BufferedLogger.java | Warning aggregation wrapper that routes warnings through a LogSession. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/LogSession.java | Session-scoped warning consolidation and flush-on-close behavior. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/IncludeRegistry.java | Tracks main↔include relationships to support recompiles on include changes. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/ModelResolver.java | SnakeYAML scalar resolver customization (defer merge-key handling; avoid ENV tag collisions). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/constructors/ModelConstructor.java | SnakeYAML constructor extension adding custom tags and substitution tracking. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/constructors/ConstructSub.java | Tracks !sub pattern suffix to select delimiter patterns. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/constructors/ConstructStr.java | Constructs STR scalars as either literal strings or substitution placeholders based on state. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/constructors/ConstructLiteral.java | Implements !literal handling to disable substitution within a subtree. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/constructors/ConstructInterpolablePlaceholder.java | Generic constructor for placeholders whose values are subject to interpolation/transformation. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/RecursiveTransformer.java | Recursive tree transformer applying placeholder processors, merge keys, and removal semantics. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/ProcessingPhase.java | Defines handler subsets for phased processing (substitution/includes/standard/overrides). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/VariableLoader.java | Extracts variables and injects special variables into evaluation context. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/TemplateLoader.java | Extracts templates while deferring substitutions until insertion time. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/SourceLocator.java | Finds approximate key positions in YAML source for diagnostics. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/PackageProcessor.java | Merges “packages” into the main model, injecting package_id and supporting overrides. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/MergeKeyProcessor.java | Resolves deferred merge-key placeholders (composer-level merge handling). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/RemovalSignal.java | Semantic signal for intentional removal distinct from null-on-error. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/PlaceholderProcessor.java | Common interface for placeholder processing. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/SubstitutionProcessor.java | Resolves substitution placeholders with optional custom delimiter patterns. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/IfProcessor.java | Implements !if conditional branching in models. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/IncludeProcessor.java | Implements !include with variable overlays and include caching. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/InsertProcessor.java | Implements !insert template expansion with per-invocation variable overrides. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/ReplaceProcessor.java | Implements !replace placeholder behavior. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/RemoveProcessor.java | Implements !remove placeholder behavior. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/FragmentUtils.java | Shared parameter parsing for !include/!insert (string and map forms). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/Placeholder.java | Base placeholder abstraction. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/InterpolablePlaceholder.java | Placeholder interface supporting value recreation and eager/lazy argument processing. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/SubstitutionPlaceholder.java | Record representing deferred string interpolation (!sub). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/IfPlaceholder.java | Record representing conditional nodes (!if). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/IncludePlaceholder.java | Record representing include nodes (!include). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/InsertPlaceholder.java | Record representing template insertion nodes (!insert). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/ReplacePlaceholder.java | Record representing override replacement nodes (!replace). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/RemovePlaceholder.java | Record representing override removal nodes (!remove). |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/placeholders/MergeKeyPlaceholder.java | Record representing deferred merge-key occurrences. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/expression/filters/LabelFilter.java | Adds a custom label filter for expression rendering. |
| bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/expression/filters/DigFilter.java | Adds a custom dig filter for safe nested map/list access. |
| bundles/org.openhab.io.yamlcomposer/README.md | Adds README + examples and links to detailed docs. |
| bundles/org.openhab.io.yamlcomposer/doc/basics.md | Documentation: YAML basics used by the composer docs. |
| bundles/org.openhab.io.yamlcomposer/doc/variables.md | Documentation: variables, substitution, expressions, filters. |
| bundles/org.openhab.io.yamlcomposer/doc/include.md | Documentation: !include syntax, scoping, and path resolution. |
| bundles/org.openhab.io.yamlcomposer/doc/templates.md | Documentation: !insert templates and evaluation model. |
| bundles/org.openhab.io.yamlcomposer/doc/packages.md | Documentation: packages and merge behavior/overrides. |
| bundles/org.openhab.io.yamlcomposer/doc/merge-keys.md | Documentation: merge keys and integration with composer features. |
| bundles/org.openhab.io.yamlcomposer/doc/conditionals.md | Documentation: !if behavior, forms, and truthiness. |
| bundles/org.openhab.io.yamlcomposer/doc/anchors.md | Documentation: anchors/aliases usage and best practices. |
| bundles/org.openhab.io.yamlcomposer/NOTICE | Notice file for the new YAML Composer bundle. |
| CODEOWNERS | Adds code ownership for the new YAML Composer bundle. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/yaml-file-based-pages-and-widgets/169079/19 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 64 out of 65 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
215619e to
caa132f
Compare
|
rebased to main to pick up markdownlint, then applied the changes that it required. |
|
the ci is so slow! That parallel build PR would've sped this up. |
23974fb to
e9b69ea
Compare
|
All checks have passed! |
|
Would be nice if @lolodomo can have a look at this as yaml expert ;-) |
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
|
@lsiepel, copilot had run out of suggestions now |
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
|
Not sure if @lolodomo is available, but would be nice to see his review on this. |
|
Sorry I will not be available for this very big PR in the next weeks. My priority is to finish the review of few PRs I already started. |
|
Copilot has had many, many rounds on this code. It's quite complicated and comprehensive, so my guess is that doing a thorough review is a mammoth task. It might be that the "next step" is to have users actually try to use it, but it's a bit hard to do with the official add-ons because of the slow release cycle. @jimtng Have you considered making it available on the community marketplace for "beta testing"? I think that would probably be the best way forward, because you could address issues rapidly, but alternatively, I think it must just be merged, and the feedback dealt with as it arrives. |
|
Even if we made this available on the marketplace first, we'll eventually end up right here again. So I'd rather just have it merged now and fix any bugs as they come later. I've worked on this for more than a year. |
lsiepel
left a comment
There was a problem hiding this comment.
Thanks, I have seen most of the code and looked up some details. This is not an easy review, but from what I have seen it gives a lot of confidence it is weel designed and written.
I can spend another day on reviewing, unlikely to find bugs that will surface quickly when used.
LGTM
…penhab#20305) * [yamlcomposer] New Yaml Composer add-on Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
|
This is missing the 5.2 tag - didn't make it into the release notes |
That can't be too late to rectify? |
|
I don't know how it works, but maybe it can still show up in the final release notes? |
I don't know for sure either, but I was able to add the milestone... |
|
It will be in the final notes, sorry I did not add it. |
…penhab#20305) * [yamlcomposer] New Yaml Composer add-on Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
…penhab#20305) * [yamlcomposer] New Yaml Composer add-on Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au> Signed-off-by: olemr <olemr@olemr.com>
Initially submitted as openhab/openhab-core#4818 but now refactored as an add-on.
YAML Composer supports extended YAML features that make openHAB configuration more modular, reusable, and maintainable. These features let you structure configuration as composable building blocks rather than large, repetitive files.
The add-on loads enhanced-syntax YAML files from
OPENHAB_CONF/yamlcomposer/and compiles them into fully resolved plain YAML written toOPENHAB_CONF/yaml/composed/.See the README.md for a brief example. Complete docs are included in this PR.