Skip to content

Commit

Permalink
Merge pull request #152 from amphi/target-component-in-components
Browse files Browse the repository at this point in the history
transformer: add target component to list of components
  • Loading branch information
nikstur authored Dec 6, 2024
2 parents 0ea2909 + 41aab95 commit e9c1ef0
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions rust/transformer/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ pub fn transform(
runtime_input_path: &Path,
output: &Path,
) -> Result<()> {
let mut buildtime_input = BuildtimeInput::from_file(buildtime_input_path)?;
let target_derivation = buildtime_input.0.remove(target_path).with_context(|| {
format!("Buildtime input doesn't contain target derivation: {target_path}")
})?;
let buildtime_input = BuildtimeInput::from_file(buildtime_input_path)?;
let target_derivation = buildtime_input
.0
.get(target_path)
.map(ToOwned::to_owned)
.with_context(|| {
format!("Buildtime input doesn't contain target derivation: {target_path}")
})?;

let mut runtime_input = RuntimeInput::from_file(runtime_input_path)?;
runtime_input.0.remove(target_path);
let runtime_input = RuntimeInput::from_file(runtime_input_path)?;

// Augment the runtime input with information from the buildtime input. The buildtime input,
// however, is not a strict superset of the runtime input. This has to do with how we query the
Expand Down Expand Up @@ -68,13 +71,6 @@ pub fn transform(

// Augment the components with those retrieved from the `sbom` passthru attribute of the
// derivations.
//
// We have to explicitly handle the target derivation since we removed it from the components
// previously.
if let Some(sbom_path) = &target_derivation.vendored_sbom {
components.extend_from_directory(sbom_path)?;
}

for derivation in buildtime_input.0.values() {
if let Some(sbom_path) = &derivation.vendored_sbom {
components.extend_from_directory(sbom_path)?;
Expand Down

0 comments on commit e9c1ef0

Please sign in to comment.