Merge two config trees with per-node merge rules
I was asked this
No reports yet. Sign in to say where you were asked it.
Two configuration files have been parsed from YAML into trees of dicts, lists and plain values: a base and an overlay. Merge the overlay into the base.
Each node can carry its own merge rule, given as a table from a dotted node path to a rule name. Rules include: merge two dicts key by key (recursing into shared keys), take the overlay's node, keep the base's node, concatenate two lists, and merge two lists of dicts by matching a key field. A node with no rule merges dicts and otherwise takes the overlay.
There are many rules in the real exercise, so design the walk so that adding a rule doesn't touch it. Cover keys present on one side only, list order, and a dict meeting a list.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
