Skip to content

Commit

Permalink
Expose overwrite_layer_sboms in BuildContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax committed Feb 15, 2024
1 parent a7a3927 commit 8a8a5cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions libcnb/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ impl<B: Buildpack + ?Sized> BuildContext<B> {
)
.map_err(crate::Error::OverwriteLayerExecdError)
}

pub fn overwrite_layer_sboms(
&self,
layer_name: impl AsRef<LayerName>,
sboms: &[Sbom],
) -> crate::Result<(), B::Error> {
crate::layer::overwrite_layer_sboms(&self.layers_dir, layer_name.as_ref(), sboms)
.map_err(crate::Error::OverwriteLayerSbomsError)
}
}

/// Describes the result of the build phase.
Expand Down
3 changes: 3 additions & 0 deletions libcnb/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pub enum Error<E> {
#[error("Couldn't write exec.d programs to layer: {0}")]
OverwriteLayerExecdError(#[from] OverwriteLayerExecdError),

#[error("Couldn't write sboms to layer: {0}")]
OverwriteLayerSbomsError(#[from] std::io::Error),

#[error("Process type error: {0}")]
ProcessTypeError(#[from] ProcessTypeError),

Expand Down
4 changes: 2 additions & 2 deletions libcnb/src/layer/handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub(crate) fn delete_layer<P: AsRef<Path>>(
Ok(())
}

fn write_layer_sboms<P: AsRef<Path>>(
pub(crate) fn overwrite_layer_sboms<P: AsRef<Path>>(
layers_dir: P,
layer_name: &LayerName,
sboms: &[Sbom],
Expand Down Expand Up @@ -353,7 +353,7 @@ fn write_layer<M: Serialize, P: AsRef<Path>>(
write_toml_file(&layer_content_metadata, layer_content_metadata_path)?;

match layer_sboms {
Sboms::Overwrite(sboms) => write_layer_sboms(layers_dir.as_ref(), layer_name, &sboms)?,
Sboms::Overwrite(sboms) => overwrite_layer_sboms(layers_dir.as_ref(), layer_name, &sboms)?,
Sboms::Keep => {}
}

Expand Down

0 comments on commit 8a8a5cd

Please sign in to comment.