Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
omertuc committed Sep 5, 2024
1 parent f8d24c4 commit 9c14a8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 20 additions & 1 deletion lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use ostree_container::store::PrepareResult;
use ostree_ext::container as ostree_container;
use ostree_ext::keyfileext::KeyFileExt;
use ostree_ext::ostree;
use ostree_ext::ostree::Sysroot;
use schemars::schema_for;

use crate::deploy::RequiredHostSpec;
Expand Down Expand Up @@ -927,7 +928,25 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
Opt::Man(manopts) => crate::docgen::generate_manpages(&manopts.directory),
Opt::State(opts) => match opts {
StateOpts::WipeOstree => {
let sysroot = get_storage().await?;
// let sysroot = match get_storage().await {
// Ok(storage) => {
// let storage: &Sysroot = &storage;
// storage
// }
// Err(_) => {
// // If we can't get the storage, we're likely in a container
// // or some other non-bootc environment. Just wipe the ostree
// // system root.
// let sysroot = ostree::Sysroot::new_default();
// sysroot.set_mount_namespace_in_use();
// &sysroot
// }
// };
//
let sysroot = ostree::Sysroot::new_default();
sysroot.set_mount_namespace_in_use();

sysroot.load(gio::Cancellable::NONE)?;
crate::deploy::wipe_ostree(&sysroot).await
}
},
Expand Down
4 changes: 2 additions & 2 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use ostree_container::OstreeImageReference;
use ostree_ext::container as ostree_container;
use ostree_ext::container::store::{ImportProgress, PrepareResult};
use ostree_ext::oci_spec::image::Descriptor;
use ostree_ext::ostree;
use ostree_ext::ostree::Deployment;
use ostree_ext::ostree::{self, Sysroot};
use ostree_ext::sysroot::SysrootLock;

use crate::spec::ImageReference;
Expand Down Expand Up @@ -288,7 +288,7 @@ pub(crate) async fn prune_container_store(sysroot: &Storage) -> Result<()> {
Ok(())
}

pub(crate) async fn wipe_ostree(sysroot: &Storage) -> Result<()> {
pub(crate) async fn wipe_ostree(sysroot: &Sysroot) -> Result<()> {
sysroot
.write_deployments(&[], gio::Cancellable::NONE)
.context("removing deployments")?;
Expand Down

0 comments on commit 9c14a8a

Please sign in to comment.