MCPcopy Create free account
hub / github.com/Qovery/engine / login

Method login

lib-engine/src/cmd/docker.rs:544–595  ·  view source on GitHub ↗
(&self, registry: &Url)

Source from the content-addressed store, hash-verified

542 }
543
544 pub fn login(&self, registry: &Url) -> Result<(), DockerError> {
545 let username = match urlencoding::decode(registry.username()) {
546 Ok(decoded_username) => decoded_username,
547 Err(err) => {
548 return Err(DockerError::InvalidConfig {
549 raw_error_message: format!("Cannot decode username due to: {err}"),
550 });
551 }
552 };
553 if username.is_empty() {
554 return Ok(());
555 }
556
557 info!("Docker login {} as user {}", registry, username);
558
559 let password = registry
560 .password()
561 .and_then(|password| urlencoding::decode(password).ok())
562 .unwrap_or_default();
563
564 let registry_host = {
565 let registry_port = registry.port_or_known_default().unwrap_or(443);
566 let registry_host = registry.host_str().unwrap_or_default();
567 if registry_port == 443 {
568 registry_host.to_string()
569 } else {
570 format!("{registry_host}:{registry_port}")
571 }
572 };
573
574 let args = vec![
575 "--config",
576 self.config_path.path().to_str().unwrap_or(""),
577 "login",
578 &registry_host,
579 "-u",
580 &username,
581 "-p",
582 &password,
583 ];
584
585 let _lock = LOGIN_LOCK.lock().unwrap();
586 docker_exec(
587 &args,
588 &self.get_all_envs(&[]),
589 &mut |line| info!("{}", line),
590 &mut |line| warn!("{}", line),
591 &CommandKiller::never(),
592 )?;
593
594 Ok(())
595 }
596
597 pub fn login_with_retry(&self, registry: &Url) -> Result<(), DockerError> {
598 match retry::retry(retry::delay::Fibonacci::from_millis(1_000).take(10), || {

Callers 13

newMethod · 0.45
new_with_credentialsMethod · 0.45
newMethod · 0.45
newMethod · 0.45
mirror_imageFunction · 0.45
login_with_retryMethod · 0.45
test_get_docker_imageFunction · 0.45
test_delete_docker_imageFunction · 0.45
test_get_docker_imageFunction · 0.45
test_delete_docker_imageFunction · 0.45

Calls 2

docker_execFunction · 0.85
get_all_envsMethod · 0.45

Tested by 5

test_get_docker_imageFunction · 0.36
test_delete_docker_imageFunction · 0.36
test_get_docker_imageFunction · 0.36
test_delete_docker_imageFunction · 0.36
test_list_docker_imagesFunction · 0.36