ramonvermeulen / dbt-toolkit

The dbt-toolkit is an early-stage plugin designed to enhance your experience working with dbt-core projects in JetBrains IDEs.
GNU General Public License v3.0
14 stars 0 forks source link

Feature-Request: .env file support #117

Closed CiderHider closed 1 month ago

CiderHider commented 2 months ago

Description

Currently environment variables are defined separately in the settings. Project environment variables are often defined in a central .env file. I would request .env file support for this tool. This would enable access to centrally managed project environment variables.

Current Behavior

Environment variables for DBT are defined in the dbt-toolkit settings.

Proposed Behavior

Environment variables can additionally be defined in an .env file. The file is targeted via a path in the dbt-toolkit settings.

Motivation

All needed environment variables can be defined and managed in a centralized file for the whole project.

ramonvermeulen commented 2 months ago

Thanks for your feature request!

I think this would be quite doable to implement. In settings a field to configure a path to the .env file and then before it starts any dbt process it will source that file. Only question then is which overrides which in case you have an env file as well as normal env vars via the settings configured.

CiderHider commented 2 months ago

Thanks for the quick response. I would say specifically set Env vars override .env vars in the file. That way you still retain control over the tool in the settings, in case some variable settings dont line up.

ramonvermeulen commented 2 months ago

Thanks for the quick response. I would say specifically set Env vars override .env vars in the file. That way you still retain control over the tool in the settings, in case some variable settings dont line up.

Makes sense, maybe I can also make a mechanism to check for a project if there is a .env file in the root of the repository, and if it can find that file it will use it. However I assume a lot of projects might have it in a subdir, and even have different .env files (e.g. dev.env, test.env, prod.env, etc.)

So I still need to do some more thinking/designing to come up with a neat solution for that. I will try to do this in the next release, however I can't promise any timelines haha. Currently quite busy at the job, and this really is a side-project for me, but I'll do my best!

ramonvermeulen commented 2 months ago

@CiderHider FYI opened a draft PR which is still WIP to support dotenv files: https://github.com/ramonvermeulen/dbt-toolkit/pull/136

Aiming to put this in the release of the 27th of September.

CiderHider commented 2 months ago

Amazing, thank you Ramon.