-
yaml
i want to change rules(list) --> alert: test2 --> labels add a new lables like this
do not use |
Beta Was this translation helpful? Give feedback.
Answered by
mikefarah
Aug 23, 2022
Replies: 1 comment 1 reply
-
You can do it this way: yq ' (.. | select(tag == "!!map" and .alert == "test2") | .labels) += {"a":"c"}' file.yaml Explanation:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pycgo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 documentselect(tag == "!!map" and .alert == "test2")
will filter to only includemap
nodes that havealert: test2