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

Function switch

crates/lib/src/cli.rs:1494–1521  ·  view source on GitHub ↗
(opts: SwitchOpts)

Source from the content-addressed store, hash-verified

1492/// Implementation of the `bootc switch` CLI command.
1493#[context("Switching")]
1494async fn switch(opts: SwitchOpts) -> Result<()> {
1495 // If we're doing an in-place mutation, we shortcut most of the rest of the work here
1496 // TODO: what we really want here is Storage::detect_from_root() that also handles
1497 // composefs. But for now this just assumes ostree.
1498 if opts.mutate_in_place {
1499 let target = imgref_for_switch(&opts)?;
1500 let deployid = {
1501 // Clone to pass into helper thread
1502 let target = target.clone();
1503 let root = cap_std::fs::Dir::open_ambient_dir("/", cap_std::ambient_authority())?;
1504 tokio::task::spawn_blocking(move || {
1505 crate::deploy::switch_origin_inplace(&root, &target)
1506 })
1507 .await??
1508 };
1509 println!("Updated {deployid} to pull from {target}");
1510 return Ok(());
1511 }
1512 let storage = &get_storage().await?;
1513 match storage.kind()? {
1514 BootedStorageKind::Ostree(booted_ostree) => {
1515 switch_ostree(opts, storage, &booted_ostree).await
1516 }
1517 BootedStorageKind::Composefs(booted_cfs) => {
1518 switch_composefs(opts, storage, &booted_cfs).await
1519 }
1520 }
1521}
1522
1523/// Implementation of the `bootc rollback` CLI command for ostree backend.
1524#[context("Rollback (ostree)")]

Callers 1

run_from_optFunction · 0.85

Calls 6

imgref_for_switchFunction · 0.85
switch_origin_inplaceFunction · 0.85
get_storageFunction · 0.85
switch_ostreeFunction · 0.85
switch_composefsFunction · 0.85
kindMethod · 0.45

Tested by

no test coverage detected