There is a dynamic attribute stored in input.yaml, I want to insert it into an existed yaml file(named as original.yaml). The attribute has multiple lines.
The two files look like: input.yaml:
- name: bob
spec: {}
original.yaml:
spec:
names:
- name: alice
spec: {}
My goal is to put input.yaml content under original.yaml spec.names.
I tried with yq version 4:
env=$(cat input.yaml)
yq eval '.spec.names + strenv(env)' original.yaml > result.yaml
What I got:
spec:
names:
- name: alice
spec: {}
- |-
- name: bob
spec: {}
there is an unwanted - |- in line 5, I am expected the below output:
spec:
names:
- name: alice
spec: {}
- name: bob
spec: {}
Any suggestion will be appreciated.