How to use map_values #1863
-
I am having some trouble with the use of I expected this query to be equivalent to an identity function, but the result surprises me. $ yq 'map_values(.)' <<< "{a: {b: c}}"
{a: {}} However, by adding a seemingly superfluous $ yq 'map_values(. | to_entries | from_entries)' <<< "{a: {b: c}}"
{a: {b: c}} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I have a simple task I want to do with this - create a docker-compose.override.yml with just the image keys. I can do this by yq '. | with_entries(select(.key=="services")) | .services as $s | .services = $s | map_values(. | to_entries | from_entries | map_values(pick(["image"])))' docker-compose.yml > docker-compose.override.yml but both the |
Beta Was this translation helpful? Give feedback.
Yep that is a bug in an older version of
yq
- please grab the latest and try again 👍🏼