Wrapper for pulling a container image, wiring up status output.
(
repo: &ostree::Repo,
imgref: &ImageReference,
target_imgref: Option<&OstreeImageReference>,
quiet: bool,
prog: ProgressWriter,
booted_deployment: Option<&ostree::Deployment>,
| 771 | |
| 772 | /// Wrapper for pulling a container image, wiring up status output. |
| 773 | pub(crate) async fn pull( |
| 774 | repo: &ostree::Repo, |
| 775 | imgref: &ImageReference, |
| 776 | target_imgref: Option<&OstreeImageReference>, |
| 777 | quiet: bool, |
| 778 | prog: ProgressWriter, |
| 779 | booted_deployment: Option<&ostree::Deployment>, |
| 780 | ) -> Result<Box<ImageState>> { |
| 781 | match prepare_for_pull(repo, imgref, target_imgref, booted_deployment).await? { |
| 782 | PreparedPullResult::AlreadyPresent(existing) => { |
| 783 | // Log that the image was already present (Debug level since it's not actionable) |
| 784 | const IMAGE_ALREADY_PRESENT_ID: &str = "5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9"; |
| 785 | tracing::debug!( |
| 786 | message_id = IMAGE_ALREADY_PRESENT_ID, |
| 787 | bootc.image.reference = &imgref.image, |
| 788 | bootc.image.transport = &imgref.transport, |
| 789 | bootc.status = "already_present", |
| 790 | "Image already present: {}", |
| 791 | imgref |
| 792 | ); |
| 793 | Ok(existing) |
| 794 | } |
| 795 | PreparedPullResult::Ready(prepared_image_meta) => { |
| 796 | // Check disk space before attempting to pull |
| 797 | check_disk_space_ostree(repo, &prepared_image_meta, imgref)?; |
| 798 | // Log that we're pulling a new image |
| 799 | const PULLING_NEW_IMAGE_ID: &str = "6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0"; |
| 800 | tracing::info!( |
| 801 | message_id = PULLING_NEW_IMAGE_ID, |
| 802 | bootc.image.reference = &imgref.image, |
| 803 | bootc.image.transport = &imgref.transport, |
| 804 | bootc.status = "pulling_new", |
| 805 | "Pulling new image: {}", |
| 806 | imgref |
| 807 | ); |
| 808 | Ok(pull_from_prepared(imgref, quiet, prog, *prepared_image_meta).await?) |
| 809 | } |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | pub(crate) async fn wipe_ostree(sysroot: Sysroot) -> Result<()> { |
| 814 | tokio::task::spawn_blocking(move || { |
no test coverage detected