MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / load_identity_lenient

Function load_identity_lenient

atomic-cli/src/commands/auth.rs:230–241  ·  view source on GitHub ↗

Load a local identity by name, falling back to a case-insensitive match. Tenant slugs are lowercase (e.g. `aaron`), but locally stored identities are free-form and frequently mixed-case (e.g. `Aaron`). A subdomain-inferred name would therefore never match the local identity on a strict comparison. An exact match always wins; otherwise the first identity whose name matches case-insensitively is re

(store: &IdentityStore, name: &str)

Source from the content-addressed store, hash-verified

228/// An exact match always wins; otherwise the first identity whose name matches
229/// case-insensitively is returned.
230fn load_identity_lenient(store: &IdentityStore, name: &str) -> Option<Identity> {
231 if let Ok(identity) = store.load_by_name(name) {
232 return Some(identity);
233 }
234
235 let wanted = name.to_lowercase();
236 store
237 .list()
238 .ok()?
239 .into_iter()
240 .find(|identity| identity.name.to_lowercase() == wanted)
241}
242
243/// Resolve a concrete identity for a remote operation, falling back to the
244/// default identity when the inferred name doesn't match any local identity.

Callers 2

check_push_credentialsFunction · 0.85

Calls 3

load_by_nameMethod · 0.80
into_iterMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected