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

Function verify_workspace_exists

atomic-cli/src/commands/workspace/set.rs:184–202  ·  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

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