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

Placeholders in configuration #66

Merged
merged 5 commits into from
Oct 3, 2023
Merged

Conversation

jampukka
Copy link
Collaborator

@jampukka jampukka commented Oct 2, 2023

Allow placeholders to be used in configuration. The main goal was to allow users to configure database connection settings as environment variables as requested in #50.

HakunapiConfigParser will now try to replace ${<placeholder>} snippets in property values by checking if an

  1. environment variable or a
  2. system property with that placeholder name exists.

If the placeholder value can't be resolved it's left as is. This is done because some next step might expect the value remain as a placeholder, for example the server url config added in #63.

Additionally, allow postgis database configurations to be inlined in hakunapi main configuration file, e.g.:

db=my_db
db.my_db.dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
db.my_db.dataSource.user=address_reader
db.my_db.dataSource.password=test
db.my_db.dataSource.databaseName=address_fin
db.my_db.dataSource.portNumber=${DB_PORT}
db.my_db.dataSource.serverName=localhost

collections.addresses.db=my_db

Everything under db.<database_identifier>.* is passed on to HikariCP as-is (as in with the db.<database_identifier>. prefix removed). The end result is identical to a separate <database_identifier>.properties file.

@jampukka jampukka added this to the 1.2.0 milestone Oct 2, 2023
@jampukka
Copy link
Collaborator Author

jampukka commented Oct 3, 2023

After a night's sleep two issues remain:

  1. separate <my_db>.properties config files don't get treated the same as the main configuration file (this should be an easy fix)
  2. if I understand az passwordless example correctly azure-identity-extensions might expect the ${AZ_ENV_VARIABLE} placeholders as placeholders (e.g. user=${AZ_POSTGRESQL_AD_NON_ADMIN_USERNAME} not user=my_datatabase_user). However, I don't see why it wouldn't work if hakunapi "resolved" the values before handing them to azure-identity-extensions

Copy link
Collaborator

@nls-jajuko nls-jajuko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Inlined db properties is a good addition.

@jampukka jampukka merged commit 1c5a3fd into main Oct 3, 2023
2 checks passed
@jampukka jampukka deleted the feature/env-variables-for-db branch October 3, 2023 10:53
@jampukka
Copy link
Collaborator Author

jampukka commented Oct 3, 2023

  1. separate <my_db>.properties config files don't get treated the same as the main configuration file (this should be an easy fix)

Fixed in 1acefa4

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.

2 participants