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

Function container_import

crates/ostree-ext/src/cli.rs:686–730  ·  view source on GitHub ↗

Import a container image with an encapsulated ostree commit.

(
    repo: &ostree::Repo,
    imgref: &OstreeImageReference,
    proxyopts: ContainerProxyOpts,
    write_ref: Option<&str>,
    quiet: bool,
)

Source from the content-addressed store, hash-verified

684
685/// Import a container image with an encapsulated ostree commit.
686async fn container_import(
687 repo: &ostree::Repo,
688 imgref: &OstreeImageReference,
689 proxyopts: ContainerProxyOpts,
690 write_ref: Option<&str>,
691 quiet: bool,
692) -> Result<()> {
693 let target = indicatif::ProgressDrawTarget::stdout();
694 let style = indicatif::ProgressStyle::default_bar();
695 let pb = (!quiet).then(|| {
696 let pb = indicatif::ProgressBar::new_spinner();
697 pb.set_draw_target(target);
698 pb.set_style(style.template("{spinner} {prefix} {msg}").unwrap());
699 pb.enable_steady_tick(std::time::Duration::from_millis(200));
700 pb.set_message("Downloading...");
701 pb
702 });
703 let importer = ImageImporter::new(repo, imgref, proxyopts.into()).await?;
704 let import = importer.unencapsulate().await;
705 // Ensure we finish the progress bar before potentially propagating an error
706 if let Some(pb) = pb.as_ref() {
707 pb.finish();
708 }
709 let import = import?;
710 if let Some(warning) = import.deprecated_warning.as_deref() {
711 print_deprecated_warning(warning).await;
712 }
713 if let Some(write_ref) = write_ref {
714 repo.set_ref_immediate(
715 None,
716 write_ref,
717 Some(import.ostree_commit.as_str()),
718 gio::Cancellable::NONE,
719 )?;
720 println!(
721 "Imported: {} => {}",
722 write_ref,
723 import.ostree_commit.as_str()
724 );
725 } else {
726 println!("Imported: {}", import.ostree_commit);
727 }
728
729 Ok(())
730}
731
732/// Grouping of metadata about an object.
733#[derive(Debug, Default, Serialize, Deserialize)]

Callers 1

run_from_optFunction · 0.85

Calls 5

print_deprecated_warningFunction · 0.85
unencapsulateMethod · 0.80
finishMethod · 0.80
intoMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected