Skip to main content

interpolate_env_json

Function interpolate_env_json 

Source
pub fn interpolate_env_json(value: &mut Value)
Expand description

Recursively interpolates ${ENV_VAR:-default} patterns in every string leaf of a JSON value — object values, array elements, and nested combinations — leaving numbers, booleans, and null untouched.

This is the single resolution point for structured plugin config from every source — gateway.yaml (loaded raw by load_yaml), the Admin API / Web UI, and etcd. Applied at graph-compile time it is source-agnostic: a client_id: ${CLIENT_ID} resolves identically however it was authored, and the stored config keeps the placeholder form (so the Admin API never serves resolved secrets).

A string that is exactly one ${...} placeholder is typed like the YAML scalar it stands in for: a resolved value of true/false becomes a boolean and a value parsing as a number becomes a number (port: ${PORT:-3010} yields 3010, not "3010"); anything else, including the empty string, stays a string. A placeholder embedded in wider text always resolves to a string.