(opts: SwitchOpts)
| 1492 | /// Implementation of the `bootc switch` CLI command. |
| 1493 | #[context("Switching")] |
| 1494 | async 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)")] |
no test coverage detected