Skip to content
Discussion options

You must be logged in to vote

Ok I understand what you are trying to do. The yq merge operator however is a naive merge, it has no knowledge of your datastructure (and does not know, for instance, that the 'name' field uniquely identifies entries). The naive merge just merges the data structures matching on the yaml key name, and arrays are either appended together, or merged together by their index position.

That said, there is a more complex merge that you can use this script here: https://mikefarah.gitbook.io/yq/operators/multiply-merge#merge-arrays-of-objects-together-matching-on-a-key

However this only does a single level of merge, where you actually need two; one on the table name, and then again on the matching…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@davesgonechina
Comment options

Answer selected by davesgonechina
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants