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

Function resolve_org_with_server

atomic-cli/src/commands/client.rs:319–346  ·  view source on GitHub ↗

Resolve the org slug for a command, with fallback to the configured default. This variant uses the *active* server's `default_org` so that per-server org defaults are respected. Resolution order: 1. `--org` override (if `Some(non-empty)`) 2. `server.default_org` from the resolved server profile 3. The default identity's personal org (the identity name), so commands always target the tenant assoc

(
    org_override: Option<&str>,
    server: &atomic_config::ServerConfig,
)

Source from the content-addressed store, hash-verified

317/// An explicit empty string (`--org ""`) is an error: the user asked for "no
318/// org" which never makes sense.
319pub fn resolve_org_with_server(
320 org_override: Option<&str>,
321 server: &atomic_config::ServerConfig,
322) -> CliResult<String> {
323 if let Some(s) = org_override {
324 if s.is_empty() {
325 return Err(CliError::InvalidArgument {
326 message: "Organization slug cannot be empty.".to_string(),
327 });
328 }
329 return Ok(s.to_string());
330 }
331
332 if let Some(org) = &server.default_org {
333 return Ok(org.clone());
334 }
335
336 // Fall back to the personal org of the identity this server authenticates
337 // as. Registration seeds the personal org slug from the identity name, so
338 // the identity name is the correct default until the user runs
339 // `atomic org set` to switch to a team org.
340 let identity = resolve_identity_for_server(server).map_err(|_| CliError::InvalidArgument {
341 message: "No organization specified.\n \
342 Use --org or set a default with: atomic org set <slug>"
343 .to_string(),
344 })?;
345 Ok(identity.name)
346}
347
348/// Resolve the org slug for callers that don't already hold a server config.
349///

Callers 3

build_client_with_orgFunction · 0.85
resolve_orgFunction · 0.85
run_with_verifierMethod · 0.85

Calls 3

is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected