Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate p.sbomViewFiles on deploy and mirror #2386

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/pkg/layout/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ func (s *SBOMs) Archive() (err error) {
}

// StageSBOMViewFiles copies SBOM viewer HTML files to the Zarf SBOM directory.
func (s *SBOMs) StageSBOMViewFiles() (warnings []string, err error) {
func (s *SBOMs) StageSBOMViewFiles() (sbomViewFiles, warnings []string, err error) {
if s.IsTarball() {
return nil, fmt.Errorf("unable to process the SBOM files for this package: %s is a tarball", s.Path)
return nil, nil, fmt.Errorf("unable to process the SBOM files for this package: %s is a tarball", s.Path)
}

// If SBOMs were loaded, temporarily place them in the deploy directory
if !helpers.InvalidPath(s.Path) {
if _, err := filepath.Glob(filepath.Join(s.Path, "sbom-viewer-*")); err != nil {
return nil, err
sbomViewFiles, err = filepath.Glob(filepath.Join(s.Path, "sbom-viewer-*"))
if err != nil {
return nil, nil, err
}

if _, err := s.OutputSBOMFiles(SBOMDir, ""); err != nil {
Expand All @@ -87,7 +88,7 @@ func (s *SBOMs) StageSBOMViewFiles() (warnings []string, err error) {
}
}

return warnings, nil
return sbomViewFiles, warnings, nil
}

// OutputSBOMFiles outputs SBOM files into outputDir.
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (p *Packager) Deploy() (err error) {
return err
}

sbomWarnings, err := p.layout.SBOMs.StageSBOMViewFiles()
var sbomWarnings []string
p.sbomViewFiles, sbomWarnings, err = p.layout.SBOMs.StageSBOMViewFiles()
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/packager/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func (p *Packager) Mirror() (err error) {
return err
}

sbomWarnings, err := p.layout.SBOMs.StageSBOMViewFiles()
var sbomWarnings []string
p.sbomViewFiles, sbomWarnings, err = p.layout.SBOMs.StageSBOMViewFiles()
if err != nil {
return err
}
Expand Down