yq
yq copied to clipboard
Explode operator with nested anchors
I have a document that is using nested YAML anchors. I'm using the explode() operator to resolve the anchors but if I have multiple nested anchors, it seems to only resolve the first level of of the nested anchors.
The following command:
cat <<END > aaa.yaml
aaa:
- &first
aaa: bbb
- &second
<<: *first
ccc: ddd
- <<: *second
eee: fff
END
yq '.aaa[2] | explode(.)' aaa.yaml
produces the following output:
!!merge <<:
aaa: bbb
ccc: ddd
eee: fff
where I would expect it to produce this:
aaa: bbb
ccc: ddd
eee: fff
I'm running yq in the version 4.30.6 on Arch Linux.
Hmm not sure why that's not working, need to look into it. As a workaround, if you run explode first then it works:
yq 'explode(.) | .aaa[2]' aaa.yaml