Deepak Deore
Deepak Deore

Reputation: 322

how to include key in the result while parsing yaml file with yq command

how to get values including the key? here is input:

istio_cni:
  enabled: false
  repair:
    enabled: true

istiocoredns:
  enabled: false

global:
  hub: docker.io/istio
  tag: 1.4.5
  logging:
    level: "default:info"

expected output is whole global block:

global:
  hub: docker.io/istio
  tag: 1.4.5
  logging:
    level: "default:info"

yq gives the result which doesn't include global key:

$ yq r /tmp/values.yaml global
hub: docker.io/istio
tag: 1.4.5
logging:
  level: "default:info"

Upvotes: 1

Views: 913

Answers (1)

Deepak Deore
Deepak Deore

Reputation: 322

got the answer from yq author

$ 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")

Upvotes: 2

Related Questions