Skip to main content

resolve_config_value

Function resolve_config_value 

Source
pub fn resolve_config_value(
    config: &str,
    env_overlay: Option<&BTreeMap<String, String>>,
) -> Option<String>
Expand description

Resolve a config value (API key, header value) that may be a shell command, an env-var template, or a literal — mirroring pi’s resolveConfigValue.

  • !command → run the rest as a shell command (sh -c on Unix, cmd /C on Windows), return trimmed stdout (cached per process). Missing shell or non-zero exit ⇒ None.
  • $VAR / ${VAR} templates: interpolate from env_overlay (winning) then the process env. $$$, $!! escapes. Any referenced var that is unset ⇒ the whole value resolves to None (pi semantics).
  • Otherwise the literal string (returned as-is).

env_overlay is the credential.env map for auth.json keys (pi passes the same). None (or an empty overlay) means process-env only — used for models.json apiKey/headers, which have no env overlay.