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

Function resolve_org_with_server

atomic-cli/src/commands/client.rs:246–273  ·  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

244/// An explicit empty string (`--org ""`) is an error: the user asked for "no
245/// org" which never makes sense.
246pub fn resolve_org_with_server(
247 org_override: Option<&str>,
248 server: &atomic_config::ServerConfig,
249) -> CliResult<String> {
250 if let Some(s) = org_override {
251 if s.is_empty() {
252 return Err(CliError::InvalidArgument {
253 message: "Organization slug cannot be empty.".to_string(),
254 });
255 }
256 return Ok(s.to_string());
257 }
258
259 if let Some(org) = &server.default_org {
260 return Ok(org.clone());
261 }
262
263 // Fall back to the personal org of the identity this server authenticates
264 // as. Registration seeds the personal org slug from the identity name, so
265 // the identity name is the correct default until the user runs
266 // `atomic org set` to switch to a team org.
267 let identity = resolve_identity_for_server(server).map_err(|_| CliError::InvalidArgument {
268 message: "No organization specified.\n \
269 Use --org or set a default with: atomic org set <slug>"
270 .to_string(),
271 })?;
272 Ok(identity.name)
273}
274
275/// Resolve the org slug for callers that don't already hold a server config.
276///

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