Skip to content

Commit

Permalink
Fix restorer
Browse files Browse the repository at this point in the history
Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano committed Oct 5, 2021
1 parent 27c9567 commit b7322e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions buildpack/layertypes/types.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package layertypes

type LayerMetadataFile struct {
BOM BOM `json:"bom,omitempty" toml:"bom,omitempty"`
BOM *BOM `json:"bom,omitempty" toml:"bom,omitempty"`
Data interface{} `json:"data" toml:"metadata"`
Build bool `json:"build" toml:"build"`
Launch bool `json:"launch" toml:"launch"`
Cache bool `json:"cache" toml:"cache"`
}

type BOM struct {
SHA string `json:"sha" toml:"sha"`
SHA string `json:"sha,omitempty" toml:"sha,omitempty"`
}
8 changes: 7 additions & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package lifecycle
import (
"github.com/pkg/errors"

"github.com/buildpacks/lifecycle/buildpack/layertypes"
"github.com/buildpacks/lifecycle/platform"
)

Expand Down Expand Up @@ -42,7 +43,12 @@ func (e *Exporter) Cache(layersDir string, cacheStore Cache) error {
origLayerMetadata := origMeta.MetadataForBuildpack(bp.ID).Layers[layer.name()]
sbomLayer := bpDir.newSBOMLayerFor(layer.Identifier())
if sbomLayer != nil {
if lmd.BOM.SHA, err = e.addOrReuseSBOMLayer(cacheStore, *sbomLayer, origLayerMetadata.BOM.SHA); err != nil {
var origSHA string
if origLayerMetadata.BOM != nil {
origSHA = origLayerMetadata.BOM.SHA
}
lmd.BOM = &layertypes.BOM{}
if lmd.BOM.SHA, err = e.addOrReuseSBOMLayer(cacheStore, *sbomLayer, origSHA); err != nil {
e.Logger.Warnf("Failed to cache layer '%s': %s", sbomLayer.identifier, err) // TODO: check
continue
}
Expand Down

0 comments on commit b7322e2

Please sign in to comment.