Active Environment Name As Env Variable
Proposal
Would expose MELTANO_ENVIRONMENT
to child processes, even if environment is set via another method (--environment
at the CLI or default_environment
in meltano.yml
.)
Background
Based on this thread in slack https://meltano.slack.com/archives/C01TCRBBJD7/p1643919224929049
My original comment was:
I'm looking for a way to detect the active environment using environment variables and I know you can set a meltano environment using --environment=prod or through a MELTANO_ENVIRONMENT. Its easy to solve if I use the second method but if I define it using the --environment argument there doesnt seem to be any environment variable set. Is there a way to consistently do this?
We also now have default environments so the environment can be set in the meltano.yml too.
For any down stream process that wants to call meltano commands like I do in the dbt airflow dag generator https://gitlab.com/pnadolny13/files-airflow-dbt/-/blob/master/bundle/orchestrate/dags/generator_cache_builder.py#L36 it would be helpful to have the meltano environment exposed in the environment variables context. If I call meltano --environment=prod invoke airflow webserver
then the dag generator should be able to access MELTANO_ENVIRONMENT
.
It might be an anti pattern but it gives more flexibility to users so we can customize more.