(
repo: &ostree::Repo,
imgref: &ImageReference,
target_imgref: Option<&OstreeImageReference>,
booted_deployment: Option<&ostree::Deployment>,
)
| 506 | } |
| 507 | |
| 508 | pub(crate) async fn prepare_for_pull( |
| 509 | repo: &ostree::Repo, |
| 510 | imgref: &ImageReference, |
| 511 | target_imgref: Option<&OstreeImageReference>, |
| 512 | booted_deployment: Option<&ostree::Deployment>, |
| 513 | ) -> Result<PreparedPullResult> { |
| 514 | let imgref_canonicalized = imgref.clone().canonicalize()?; |
| 515 | tracing::debug!("Canonicalized image reference: {imgref_canonicalized:#}"); |
| 516 | let ostree_imgref = &OstreeImageReference::from(imgref_canonicalized); |
| 517 | let mut imp = new_importer(repo, ostree_imgref, booted_deployment).await?; |
| 518 | if let Some(target) = target_imgref { |
| 519 | imp.set_target(target); |
| 520 | } |
| 521 | let prep = match imp.prepare().await? { |
| 522 | PrepareResult::AlreadyPresent(c) => { |
| 523 | println!("No changes in {imgref:#} => {}", c.manifest_digest); |
| 524 | return Ok(PreparedPullResult::AlreadyPresent(Box::new((*c).into()))); |
| 525 | } |
| 526 | PrepareResult::Ready(p) => p, |
| 527 | }; |
| 528 | check_bootc_label(&prep.config); |
| 529 | if let Some(warning) = prep.deprecated_warning() { |
| 530 | ostree_ext::cli::print_deprecated_warning(warning).await; |
| 531 | } |
| 532 | ostree_ext::cli::print_layer_status(&prep); |
| 533 | let layers_to_fetch = prep.layers_to_fetch().collect::<Result<Vec<_>>>()?; |
| 534 | |
| 535 | let prepared_image = PreparedImportMeta { |
| 536 | imp, |
| 537 | n_layers_to_fetch: layers_to_fetch.len(), |
| 538 | layers_total: prep.all_layers().count(), |
| 539 | bytes_to_fetch: layers_to_fetch.iter().map(|(l, _)| l.layer.size()).sum(), |
| 540 | bytes_total: prep.all_layers().map(|l| l.layer.size()).sum(), |
| 541 | digest: prep.manifest_digest.clone(), |
| 542 | prep, |
| 543 | }; |
| 544 | |
| 545 | Ok(PreparedPullResult::Ready(Box::new(prepared_image))) |
| 546 | } |
| 547 | |
| 548 | /// Check whether the image exists in bootc's unified container storage. |
| 549 | /// |
no test coverage detected