feat: Add the ability to choose a tempdir for builds

This commit is contained in:
Gerald Pinder 2024-12-08 22:01:36 -05:00
parent 7bc67bf766
commit d9b812d59b
5 changed files with 49 additions and 18 deletions

View file

@ -44,4 +44,5 @@ pub struct RechunkOpts<'scope> {
/// The compression type to use when pushing.
#[builder(default)]
pub compression: CompressionType,
pub tempdir: Option<&'scope Path>,
}

View file

@ -308,7 +308,11 @@ pub trait RechunkDriver: RunDriver + BuildDriver + ContainerMountDriver {
Self::prune_image(mount, container, raw_image, opts)?;
Self::create_ostree_commit(mount, ostree_cache_id, container, raw_image, opts)?;
let temp_dir = tempfile::TempDir::new().into_diagnostic()?;
let temp_dir = if let Some(dir) = opts.tempdir {
tempfile::TempDir::new_in(dir).into_diagnostic()?
} else {
tempfile::TempDir::new().into_diagnostic()?
};
let temp_dir_str = &*temp_dir.path().to_string_lossy();
Self::rechunk_image(ostree_cache_id, temp_dir_str, current_dir, opts)?;