I have a yaml file, inside which I use anchors & aliases to DRY up the file. It's a docker-compose file. Simple e.g. follows:
version: "3.4"
x-build: &build
context: ../
services:
api:
build:
<<: *build
dockerfile: some-path/Dockerfile
image: gcr.io/some-project/api
I use yq and then jq to convert this to json and pass it to terraform so that I can re-use the information in docker-compose as a source of truth.
All the aliases and anchors get removed from the resulting json. Not a disaster, but it would be much nicer to have it actually expanded.
I'm looking for a command-line tool that I can run in a bash script to take the above json as an input and expand the anchors and aliases, and write the result to stdout, so something like:
version: "3.4"
services:
api:
build:
context: ../
dockerfile: some-path/Dockerfile
image: gcr.io/some-project/api
Does anyone know how to do this?