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

Method sync_credentials

libatomic/src/local.rs:365–410  ·  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

363
364 /// Resolve all ambient configuration only at the trusted local boundary.
365 async fn sync_credentials(
366 &self,
367 repository: &crate::atomic::RepositoryRef,
368 remote: &str,
369 identity: Option<String>,
370 push: bool,
371 ) -> Result<(String, String, HttpRemoteConfig), Status> {
372 let handle = self.state.resolve(repository)?;
373 let remote = (!remote.is_empty()).then(|| remote.to_owned());
374 let runtime = tokio::runtime::Handle::current();
375 tokio::task::spawn_blocking(move || {
376 let repo = handle.repository_readonly()?;
377 let name = remote.unwrap_or_else(|| {
378 repo.get_default_remote()
379 .map(|(name, _)| name)
380 .unwrap_or_else(|_| "origin".to_owned())
381 });
382 let url = if name.contains("://") {
383 name.clone()
384 } else {
385 repo.get_remote(&name)
386 .map_err(|error| match error {
387 atomic_repository::RepositoryError::RemoteNotFound { .. } => {
388 crate::daemon::state::domain_status(
389 crate::atomic::ErrorCode::NotFound,
390 format!("remote '{name}' not found"),
391 )
392 }
393 other => repository_error(other),
394 })?
395 .url
396 };
397 if push {
398 auth::check_push_credentials(&url, identity.as_deref()).map_err(auth_status)?;
399 }
400 drop(repo);
401 let config = runtime.block_on(auth::attach_identity(
402 HttpRemoteConfig::new(),
403 &url,
404 identity.as_deref(),
405 ));
406 Ok::<_, Status>((name, url, config))
407 })
408 .await
409 .map_err(|e| Status::internal(format!("credentials task failed: {e}")))?
410 }
411}
412
413fn 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