(
config_name: Option<&str>,
profile_name: Option<&str>,
overrides: ConfigOverrides<'_>,
allow_missing_profile: bool,
)
| 226 | |
| 227 | impl CodSpeedConfig { |
| 228 | pub fn load_with_profile( |
| 229 | config_name: Option<&str>, |
| 230 | profile_name: Option<&str>, |
| 231 | overrides: ConfigOverrides<'_>, |
| 232 | allow_missing_profile: bool, |
| 233 | ) -> Result<Self> { |
| 234 | let config_path = get_configuration_file_path(config_name); |
| 235 | |
| 236 | let (persisted, was_migrated) = match fs::read(&config_path) { |
| 237 | Ok(config_str) => { |
| 238 | let raw: RawConfig = serde_yaml::from_slice(&config_str).context(format!( |
| 239 | "Failed to parse CodSpeed config at {}", |
| 240 | config_path.display() |
| 241 | ))?; |
| 242 | debug!("Config loaded from {}", config_path.display()); |
| 243 | migrate(raw)? |
| 244 | } |
| 245 | Err(e) if e.kind() == std::io::ErrorKind::NotFound => { |
| 246 | debug!("Config file not found at {}", config_path.display()); |
| 247 | (PersistedConfig::default(), false) |
| 248 | } |
| 249 | Err(e) => bail!("Failed to load config: {e}"), |
| 250 | }; |
| 251 | |
| 252 | if was_migrated { |
| 253 | debug!( |
| 254 | "Upgrading config at {} to v{CURRENT_CONFIG_VERSION}", |
| 255 | config_path.display() |
| 256 | ); |
| 257 | write_persisted(&persisted, config_name)?; |
| 258 | } |
| 259 | |
| 260 | let mut config = Self::from_persisted(persisted); |
| 261 | |
| 262 | config.resolve_selected_profile(profile_name, overrides, allow_missing_profile)?; |
| 263 | |
| 264 | Ok(config) |
| 265 | } |
| 266 | |
| 267 | /// Persist the canonical on-disk configuration. Runtime resolved |
| 268 | /// fields (auth, api_url, upload_url) are not written — only what |
nothing calls this directly
no test coverage detected