MCPcopy Create free account
hub / github.com/bootc-dev/bootc / prepare_for_pull

Function prepare_for_pull

crates/lib/src/deploy.rs:508–546  ·  view source on GitHub ↗
(
    repo: &ostree::Repo,
    imgref: &ImageReference,
    target_imgref: Option<&OstreeImageReference>,
    booted_deployment: Option<&ostree::Deployment>,
)

Source from the content-addressed store, hash-verified

506}
507
508pub(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///

Callers 2

install_containerFunction · 0.85
pullFunction · 0.85

Calls 12

new_importerFunction · 0.85
check_bootc_labelFunction · 0.85
print_deprecated_warningFunction · 0.85
print_layer_statusFunction · 0.85
set_targetMethod · 0.80
prepareMethod · 0.80
deprecated_warningMethod · 0.80
layers_to_fetchMethod · 0.80
all_layersMethod · 0.80
canonicalizeMethod · 0.45
intoMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected