In my Quarkus application, I don't want passwords to be versionned by Git.
I don't have any issue with the prod
profile because I have a config file in $PWD/config/application.properties
. Fine.
For the dev
profile, I'm using the .env
approach which contains properties such as :
QUARKUS_DATASOURCE_PASSWORD=foo
I'm trying to setup tests and I need some separate conf for tests.
So I have the following config in my src/test/resources/application.properties
:
%test.quarkus.datasource.password=bar
Unfortunately, the test value (bar
) is overriden by the .env
value (foo
) which is supposed to be dedicated to the dev
profile.
I don't find an elegant way to fix it.
Based on https://quarkus.io/guides/config#overriding-properties-at-runtime I have 5 possible approachs:
.env
file: Could work, but I can't specifiy value for dev
profile only (aka %dev.[...]
) ;$PWD/config/application.properties
file: well, this is for dev mode, I don't find it convinient as target is cleared and I have to copy again the config
folder after each mvn clean
;ConfigSource
or ConfigSourceProvider
. I know this one could work, but I prefer to avoid doing specific stuff in my project, and stay with the builtin Quarkus config.I just found that I was wrong about that :
.env
file: Could work, but I can't specifiy value for dev profile only (aka%dev.[...]
) ;
It is possible to have custom profile values in .env
file :
_DEV_QUARKUS_DATASOURCE_PASSWORD=foo
As I can prefix the property with _DEV_[...]
, this value is for dev
profile only: the test
property is not overriden anymore.