I need to use yaml anchor references together with string concatenation inside application.yml for Spring Boot app. Motivation is to reuse existing configs and not duplicate them.
For example, we have the following application.yml:
sources:
- filter:
expression: &mainFilter
level > 100
- filter:
expression: *mainFilter
- filter:
expression: *mainFilter and level < 200
I need that it will be resolved to the following:
sources:
- filter:
expression: &mainFilter
level > 100
- filter:
expression: level > 100
- filter:
expression: level > 100 and level < 200
expression: *mainFilter will be resolved correctly as it's yml anchors, but expression: *mainFilter and level < 200 will not work as yml doesn't support anchors with concatenation (app will fail on app start). According to yml string concatenation with custom tags, yml has notion as custom tags that we could define, like expression: !concat [*mainFilter, 'and level < 200']. Is it possible to define and register our own custom tags in Spring Boot yml configuration?