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

Support environment variables in properties file #2181

Open
NathanEckert opened this issue Mar 1, 2024 · 0 comments
Open

Support environment variables in properties file #2181

NathanEckert opened this issue Mar 1, 2024 · 0 comments

Comments

@NathanEckert
Copy link

Hello,

Playing around with the configuration files of Hikari, I noticed it does not support environment variable:

package com.tests.hikari

import static org.assertj.core.api.Assertions.assertThat;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.Cleanup;
import org.junit.jupiter.api.Test;


public class TestHikariExample {

  @Test
  void testHikariConfigFileWithEnvVar() {
    System.setProperty("hikaricp.configurationFile", "src/test/resources/hikari.properties");

    var config = new HikariConfig();

    @Cleanup
    var dataSource = new HikariDataSource(config);

    assertThat(dataSource.getConnectionTimeout()).isEqualTo(250);
    assertThat(config.getConnectionTimeout()).isEqualTo(250);

  }
}

Associated hikari.properties file:

jdbcUrl=jdbc:redshift://my-cluster.redshift.amazonaws.com:port/databaseName
datasource.user=${REDSHIFT_USERNAME}
datasource.password=${REDSHIFT_PASSWORD}
connectionTimeout=250

This works if I use the plain values instead of the env variables

N-B: I might even want to use them in a more convulated way, for example: jdbcUrl=jdbc:redshift://${REDSHIFT_CLUSTER_NAME}.redshift.amazonaws.com:${REDSHIFT_PORT}/${REDSHIFT_DATABASE_NAME}

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

No branches or pull requests

1 participant