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

Method sync_credentials

libatomic/src/local.rs:428–473  ·  view source on GitHub ↗

Resolve all ambient configuration only at the trusted local boundary.

(
        &self,
        repository: &crate::atomic::RepositoryRef,
        remote: &str,
        identity: Option<String>,
        push: bool,
    )

Source from the content-addressed store, hash-verified

426
427 /// Resolve all ambient configuration only at the trusted local boundary.
428 async fn sync_credentials(
429 &self,
430 repository: &crate::atomic::RepositoryRef,
431 remote: &str,
432 identity: Option<String>,
433 push: bool,
434 ) -> Result<(String, String, HttpRemoteConfig), Status> {
435 let handle = self.state.resolve(repository)?;
436 let remote = (!remote.is_empty()).then(|| remote.to_owned());
437 let runtime = tokio::runtime::Handle::current();
438 tokio::task::spawn_blocking(move || {
439 let repo = handle.repository_readonly()?;
440 let name = remote.unwrap_or_else(|| {
441 repo.get_default_remote()
442 .map(|(name, _)| name)
443 .unwrap_or_else(|_| "origin".to_owned())
444 });
445 let url = if name.contains("://") {
446 name.clone()
447 } else {
448 repo.get_remote(&name)
449 .map_err(|error| match error {
450 atomic_repository::RepositoryError::RemoteNotFound { .. } => {
451 crate::daemon::state::domain_status(
452 crate::atomic::ErrorCode::NotFound,
453 format!("remote '{name}' not found"),
454 )
455 }
456 other => repository_error(other),
457 })?
458 .url
459 };
460 if push {
461 auth::check_push_credentials(&url, identity.as_deref()).map_err(auth_status)?;
462 }
463 drop(repo);
464 let config = runtime.block_on(auth::attach_identity(
465 HttpRemoteConfig::new(),
466 &url,
467 identity.as_deref(),
468 ));
469 Ok::<_, Status>((name, url, config))
470 })
471 .await
472 .map_err(|e| Status::internal(format!("credentials task failed: {e}")))?
473 }
474}
475
476fn reject_transport_credentials(

Callers 1

callMethod · 0.80

Calls 12

domain_statusFunction · 0.85
check_push_credentialsFunction · 0.85
attach_identityFunction · 0.85
repository_readonlyMethod · 0.80
get_default_remoteMethod · 0.80
currentFunction · 0.50
repository_errorFunction · 0.50
resolveMethod · 0.45
is_emptyMethod · 0.45
containsMethod · 0.45
cloneMethod · 0.45
get_remoteMethod · 0.45

Tested by

no test coverage detected