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

Function verify_workspace_exists

atomic-cli/src/commands/workspace/set.rs:186–204  ·  view source on GitHub ↗

Confirm the workspace slug resolves on the server under the target org. 404s surface as a clean slug-specific message; other failures (network, auth, wrong org) bubble through so the user can distinguish problems.

(org_slug: &str, workspace_slug: &str)

Source from the content-addressed store, hash-verified

184/// 404s surface as a clean slug-specific message; other failures (network,
185/// auth, wrong org) bubble through so the user can distinguish problems.
186fn verify_workspace_exists(org_slug: &str, workspace_slug: &str) -> CliResult<()> {
187 let rt = tokio::runtime::Runtime::new()
188 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {e}")))?;
189
190 rt.block_on(async {
191 let (client, _resolved) = build_client_with_org(Some(org_slug), None).await?;
192 match client.get_workspace(workspace_slug).await {
193 Ok(_) => Ok(()),
194 Err(e) if e.is_not_found() => Err(CliError::InvalidArgument {
195 message: format!(
196 "Workspace '{workspace_slug}' not found in org '{org_slug}'.\n \
197 Check the slug with: atomic workspace list --org {org_slug}\n \
198 Or pass --no-verify to set the value without checking."
199 ),
200 }),
201 Err(e) => Err(remote_err(e)),
202 }
203 })
204}
205
206#[cfg(test)]
207mod tests {

Callers

nothing calls this directly

Calls 4

build_client_with_orgFunction · 0.85
remote_errFunction · 0.85
get_workspaceMethod · 0.80
is_not_foundMethod · 0.45

Tested by

no test coverage detected