如何在使用 yq 命令解析 yaml 文件时在结果中包含密钥
how to include key in the result while parsing yaml file with yq command
如何获取包含键的值?这里是输入:
istio_cni:
enabled: false
repair:
enabled: true
istiocoredns:
enabled: false
global:
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
预期输出是整个 global
块:
global:
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
yq
给出的结果不包括 global
键:
$ yq r /tmp/values.yaml global
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
得到yq作者的回答
$ yq r /tmp/values.yaml global -p pv
global:
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
-p is for print mode
pv is one of a print mode - (v (values, default), p (paths), pv (path and value pairs) (default "v")
如何获取包含键的值?这里是输入:
istio_cni:
enabled: false
repair:
enabled: true
istiocoredns:
enabled: false
global:
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
预期输出是整个 global
块:
global:
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
yq
给出的结果不包括 global
键:
$ yq r /tmp/values.yaml global
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
得到yq作者的回答
$ yq r /tmp/values.yaml global -p pv
global:
hub: docker.io/istio
tag: 1.4.5
logging:
level: "default:info"
-p is for print mode
pv is one of a print mode - (v (values, default), p (paths), pv (path and value pairs) (default "v")