Class EnvironmentVariableAliases

java.lang.Object
io.helidon.config.EnvironmentVariableAliases

public class EnvironmentVariableAliases extends Object
Provides configuration key aliases in an attempt to map to legal environment variable names.

The MP config specification describes the environment variables ConfigSource as follows:

 Some operating systems allow only alphabetic characters or an underscore, _, in environment variables. Other
 characters such as ., /, etc may be disallowed. In order to set a value for a config property that has a name
 containing such disallowed characters from an environment variable, the following rules are used.

 This ConfigSource searches 3 environment variables for a given property name (e.g. com.ACME.size):

  1. Exact match (i.e. com.ACME.size)
  2. Replace the character that is neither alphanumeric nor _ with _ (i.e. com_ACME_size)
  3. Replace the character that is neither alphanumeric nor _ with _ and convert to upper case (i.e. COM_ACME_SIZE)
 

Since Helidon supports many hyphenated configuration keys (e.g. "server.executor-service.max-pool-size"), an additional mapping is required to produce aliases that can be expressed as environment variable names (e.g. "SERVER_EXECUTOR_dash_SERVICE_MAX_dash_POOL_dash_SIZE"); see aliasesOf(String) for details.

  • Method Details

    • aliasesOf

      public static List<String> aliasesOf(String key)
      Returns a list of aliases for the given config key.

      If the key does not contain any '-' (dash) characters, all disallowed characters are replaced by '_' (underscore) and this plus the uppercase variant are returned. For example, "app.qualifiedName" and "app/qualifiedName" both result in the same two aliases:

      1. "app_qualifiedName"
      2. "APP_QUALIFIEDNAME"
      If the key does contain any '-' (dash) characters, they are replaced by "_dash_" and by the uppercase variant so that, e.g., "app.page-size" results in three aliases:
      1. "app_page_dash_size"
      2. "APP_PAGE_dash_SIZE"
      3. "APP_PAGE_DASH_SIZE"
      Parameters:
      key - The configuration key.
      Returns:
      The list of aliases.