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

Function resolve_person

atomic-cli/src/commands/provenance/command.rs:214–246  ·  view source on GitHub ↗

Resolve the PERSON's signing identity + keypair, exactly as `atomic intent attest` does.

(
    identity: Option<&str>,
)

Source from the content-addressed store, hash-verified

212/// Resolve the PERSON's signing identity + keypair, exactly as
213/// `atomic intent attest` does.
214pub(crate) fn resolve_person(
215 identity: Option<&str>,
216) -> CliResult<(
217 atomic_identity::identity::Identity,
218 atomic_identity::keypair::KeyPair,
219)> {
220 let store = IdentityStore::open_default()
221 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to open identity store: {}", e)))?;
222 let identity = if let Some(name) = identity {
223 store
224 .load_by_name(name)
225 .map_err(|_| CliError::IdentityNotFound(name.to_string()))?
226 } else {
227 store
228 .get_default()
229 .map_err(|e| {
230 CliError::Internal(anyhow::anyhow!("Failed to load default identity: {}", e))
231 })?
232 .ok_or_else(|| CliError::InvalidArgument {
233 message: "No default identity set. Create one first:\n \
234 atomic identity new <name> --email <email> --set-default"
235 .to_string(),
236 })?
237 };
238 let keypair = store.load_keypair(&identity.id, None).map_err(|e| {
239 CliError::Internal(anyhow::anyhow!(
240 "Failed to load keypair for '{}': {}",
241 identity.name,
242 e
243 ))
244 })?;
245 Ok((identity, keypair))
246}
247
248/// Print the PROV JSON-LD artifact(s) to stdout. When `signed`, add the
249/// dev-signature caveat (the signing path was used).

Callers 2

runMethod · 0.85
attest_reportFunction · 0.85

Calls 3

load_by_nameMethod · 0.80
load_keypairMethod · 0.80
get_defaultMethod · 0.45

Tested by

no test coverage detected