(&self, sandbox_id: &str, image: &str)
| 1346 | } |
| 1347 | |
| 1348 | async fn pull_image(&self, sandbox_id: &str, image: &str) -> Result<(), Status> { |
| 1349 | self.publish_docker_progress( |
| 1350 | sandbox_id, |
| 1351 | "Pulling", |
| 1352 | format!("Pulling Docker image \"{image}\""), |
| 1353 | HashMap::from([("image_ref".to_string(), image.to_string())]), |
| 1354 | ); |
| 1355 | let mut stream = self.docker.create_image( |
| 1356 | Some(CreateImageOptions { |
| 1357 | from_image: Some(image.to_string()), |
| 1358 | ..Default::default() |
| 1359 | }), |
| 1360 | None, |
| 1361 | None, |
| 1362 | ); |
| 1363 | while let Some(result) = stream.next().await { |
| 1364 | let info = result.map_err(|err| internal_status("pull Docker image", err))?; |
| 1365 | if let Some(message) = info |
| 1366 | .error_detail |
| 1367 | .as_ref() |
| 1368 | .and_then(|detail| detail.message.as_ref()) |
| 1369 | { |
| 1370 | return Err(Status::failed_precondition(format!( |
| 1371 | "pull Docker image '{image}' failed: {message}" |
| 1372 | ))); |
| 1373 | } |
| 1374 | if let Some(event) = docker_pull_progress_event(image, &info) { |
| 1375 | self.publish_platform_event(sandbox_id.to_string(), event); |
| 1376 | } |
| 1377 | } |
| 1378 | self.publish_docker_progress( |
| 1379 | sandbox_id, |
| 1380 | "Pulled", |
| 1381 | format!("Pulled Docker image \"{image}\""), |
| 1382 | HashMap::from([("image_ref".to_string(), image.to_string())]), |
| 1383 | ); |
| 1384 | Ok(()) |
| 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | #[tonic::async_trait] |
no test coverage detected