Module includes

Module includes 

Source
Expand description

Config includes and file-based profiles (CFG-01, #180).

A config document may carry a top-level includes: key listing file paths or directory globs (relative to the config file’s directory). resolve_includes reads each, recursively resolves includes in them, and merges the result into the base document with conflict detection: the same scalar key set in two documents is an error (forces the operator to be explicit), while collection keys (listeners, routes, upstreams, …) from an include REPLACE the base’s (an include is a full topology overlay, not a delta).

File-based profiles: when gateway.lifecycle.profiles.profiles_dir is set, the selected profile’s patch is loaded from <profiles_dir>/<profile>.yaml instead of an inline YAML string. apply_profile_overlay resolves the profile (from an explicit name or the DWARA_PROFILE env var) and merges the patch onto the base. This is backward compatible: inline profile_overrides still work when profiles_dir is absent.

Both operate on raw YAML text BEFORE super::parse_gateway, so the includes: / profiles_dir directives are consumed and never reach the strict deny_unknown_fields Gateway struct.

Functions§

apply_profile_overlay
Apply the selected profile’s overlay onto the base config. The profile is profile when given, else the DWARA_PROFILE env var. When gateway.lifecycle.profiles.profiles_dir is set, the patch is loaded from <profiles_dir>/<profile>.yaml; otherwise the inline profile_overrides map is used (backward compat). The merged YAML text is returned.
preprocess
Full preprocessing: resolve includes, then apply the profile.
resolve_includes
Resolve includes: directives in a config document. The includes: top-level key lists file paths or directory globs (relative to base_dir). Each is read, recursively resolved, and merged into the base. The includes: key is removed from the result. Returns the merged YAML text.