Good afternoon. A coworker ran into a scenario wh...
# atmos
r
Good afternoon. A coworker ran into a scenario where values are merged rather than replaced. Trying to confirm whether it should be expected or not due to how this ends up typed. ๐Ÿงต
Copy code
# globals-variables
components:
  terraform:
    my_component:
      vars:
        some_var:
          test: {}
---
# stack
import:
  - globals-variables
components:
  terraform:
    my_component:
      vars:
        some_var: {}
---
# results
vars:
  some_var:
    test: {}
---
# result I expected
  vars:
    some_var: {}
a
maps/objects are always merged, so the result is correct
list are replaced by default (it's difficult to merge lists correctly) you can change the list merging strategy in
atmos.yaml
https://atmos.tools/cli/configuration/#settings
Copy code
settings.list_merge_strategy
Specifies how lists are merged in Atmos stack manifests.

The following strategies are supported:

replace
Most recent list imported wins (the default behavior).
append
The sequence of lists is appended in the same order as imports.
merge
The items in the destination list are deep-merged with the items in the source list. The items in the source list take precedence. The items are processed starting from the first up to the length of the source list (the remaining items are not processed). If the source and destination lists have the same length, all items in the destination lists are deep-merged with all items in the source list.
r
Thanks. Was aware of that documentation and how lists worked. I don't think we have any maps with to have caught this behavior in the past. Appreciate the confirmation.
a
note that merging lists is complicated and can give surprising results (especially list of complext types). That's why many libs don't merge lists by default but replace them
๐Ÿ‘ 1
r
I had just got done arguing about how the defaults were set because they don't merge and then he accidentally found out their merged. I thought it was going to match the lists. ๐Ÿ™ƒ Still causes us to have to think and now know the difference.
That's an us issue. ๐Ÿ™‚