apply_profile

Function apply_profile 

Source
pub fn apply_profile(overlay: &ProfileOverlay) -> Result<AppliedProfile, String>
Expand description

Apply the selected profile’s patch onto the base config.

The profile is read from the DWARA_PROFILE env var. When unset, the base config is returned unchanged. When set to a recognized profile (dev/staging/prod, case-insensitive) AND that profile has a patch in the overlay, the patch is merged onto the base. When set to a recognized profile with NO patch, the base is returned unchanged (the profile is selected but defines no overrides – a no-op overlay). When set to an unrecognized value, the base is returned unchanged (an unknown profile is a no-op, not an error – the operator may have a typo, but the gateway still starts on the base config).

The merge is a shallow JSON merge: the base and patch are each parsed into JSON values, the patch’s top-level keys overwrite the base’s, and the result is serialized back to YAML. Collection fields (listeners, routes, upstreams, etc.) in the patch REPLACE the base’s collections (not append) – a profile is a full topology overlay.