I have a YAML file that I use in my Rails 4 application,
default: &default
key: <%= JSON.parse(ENV[‘data’])[‘key'] %>
secret: <%= JSON.parse(ENV[‘data’])[‘secret’] %>
development:
key: 1234
Secret: 1234
test:
key: 1234
Secret: 1234
qa:
<<: *default
production:
<<: *default
I would like to run a script to duplicate the block “qa” so that there is an identical “qa2” block beneath it. Ideally the end result would be
default: &default
key: <%= JSON.parse(ENV[‘data’])[‘key'] %>
secret: <%= JSON.parse(ENV[‘data’])[‘secret’] %>
development:
key: 1234
secret: 1234
test:
key: 1234
secret: 1234
qa:
<<: *default
qa2:
<<: *default
production:
<<: *default
And was given this command
yq e '.production as $p | del(.production) | .qa2 = .qa | .production = $p' config/myfile.yml
But this produces
default: &default
key: <%= JSON.parse(ENV['data'])['key'] %>
secret: <%= JSON.parse(ENV['data'])['secret'] %>
development:
key: 1234
secret: 1234
test:
key: 1234
secret: 1234
qa:
!!merge <<: *default
qa2:
!!merge <<: *default
production:
!!merge <<:
Is there a way I can rewrite things so that I don’t have that annoying “!!merge” keyword inserted?