Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: read pointed file of environment variables using github.com/joho/godotenv #603

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

smoke
Copy link
Contributor

@smoke smoke commented Oct 6, 2023

refs #347 (comment)

Defaulting to .env in the current directory.

Skipping any error, including non-existing file or errors while parsing
the file as no better options for now.

@smoke smoke force-pushed the feat/read-dotenv-files-using-godotenv branch from 7efba1d to 0792b08 Compare October 6, 2023 06:23
@smoke smoke marked this pull request as draft October 9, 2023 21:47
@smoke
Copy link
Contributor Author

smoke commented Oct 9, 2023

I have noticed that missing .env is considered a fatal error, where it should not be ...
now reconsidering the options

@smoke smoke force-pushed the feat/read-dotenv-files-using-godotenv branch from 0792b08 to a8033f0 Compare October 9, 2023 22:14
@smoke smoke marked this pull request as ready for review October 9, 2023 22:15
@smoke
Copy link
Contributor Author

smoke commented Oct 9, 2023

Considered to expose option to read file pointed via -env-file and as well to skip any errors while doing that.

@smoke smoke changed the title feat: read .env using github.com/joho/godotenv feat: read pointed file of environment variables using github.com/joho/godotenv Oct 9, 2023
…ho/godotenv`

Defaulting to `.env` in the current directory.

Skipping any error, including non-existing file or errors while parsing
the file as no better options for now.
@smoke smoke force-pushed the feat/read-dotenv-files-using-godotenv branch from c7ad2e4 to ac67cd0 Compare December 25, 2023 06:12
@smoke
Copy link
Contributor Author

smoke commented Dec 25, 2023

@mfridman I have rebased this branch, please take a look.

@smoke smoke force-pushed the feat/read-dotenv-files-using-godotenv branch from ac67cd0 to d5ed18d Compare December 25, 2023 06:38
@mfridman
Copy link
Collaborator

mfridman commented Dec 25, 2023

Related issue (and what this would close if merged) #329.

I'm still not convinced this is necessary, could you describe why the goose package and CLI should understand how to read/parse .env or .envrc files, as opposed to letting the user set their ENV variables how they want?

Afaics there are a lot of tools out there that do this well, e.g., https://direnv.net/, plain export, etc.

It should be up to the user to set their ENV variables, instead of every tool in existence reading these files.

Maybe I'm missing something, but I'd like to understand why this is needed.

@smoke
Copy link
Contributor Author

smoke commented Dec 26, 2023

@mfridman That is a good point indeed and makes me wonder as well. Me and many others most likely are used to have such capability embedded and being cross-platform from tools like docker compose https://docs.docker.com/compose/environment-variables/set-environment-variables/
There are many ways to achieve that indeed, but in most cases it comes with good enough craftsmanship and is not easy to use for huge teams or less skilled people.

I personally love organizing different environments in different files e.g.

.env-dev
.env-qa
.env-stage
.env-others

then use goose to directly and seamlessly source from given env e.g.

goose -env-file .env-dev status

or direclty symlinking the relevant environment I am working with

ln -sf .env-dev .env
goose status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants