Pure decision core for identity resolution with a default fallback. Split from [`resolve_identity_with_default_fallback`] so the fallback logic can be unit-tested without an on-disk identity store. `inferred_name` — the name resolved from the URL/`--identity` (if any). `explicit` — whether the name came from `--identity` (vs. URL inference). `inferred_exists` — whether an identity with the given
(
inferred_name: Option<&str>,
explicit: bool,
inferred_exists: impl Fn(&str) -> bool,
default_name: Option<String>,
)
| 332 | /// Returns the identity name to authenticate as, or `None` when nothing usable |
| 333 | /// resolves (the caller should error). |
| 334 | fn decide_identity_with_default_fallback( |
| 335 | inferred_name: Option<&str>, |
| 336 | explicit: bool, |
| 337 | inferred_exists: impl Fn(&str) -> bool, |
| 338 | default_name: Option<String>, |
| 339 | ) -> Option<String> { |
| 340 | if let Some(name) = inferred_name { |
| 341 | if inferred_exists(name) { |
| 342 | return Some(name.to_string()); |
| 343 | } |
| 344 | // Inferred name not found locally. If it came from --identity, that's |
| 345 | // an explicit miss — error, don't silently substitute the default. |
| 346 | if explicit { |
| 347 | return None; |
| 348 | } |
| 349 | } |
| 350 | // Fall back to the default identity (subdomain-inferred miss, or nothing |
| 351 | // inferable at all). The subdomain is the org slug, not the identity name, |
| 352 | // so a mismatch here is the expected, common case. |
| 353 | default_name |
| 354 | } |
| 355 | |
| 356 | /// Attach a Bearer JWT auth header to the remote config. |
| 357 | /// |
no outgoing calls