Skip to content

Help combining two maps based on map name #2084

Answered by mikefarah
glitchcrab asked this question in Q&A
Discussion options

You must be logged in to vote

Short Answer:

yq '.nodeClasses as $nodeClasses | .nodePools[] *=n $nodeClasses[.class]' file.yaml
  • First we make a variable called $nodeClasses. We'll need this because we are going to update each of the nodePools relative to themselves (and so the . operator will refer to the specific node pool).
  • then we want to update all of the nodePools by merging in their current value with the nodeClass[.class].
    • * is the merge operator, we could do `.nodePools[] |= . * ($nodeClasses | .[.class])' but we can instead use the update shorthand:
    • *=n doc is a relative merge operator we can use to do exactly that.
    • the extra n tells it only to merge in "new" values (so if someone specifies a "diskGiB" for…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by glitchcrab
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