Download codex-rs/config/src/loader/project_discovery.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/config/src/loader/project_discovery.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/config/src/loader/project_discovery.rs
-
curl -L -o project_discovery.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/config/src/loader/project_discovery.rs
1.52 kB
| //! Shared configuration composition for project-root and trust discovery. | |
| use super::layer_io::LoadedConfigLayers; | |
| use super::resolve_relative_paths_in_config_toml; | |
| use crate::merge_toml_values; | |
| use std::io; | |
| use std::path::Path; | |
| use toml::Value as TomlValue; | |
| /// Overlay the already-read managed sources at their normal precedence: file, | |
| /// then MDM. Resolve paths as the final loader does, without changing the raw | |
| /// layers or reading either source again. | |
| pub(super) fn merge_managed_config_for_discovery( | |
| discovery_config: &mut TomlValue, | |
| loaded: &LoadedConfigLayers, | |
| codex_home: &Path, | |
| ) -> io::Result<()> { | |
| if let Some(config) = &loaded.managed_config { | |
| let base_dir = config.file.as_path().parent().ok_or_else(|| { | |
| io::Error::new( | |
| io::ErrorKind::InvalidData, | |
| format!( | |
| "Managed config file {} has no parent directory", | |
| config.file.as_path().display() | |
| ), | |
| ) | |
| })?; | |
| let resolved = | |
| resolve_relative_paths_in_config_toml(config.managed_config.clone(), base_dir)?; | |
| merge_toml_values(discovery_config, &resolved); | |
| } | |
| if let Some(config) = &loaded.managed_config_from_mdm { | |
| let resolved = | |
| resolve_relative_paths_in_config_toml(config.managed_config.clone(), codex_home)?; | |
| merge_toml_values(discovery_config, &resolved); | |
| } | |
| Ok(()) | |
| } | |
| mod tests; | |