thesimj / envyaml

Simple YAML configuration file parser
MIT License
78 stars 21 forks source link

Env variables do not interpolate correctly if set with other Env vars in .env file #33

Closed bbarberBPL closed 2 years ago

bbarberBPL commented 2 years ago

System/Project info

Main issue is when loading the config file with an environment variable in .env that appends or prepends an existing environment variable , such as $HOME, the prepended or appended environment variable is not interpolated. See example .env/yaml config below

NOTE: Also tried above without quotes and without {} brackets and got the same issue


* `myconfig.yaml`

my_source_directory: "${MY_SOURCE_DIRECTORY}"

NOTE: Also tried above without quotes and without {} brackets and got the same issue


Expected:

MY_CONFIG=EnvYaml('myconfig.yaml') print(MY_CONFIG['my_source_directory']) '/home/myuser/mapped/source/directory'


Got:

MY_CONFIG=EnvYaml('myconfig.yaml') print(MY_CONFIG['my_source_directory']) '$HOME/mapped/source/directory'

ALSO GOT:

'${HOME}/mapped/source/directory'


Additionally when I load the environment variable with the `os` module I get the expected result

import os print(os.getenv('MY_SOURCE_DIRECTORY')) '/home/myuser/mapped/source/directory'

thesimj commented 2 years ago

hi @bbarberBPL thank you for this issue, I will dive deeper into this.

thesimj commented 2 years ago

this is fixed in develop branch