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

Method set_identity_for_server

atomic-cli/src/commands/server/mod.rs:452–491  ·  view source on GitHub ↗

Bind (or clear) an identity for a server profile.

(&self, cmd: &ServerSetIdentity)

Source from the content-addressed store, hash-verified

450
451 /// Bind (or clear) an identity for a server profile.
452 fn set_identity_for_server(&self, cmd: &ServerSetIdentity) -> CliResult<()> {
453 let mut config = GlobalConfig::load()
454 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load config: {}", e)))?;
455
456 let profile =
457 config
458 .servers
459 .get_mut(&cmd.name)
460 .ok_or_else(|| CliError::InvalidArgument {
461 message: format!(
462 "Server profile '{}' not found. \
463 Use 'atomic server add {} <url>' to create it.",
464 cmd.name, cmd.name
465 ),
466 })?;
467
468 if cmd.clear {
469 profile.identity = None;
470 config
471 .save()
472 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save config: {}", e)))?;
473 print_success(&format!(
474 "Identity cleared for server profile '{}'",
475 cmd.name
476 ));
477 print_hint("Management commands will now use the global default identity.");
478 } else {
479 let identity_name = cmd.identity.as_deref().unwrap();
480 profile.identity = Some(identity_name.to_string());
481 config
482 .save()
483 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save config: {}", e)))?;
484 print_success(&format!(
485 "Identity '{}' bound to server profile '{}'",
486 identity_name, cmd.name
487 ));
488 }
489
490 Ok(())
491 }
492}
493
494impl Command for ServerCmd {

Callers 1

runMethod · 0.80

Calls 5

print_successFunction · 0.85
print_hintFunction · 0.85
get_mutMethod · 0.80
saveMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected