I am writing a Perl script to generate a docker-compose.yml file. I am using the YAML.pl module's DumpFile method to write a complex hash to a file in YAML format.
Some of the arrays are dumping correctly, that is to say, the elements are unquoted, e.g.,
"environment" => [
'MYSQL_ROOT_PASSWORD=secret', 'MYSQL_DATABASE=db',
'MYSQL_USER=dbadmin', 'MYSQL_PASSWORD=secret2',
],
becomes
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=db
- MYSQL_USER=dbadmin
- MYSQL_PASSWORD=secret2
However there are some arrays that contain what are supposed to be arguments with values comprised of environment variables that docker-compose will get from the environment, i.e., I CANNOT output the raw values here, I need to output the env var that docker-compose will use to get the value. These are being dumped quoted:
"args" => [
'APP_CODE_PATH=${APP_CODE_PATH_CONTAINER}',
'APP_GROUP=${APP_GROUP}',
'APP_GROUP_ID=${APP_GROUP_ID}',
'APP_USER=${APP_USER}',
'APP_USER_ID=${APP_USER_ID}',
'TARGET_PHP_VERSION=${PHP_VERSION}',
'TZ=${TIMEZONE}'
],
becomes:
args:
- 'APP_CODE_PATH=${APP_CODE_PATH_CONTAINER}'
- 'APP_GROUP=${APP_GROUP}'
- 'APP_GROUP_ID=${APP_GROUP_ID}'
- 'APP_USER=${APP_USER}'
- 'APP_USER_ID=${APP_USER_ID}'
- 'TARGET_PHP_VERSION=${PHP_VERSION}'
- 'TZ=${TIMEZONE}'
The output is not supposed to be quoted.
I've combed the YAML.pm docs, but I cannot find anything specific to this question there.
I suspect it is how I'm entering the values in the array, but I can't figure out what I'm doing wrong.