I'm looking for a way to detect the active environ...
# troubleshooting
p
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?
For context I'm writing a custom dag generator for airflow where I want it to be environment aware so I can use the same script for multiple different operators (i..e. bash locally and kubernetes pod when deployed)
v
Could make a wrapper that calls meltano, and forces environment to be defined eek . Gross but it'll work everytime!
e
I think we (I) should add the active environment setting to
src/meltano/core/bundle/settings.yml
so the env var always gets injected into the execution environment. @pat_nadolny I'm curious how you intend to use the detected environment.
p
@edgar_ramirez_mondragon I'm making a custom DAG generator in the squared repo and I want it to check the active environment to decide if it should generate DAGs using the KubernetesPodOperator or the BashOperator. This would let me turn on and run my pipelines locally and also make sure they generate properly, then that dag folder is also used as input for building our airflow docker image thats sent to EKS. I could have it defined as separate modules (dev/prod) but then im worried about skew between them.
I could set some other value like
AIRFLOW_OPERATOR
or something at the env config level, maybe thats better actually. I cant remember why i didnt want to do that
k
@aaronsteers and I had a conversation yesterday about using the current environment to switch between profiles in
dbt
(rather that creating a new Meltano-specific
DBT_PROFILE
setting and env var) 🤔 +1 for injecting
MELTANO_ENVIRONMENT
into plugin context as I think it is much neater and more reusable than a per-plugin setting definition 🙂
a
@pat_nadolny - Can you create an issue on this? I'm inclined to inject
MELTANO_ENVIRONMENT
into child processes if environment is declared another way (e.g. via the CLI flag, or via default_environment in meltano.yml)
p
@aaronsteers yep I created one yesterday https://gitlab.com/meltano/meltano/-/issues/3377
a
I've added comments and added a one-liner spec proposal to the top of the description. Thanks for opening!