4

I am trying to add a new root to an existing yaml.

I have a values.yaml file with the following content

key1: value1
key2: value2
key3:
  key31: value31
  key32: value32

And I am trying to add a root to the existing yaml.

mainkey: 
  key1: value1
  key2: value2
  key3:
    key31: value31
    key32: value32

I tried yq with +, merge and nothing yielded the result i wanted. Is it possible to append a root to an existing yaml?

oguz ismail
  • 1
  • 16
  • 47
  • 69
Vini
  • 1,978
  • 8
  • 40
  • 82
  • 4
    `yq '{"mainkey": .}' values.yaml` works with [mikefarah/yq](https://github.com/mikefarah/yq), `yq -y '{mainkey: .} values.yaml` works with [kislyuk/yq](https://github.com/kislyuk/yq). – pmf Oct 27 '22 at 20:07
  • thanks that works. i was trying it always the other way round :-) – Vini Oct 27 '22 at 20:10

0 Answers0