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

Function load_identity_lenient

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

140/// An exact match always wins; otherwise the first identity whose name matches
141/// case-insensitively is returned.
142fn load_identity_lenient(store: &IdentityStore, name: &str) -> Option<Identity> {
143 if let Ok(identity) = store.load_by_name(name) {
144 return Some(identity);
145 }
146
147 let wanted = name.to_lowercase();
148 store
149 .list()
150 .ok()?
151 .into_iter()
152 .find(|identity| identity.name.to_lowercase() == wanted)
153}
154
155/// Attach a Bearer JWT auth header to the remote config.
156///

Callers 2

attach_identityFunction · 0.85
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