Skip to content

Commit

Permalink
fix: import a bom only if available from built layers
Browse files Browse the repository at this point in the history
It is possible that a build_only layer doesn't generate a BOM, so it
cannot be imported in a derived layer.

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
  • Loading branch information
rchincha committed Apr 4, 2024
1 parent fde026b commit de6a32e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/stacker/bom.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package stacker
import (
"fmt"
"io"
"io/fs"
"os"
"path"
"path/filepath"

"github.com/pkg/errors"
"stackerbuild.io/stacker/pkg/container"
"stackerbuild.io/stacker/pkg/log"
"stackerbuild.io/stacker/pkg/types"
Expand Down Expand Up @@ -109,6 +111,11 @@ func ImportArtifacts(sc types.StackerConfig, src types.ImageSource, name string)
// if a bom is available, add it here so it can be merged
srcpath := path.Join(sc.StackerDir, "artifacts", src.Tag, fmt.Sprintf("%s.json", src.Tag))

_, err := os.Lstat(srcpath)
if err != nil && errors.Is(err, fs.ErrNotExist) {
return nil
}

Check warning on line 117 in pkg/stacker/bom.go

View check run for this annotation

Codecov / codecov/patch

pkg/stacker/bom.go#L114-L117

Added lines #L114 - L117 were not covered by tests

dstfp, err := os.CreateTemp(path.Join(sc.StackerDir, "artifacts", name), fmt.Sprintf("%s-*.json", name))
if err != nil {
return err
Expand Down

0 comments on commit de6a32e

Please sign in to comment.