Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Allow use of environment variables as an alternative to database credentials in application.properties #15

Merged
merged 1 commit into from
Feb 28, 2022

Conversation

MaartenS11
Copy link
Contributor

@MaartenS11 MaartenS11 commented Feb 23, 2022

This allows getting the password, username and/or url for the database from the respective OSOC_DB_PASSWORD, OSOC_DB_USERNAME and OSOC_DB_URL env variables if they are set. In the case that they are not set default values from the application.properties file will be used just like before this merge request.

@MaartenS11 MaartenS11 self-assigned this Feb 23, 2022
@MaartenS11 MaartenS11 added the enhancement New feature or request label Feb 23, 2022
@MaartenS11 MaartenS11 added this to the Milestone 1 milestone Feb 23, 2022
@Nyxes5
Copy link
Contributor

Nyxes5 commented Feb 23, 2022

You should probably make a file .env.example in the correct directory with for example OSOC_DB_PASSWORD=<PASSWORD>

@TomAlard
Copy link
Contributor

Could you add some comments to the code?

@TomAlard
Copy link
Contributor

TomAlard commented Feb 24, 2022

I think we should also write a unit test.

@TomAlard
Copy link
Contributor

I think we should also write a unit test.

I thought this would be a problem for tests, but as discussed in 'Meeting 2' this code works fine with tests.

TomAlard
TomAlard previously approved these changes Feb 28, 2022
@Nyxes5 Nyxes5 self-requested a review February 28, 2022 13:43
Nyxes5
Nyxes5 previously approved these changes Feb 28, 2022
This commit allows getting the password, username and/or url for the
database from the respective OSOC_DB_PASSWORD, OSOC_DB_USERNAME and
OSOC_DB_URL env variables if they are set. In the case that they are not
set default values from the "application.properties" file will be used
just like before this commit.

Implementation details:
The "application.properties" file is loaded lazily into the
applicationProperties field when it is needed and reused if any other
env variables were not set.
@MaartenS11 MaartenS11 merged commit 45157df into development Feb 28, 2022
@TomAlard TomAlard deleted the env_variable_credentials branch March 6, 2022 10:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow use of environment variables as an alternative to database credentials in application.properties
3 participants