Function cubist_config::interpolation::try_interpolate
source · pub fn try_interpolate(s: &str, percent_decode: bool) -> Result<SecretString>
Expand description
Try to interpolate a given string, optionally “percent decoding” it first.
Substrings matching ${{<KIND>.<VALUE>}}
(where <KIND>
is either env
,
file
, or text
, and <VALUE>
is an arbitrary string) are subject to
interpolation. More precisely:
- if
<KIND>
isenv
,<VALUE>
is interpreted as environment variable name, and the secret is the value of that environment variable; - if
<KIND>
isfile
,<VALUE>
is interpreted as a file name, and the secret is the contents of that file; - if
<KIND>
istxt
,<VALUE>
is interpreted as the secret itself.
See REGEX_STR
for the exact regex.
Arguments
s
- string to interpolatepercent_decode
- whether to “percent decode”s
first (useful ifs
was obtained by converting an URI to string)
Returns
- A secret string, since some of the interpolated values may be secret.