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

Function load_identity_lenient

atomic-cli/src/commands/auth.rs:149–160  ·  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

147/// An exact match always wins; otherwise the first identity whose name matches
148/// case-insensitively is returned.
149fn load_identity_lenient(store: &IdentityStore, name: &str) -> Option<Identity> {
150 if let Ok(identity) = store.load_by_name(name) {
151 return Some(identity);
152 }
153
154 let wanted = name.to_lowercase();
155 store
156 .list()
157 .ok()?
158 .into_iter()
159 .find(|identity| identity.name.to_lowercase() == wanted)
160}
161
162/// Resolve a concrete identity for a remote operation, falling back to the
163/// 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