MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / docker_guest_tls_paths

Function docker_guest_tls_paths

crates/openshell-driver-docker/src/lib.rs:3436–3485  ·  view source on GitHub ↗
(
    docker_config: &DockerComputeConfig,
)

Source from the content-addressed store, hash-verified

3434}
3435
3436pub(crate) fn docker_guest_tls_paths(
3437 docker_config: &DockerComputeConfig,
3438) -> CoreResult<Option<DockerGuestTlsPaths>> {
3439 let tls_flags_provided = docker_config.guest_tls_ca.is_some()
3440 || docker_config.guest_tls_cert.is_some()
3441 || docker_config.guest_tls_key.is_some();
3442
3443 if !docker_config.grpc_endpoint.starts_with("https://") {
3444 if tls_flags_provided {
3445 return Err(Error::config(format!(
3446 "guest_tls_ca/guest_tls_cert/guest_tls_key were provided but grpc_endpoint is '{}'; TLS materials require an https:// endpoint",
3447 docker_config.grpc_endpoint,
3448 )));
3449 }
3450 return Ok(None);
3451 }
3452
3453 let provided = [
3454 docker_config.guest_tls_ca.as_ref(),
3455 docker_config.guest_tls_cert.as_ref(),
3456 docker_config.guest_tls_key.as_ref(),
3457 ];
3458 if provided.iter().all(Option::is_none) {
3459 return Err(Error::config(
3460 "docker compute driver requires guest_tls_ca, guest_tls_cert, and guest_tls_key when grpc_endpoint uses https://",
3461 ));
3462 }
3463
3464 let Some(ca) = docker_config.guest_tls_ca.clone() else {
3465 return Err(Error::config(
3466 "guest_tls_ca is required when Docker sandbox TLS materials are configured",
3467 ));
3468 };
3469 let Some(cert) = docker_config.guest_tls_cert.clone() else {
3470 return Err(Error::config(
3471 "guest_tls_cert is required when Docker sandbox TLS materials are configured",
3472 ));
3473 };
3474 let Some(key) = docker_config.guest_tls_key.clone() else {
3475 return Err(Error::config(
3476 "guest_tls_key is required when Docker sandbox TLS materials are configured",
3477 ));
3478 };
3479
3480 Ok(Some(DockerGuestTlsPaths {
3481 ca: canonicalize_existing_file(&ca, "docker TLS CA certificate")?,
3482 cert: canonicalize_existing_file(&cert, "docker TLS client certificate")?,
3483 key: canonicalize_existing_file(&key, "docker TLS client private key")?,
3484 }))
3485}
3486
3487fn is_not_found_error(err: &BollardError) -> bool {
3488 matches!(

Calls 2

configFunction · 0.85