paulschwarz / spring-dotenv

Provides a Dotenv property source for Spring
MIT License
325 stars 23 forks source link

Add support the Dotenv configuration options #6

Closed durimkryeziu closed 2 years ago

durimkryeziu commented 3 years ago

I'd like this library to have support for Dotenv configuration options: https://github.com/cdimascio/dotenv-java#configuration-options

So I'd like to be able to change the 'directory' and 'filename'

Thanks

paulschwarz commented 3 years ago

I don't mind the idea, however there are a few questions I'd like to ask you.

  1. have you run into a case where it's not sufficient to rely on the default locations of project root and resources root?
  2. have you run into a case where the default name .env is not sufficient?
  3. how do you propose to configure the Dotenv loading without confusing the user?

Discussion

Question 1: So far, in my projects I've never come across a need to specify a different directory. Are you sure you're using the library/concept correctly?

Question 2: I have seen some frameworks leverage different profiles like .env.testing but I'm nervous that if we allow that, people will revert to profile-based environments which goes against 12factor app's explanation of Config.

Question 3: How to make sure we don't create configurationception?

Thoughts? Proposal? PR?

durimkryeziu commented 3 years ago

I don't mind the idea, however there are a few questions I'd like to ask you.

  1. have you run into a case where it's not sufficient to rely on the default locations of project root and resources root?
  2. have you run into a case where the default name .env is not sufficient?
  3. how do you propose to configure the Dotenv loading without confusing the user?

Discussion

Question 1: So far, in my projects I've never come across a need to specify a different directory. Are you sure you're using the library/concept correctly?

Question 2: I have seen some frameworks leverage different profiles like .env.testing but I'm nervous that if we allow that, people will revert to profile-based environments which goes against 12factor app's explanation of Config.

Question 3: How to make sure we don't create configurationception?

Thoughts? Proposal? PR?

  1. No, simply wanted to put into a different directory like /env and then put different files there like .env.local .env.dev, but then this relates to point number 2 which is not what this is meant for, so all good 👍

P.S. I just started using this library today :)

  1. I thought by having defaults, as it is without specifying those!

Thanks for your reply and clarification :)

petromir commented 3 years ago

Any plans to implement this? We have the following case: A monorepo multi-module project which has several application each in different module

.
application1
application1/.env
application1/.env.test
application2
application2/.env
application2/.env.test

Each of this sub-modules are started separately. env.test is used in during our tests

paulschwarz commented 3 years ago

@petromir @durimkryeziu would anyone mind submitting a PR? I believe that it makes sense to allow the library to be configured. At first I was just hesitant because it looks like it would descend into users creating multi-tier env files.

petromir commented 3 years ago

I personally don't mind to wait for your solution once you return from vacation 😉

paulschwarz commented 2 years ago

@durimkryeziu @petromir thanks for your patience. I released v2.4.0 today. Please see the section on configuration https://github.com/paulschwarz/spring-dotenv#configuration-optional

Looking forward to hearing your feedback.

landsman commented 2 years ago

@paulschwarz do you have an example of how to write configuration in .properties file? Thanks

paulschwarz commented 2 years ago

@landsman I added an example to the readme https://github.com/paulschwarz/spring-dotenv#configuration-optional (scroll down).