Open philwebb opened 1 month ago
Perhaps without the brackets. And perhaps only +
for now.
I'ld be interested to know how this might work for collections of complex types (which might have sub-collections). E.g.
my-collection:
- name: foo
prop: x
sub-collection:
- item1
- item2
- name: bar
prop: y
sub-collection:
- item3
- item4
Removing an item from my-collection
or setting a property of an item, without knowing its index might be tricky. E.g
'my-collection[name == "bar"].prop': "z"
We generally in our team have an convention that if
name
),then its probably better modelled as map using the sub-property as a key - and in most other cases we don't actually need to mutate existing collections and content with "first wins" policy.
my-collection:
foo:
prop: x
sub-collection:
- item1
- item2
bar:
prop: y
sub-collection:
- item3
- item4
Currently the
Binder
class has a "first wins" policy for binding lists. From the docs:This policy has worked well, however, it also causes problems such as #41669 where users really want to merge lists together.
I think it would be a mistake to attempt to compose lists from elements in different property sources, however, we might be able to offer a feature where distinct lists could be merged together.
Proposal
When property values are defined, the property name could include an additional indicator that is used to determine how the values should be merged. The indicator would be
(+)
foraddAll
and(-)
forremoveAll
:This example shows an auto-configure exclude:
.properties
.yaml
More complex examples are:
.properties
.yaml
Limitations
It will be hard to support this syntax with environment variables.