Xyna-Factory / xyna-factory

Sources of the Xyna Factory Server, Xyna runtime applications (like GuiHttp or gitintegration), and installation scripts.
Apache License 2.0
16 stars 3 forks source link

DB pool configuration using environment variables #1244

Open csc-gip opened 2 weeks ago

csc-gip commented 2 weeks ago

Add optional string parameters to the DB connection pools to take username, password and connect string from environment variables to simplify container build and runtime configuration.

i.e. if an additional property is set for the pool during configuration use the environment variable instead of the stored value.

  public static final StringParameter<String> USERNAME_ENV= 
      StringParameter.typeString("usernameEnv").
      label("Username environment variable.").
      documentation(Documentation.
                    en("Name of the environment variable containing the db username.").
                    de("Name der Umgebungsvariable, die den DB Nutzernamen enthält.").
                    build()).
      optional().build();

  public static final StringParameter<String> PASSWORD_ENV= 
      StringParameter.typeString("passwordEnv").
      label("Password environment variable.").
      documentation(Documentation.
                    en("Name of the environment variable containing the db password.").
                    de("Name der Umgebungsvariable, die das DB Passwort enthält.").
                    build()).
      optional().build();

  public static final StringParameter<String> CONNECT_ENV= 
      StringParameter.typeString("connectStringEnv").
      label("Connectstring environment variable.").
      documentation(Documentation.
                    en("Name of the environment variable containing the JDBC connect string.").
                    de("Name der Umgebungsvariable, die die JDBC Verbindungsdaten enthält.").
                    build()).
      optional().build();

In order to allow for runtime credential rotation the connection build strategy should reread the properties, when creating a new connection.