Configuration Interpolation#

Configuration interpolation allows retrieving values from the Configuration Service and inject them to different parts of Squirro platform. By using specific syntax, it replaces configuration keys with their configuration values.

At the moment, the feature is only implemented in context of the Project Configuration.

Usage#

The syntax to retrieve a specific configuration value from its key is: ${key}.

The examples below show how to use configuration interpolation.

The following sample configuration is used in the examples:

topic.snow-protocol = "https"
topic.snow-server = "mysnow.com"

Strings#

The interpolation takes the string object, extracts the given keys and for each of the keys retrieves the values specified in the configuration. If the key is not found in the configuration, an error is raised.

Config reference:

"${topic.snow-protocol}://${topic.snow-server}"

Result:

"https://mysnow.com"

Default values#

A default value can be specified by including it after the colon. If the key is not found in the configuration, the default value will be used.

Config reference:

"${topic.snow_user:admin}"

Result:

"admin"

Dictionaries#

The interpolation also works with dictionaries. In this case, the values are interpolated recursively.

Config reference:

{
    "details": {
        "url": "${topic.snow-protocol}://${topic.snow-server}",
        "credentials": {
            "password": "${topic.snow-password:foo}",
        },
    },
}

Result:

{
    "details": {
        "url": "https://mysnow.com",
        "credentials": {
            "password": "foo",
        },
    },
}