我有这个结构:
foo:
image: 123
bar:
image: 456
baz:
config: "my config"
我想根据子“图像”的存在打印根键(即 foo、bar、baz)
在 yq 版本 3 中,我可以这样做:
$ yq read test.yaml --printMode p "*.image" | awk -F'.' '{print $1}'
foo
bar
但我在 v4 中找不到等价物。yq + jq 解决方案是:
$ yq -j e test.yaml | jq -r 'to_entries[] | select(.value | has("image")) | [.key][]'
foo
bar
知道如何用 yq v4 做到这一点吗?