Fetch the image if it is not already present; return whether or not the image was fetched.
(&self, image: &str, mode: PullMode)
| 424 | /// Fetch the image if it is not already present; return whether |
| 425 | /// or not the image was fetched. |
| 426 | pub(crate) async fn pull(&self, image: &str, mode: PullMode) -> Result<bool> { |
| 427 | match mode { |
| 428 | PullMode::IfNotExists => { |
| 429 | if self.exists(image).await? { |
| 430 | tracing::debug!("Image is already present: {image}"); |
| 431 | return Ok(false); |
| 432 | } |
| 433 | } |
| 434 | PullMode::Always => {} |
| 435 | }; |
| 436 | let mut cmd = self.new_image_cmd()?; |
| 437 | cmd.stdin(Stdio::null()); |
| 438 | cmd.stdout(Stdio::null()); |
| 439 | cmd.args(["pull", image]); |
| 440 | tracing::debug!("Pulling image: {image}"); |
| 441 | let mut cmd = AsyncCommand::from(cmd); |
| 442 | cmd.run().await.context("Failed to pull image")?; |
| 443 | Ok(true) |
| 444 | } |
| 445 | |
| 446 | /// Copy an image from the default container storage (/var/lib/containers/) |
| 447 | /// to this storage. |
no test coverage detected