Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Info

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

Table of Contents

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:

Code Block
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:

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

Result:

Code Block
languagepy
"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:

Code Block
languagepy
"${topic.snow_user:admin}"

Result:

Code Block
languagepy
"admin"

Dictionaries

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

Config reference:

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

Result:

...

languagepy

...

This page can now be found at Configuration Interpolation on the Squirro Docs site.