Yaml YQV4基于深层密钥的存在获取根密钥

Yaml YQV4基于深层密钥的存在获取根密钥,yaml,yq,Yaml,Yq,我有这样的结构: foo: image: 123 bar: image: 456 baz: config: "my config" 我想根据子“image”的存在打印根键(即foo、bar、baz) 在yq版本3中,我可以这样做: $ yq read test.yaml --printMode p "*.image" | awk -F'.' '{print $1}' foo bar 但是我在v4中找不到等效的。yq+jq解决方案将是:

我有这样的结构:

foo:
  image: 123

bar:
  image: 456

baz:
  config: "my config"
我想根据子“image”的存在打印根键(即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执行此操作吗?

您可以使用获取包含标记
图像的匹配对象的路径

yq e.[]|选择(has(“image”)|路径|.[]'yaml