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> is env, <VALUE> is interpreted as environment variable name, and the secret is the value of that environment variable;
  • if <KIND> is file, <VALUE> is interpreted as a file name, and the secret is the contents of that file;
  • if <KIND> is txt, <VALUE> is interpreted as the secret itself.

See REGEX_STR for the exact regex.

Arguments

  • s - string to interpolate
  • percent_decode - whether to “percent decode” s first (useful if s was obtained by converting an URI to string)

Returns

  • A secret string, since some of the interpolated values may be secret.