From c149bea746c3b4e0e74e94c400d515d2ff044531 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sat, 14 Dec 2024 16:25:06 -0500 Subject: [PATCH] feat: Allow fresh rechunking of image --- process/drivers/opts/rechunk.rs | 3 +++ process/drivers/traits.rs | 4 ++-- src/commands/build.rs | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/process/drivers/opts/rechunk.rs b/process/drivers/opts/rechunk.rs index e85d909e..fc90edb4 100644 --- a/process/drivers/opts/rechunk.rs +++ b/process/drivers/opts/rechunk.rs @@ -45,4 +45,7 @@ pub struct RechunkOpts<'scope> { #[builder(default)] pub compression: CompressionType, pub tempdir: Option<&'scope Path>, + + #[builder(default)] + pub fresh: bool, } diff --git a/process/drivers/traits.rs b/process/drivers/traits.rs index bdccafd9..57cb3b52 100644 --- a/process/drivers/traits.rs +++ b/process/drivers/traits.rs @@ -440,9 +440,9 @@ pub trait RechunkDriver: RunDriver + BuildDriver + ContainerMountDriver { }) .env_vars(crate::run_envs! { "REPO" => "/var/ostree/repo", - "PREV_REF" => &*opts.image, + "PREV_REF" => if opts.fresh { "" } else { &*opts.image }, "OUT_NAME" => ostree_cache_id, - // "PREV_REF_FAIL" => "true", + "PREV_REF_FAIL" => if opts.fresh { "" } else { "true" }, "VERSION" => format!("{}", opts.version), "OUT_REF" => format!("oci:{ostree_cache_id}"), "GIT_DIR" => "/var/git", diff --git a/src/commands/build.rs b/src/commands/build.rs index 36b4be24..810fea81 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -120,6 +120,13 @@ pub struct BuildCommand { #[cfg(feature = "rechunk")] rechunk: bool, + /// Performs frech rechunking without using previous + /// ostree chunks. + #[arg(long)] + #[builder(default)] + #[cfg(feature = "rechunk")] + fresh_rechunk: bool, + /// The location to temporarily store files /// while building. If unset, it will use `/tmp`. #[arg(long)] @@ -359,6 +366,7 @@ impl BuildCommand { .description(&*recipe.description) .base_image(format!("{}:{}", &recipe.base_image, &recipe.image_version)) .maybe_tempdir(self.tempdir.as_deref()) + .fresh(self.fresh_rechunk) .build(), )? } else {