Skip to main content

merge

merge is a DTL operation that combines sibling mappings into one mapping.

Use it when separate sibling objects should become one object.

YOp

- merge:
path: config
keys: [db_primary, db_replica]
into: database

Parameters

ParameterTypeRequiredDescription
pathstringyesPath to the parent mapping.
keyssequence of stringsyesSibling keys to combine.
intostringyesKey name for the merged result.

Behavior

  • Requires path to exist and be a mapping.
  • Requires every listed key to exist as a sibling.
  • Combines the listed values into the into mapping.
  • Removes the original sibling keys.
  • If merged mappings contain the same key, later listed keys win.

Errors

ErrorMeaning
PATH_NOT_FOUNDParent path does not exist.
NOT_A_MAPPINGParent is not a mapping.
NOT_SIBLINGSOne or more listed keys are not siblings in the parent.

Example

yops:
- merge:
path: config
keys: [primary, replica]
into: database

Input:

config:
primary:
host: primary.example.com
replica:
port: 5432

Output:

config:
database:
host: primary.example.com
port: 5432