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

Function match_server_identity

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

Pick the identity bound to the configured server whose host is the longest dot-boundary suffix of `remote_host`. When several profiles' hosts match with the same length (e.g. the legacy `[server]` block and a named profile pointing at the same server), the **active** profile wins — the one `default_server` selects, else the legacy block. Longest-suffix still wins over active: a more specific serv

(remote_host: &str, servers: &[ServerBinding])

Source from the content-addressed store, hash-verified

170/// for hosts under both — e.g. `x.staging.atomic.storage` resolves to the
171/// staging identity, not prod.
172fn match_server_identity(remote_host: &str, servers: &[ServerBinding]) -> Option<String> {
173 servers
174 .iter()
175 .filter(|b| host_is_under(remote_host, &b.host))
176 .max_by_key(|b| (b.host.len(), b.active))
177 .map(|b| b.identity.clone())
178}
179
180/// Whether `remote_host` is the server host itself or a subdomain of it,
181/// matching only on dot boundaries (so `notatomic.storage` does NOT match

Callers 1

Calls 4

host_is_underFunction · 0.85
iterMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected