StringInterpolator (secret_config v1.0.0)

Provides functionality for interpolating environment variables into strings within a map.

Link to this section Summary

Functions

Interpolates environment variables into the values of a given map.

Link to this section Functions

Link to this function

interpolate_env(map)

Specs

interpolate_env(map :: map()) :: map()

Interpolates environment variables into the values of a given map.

Iterates over each key-value pair in the map, replacing placeholders in the values with the corresponding environment variable values. If an environment variable is missing, a RuntimeError is raised indicating the missing variable.

Parameters

  • map: A map with string values possibly containing placeholders for environment variables in the format ${env:VAR_NAME}.

Returns

  • A new map with the same keys but with interpolated values.

Examples

iex> StringInterpolator.interpolate_env(%{"greeting" => "Hello, ${env:USER}"})
%{"greeting" => "Hello, Alice"}

Errors

  • Raises RuntimeError if an environment variable referenced in a value does not exist.