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

Function configured_server_identities

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

Collect `(server_host, identity)` pairs from the global config — both the default `[server]` block and every named `[servers.*]` profile — that declare an identity. Servers without an identity binding are skipped. Returns an empty list when no config exists or it can't be read, so resolution degrades cleanly to URL-based inference.

()

Source from the content-addressed store, hash-verified

63/// Returns an empty list when no config exists or it can't be read, so
64/// resolution degrades cleanly to URL-based inference.
65fn configured_server_identities() -> Vec<(String, String)> {
66 let config = match atomic_config::GlobalConfig::load() {
67 Ok(c) => c,
68 Err(e) => {
69 log::debug!("Could not load global config for server identities: {e}");
70 return Vec::new();
71 }
72 };
73
74 let mut pairs = Vec::new();
75 let mut consider = |server: &atomic_config::ServerConfig| {
76 if let (Some(url), Some(identity)) = (server.url.as_ref(), server.identity.as_ref()) {
77 if let Some(host) = Url::parse(url)
78 .ok()
79 .and_then(|u| u.host_str().map(String::from))
80 {
81 pairs.push((host, identity.clone()));
82 }
83 }
84 };
85
86 consider(&config.server);
87 for server in config.servers.values() {
88 consider(server);
89 }
90 pairs
91}
92
93/// Pure identity resolution from a URL plus the configured server bindings.
94///

Callers 1

Calls 4

parseFunction · 0.85
as_refMethod · 0.80
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected