Skip to content

how to select list to update #1311

Answered by mikefarah
pycgo asked this question in Q&A
Aug 19, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can do it this way:

yq ' (.. | select(tag == "!!map" and .alert == "test2") | .labels) += {"a":"c"}' file.yaml

Explanation:

  • .. matches all nodes in the yaml document
  • select(tag == "!!map" and .alert == "test2") will filter to only include map nodes that have alert: test2

Replies: 1 comment 1 reply

Comment options

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

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