Pure resolution over the chain, split from the I/O so the order is unit-testable. Env var beats the global setting beats the active server profile; empty or whitespace-only values are skipped as if unset at every level.
(
env: Option<&str>,
config: &GlobalConfig,
)
| 175 | /// Env var beats the global setting beats the active server profile; empty |
| 176 | /// or whitespace-only values are skipped as if unset at every level. |
| 177 | fn resolve_from_parts( |
| 178 | env: Option<&str>, |
| 179 | config: &GlobalConfig, |
| 180 | ) -> Option<(String, AgentIdentitySource)> { |
| 181 | if let Some(name) = env.map(str::trim).filter(|n| !n.is_empty()) { |
| 182 | return Some((name.to_string(), AgentIdentitySource::EnvVar)); |
| 183 | } |
| 184 | if let Some(name) = config.agent_identity.as_deref().map(str::trim) { |
| 185 | if !name.is_empty() { |
| 186 | return Some((name.to_string(), AgentIdentitySource::GlobalSetting)); |
| 187 | } |
| 188 | } |
| 189 | if let Some(name) = config.active_server_agent_identity().map(str::trim) { |
| 190 | if !name.is_empty() { |
| 191 | return Some((name.to_string(), AgentIdentitySource::ServerProfile)); |
| 192 | } |
| 193 | } |
| 194 | None |
| 195 | } |
| 196 | |
| 197 | // Set Command |
| 198 |