Skip to content

Commit

Permalink
refactor: remove sbom view files property from packager (#2695)
Browse files Browse the repository at this point in the history
  • Loading branch information
phillebaba authored Jul 3, 2024
1 parent 43e50bb commit 014d1d2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/pkg/packager/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ type Packager struct {
layout *layout.PackagePaths
hpaModified bool
connectStrings types.ConnectStrings
sbomViewFiles []string
source sources.PackageSource
generation int
}
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/packager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (p *Packager) Create(ctx context.Context) error {
}
p.cfg.Pkg = pkg

if !p.confirmAction(config.ZarfCreateStage, warnings) {
if !p.confirmAction(config.ZarfCreateStage, warnings, nil) {
return fmt.Errorf("package creation canceled")
}

Expand Down
3 changes: 1 addition & 2 deletions src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ func (p *Packager) Deploy(ctx context.Context) error {
if err != nil {
return err
}
p.sbomViewFiles = sbomViewFiles
warnings = append(warnings, sbomWarnings...)

// Confirm the overall package deployment
if !p.confirmAction(config.ZarfDeployStage, warnings) {
if !p.confirmAction(config.ZarfDeployStage, warnings, sbomViewFiles) {
return fmt.Errorf("deployment cancelled")
}

Expand Down
12 changes: 6 additions & 6 deletions src/pkg/packager/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pterm/pterm"
)

func (p *Packager) confirmAction(stage string, warnings []string) (confirm bool) {
func (p *Packager) confirmAction(stage string, warnings []string, sbomViewFiles []string) (confirm bool) {
pterm.Println()
message.HeaderInfof("📦 PACKAGE DEFINITION")
utils.ColorPrintYAML(p.cfg.Pkg, p.getPackageYAMLHints(stage), true)
Expand All @@ -30,14 +30,14 @@ func (p *Packager) confirmAction(stage string, warnings []string) (confirm bool)
message.HorizontalRule()
message.Title("Software Bill of Materials", "an inventory of all software contained in this package")

if len(p.sbomViewFiles) > 0 {
if len(sbomViewFiles) > 0 {
cwd, _ := os.Getwd()
link := pterm.FgLightCyan.Sprint(pterm.Bold.Sprint(filepath.Join(cwd, layout.SBOMDir, filepath.Base(p.sbomViewFiles[0]))))
link := pterm.FgLightCyan.Sprint(pterm.Bold.Sprint(filepath.Join(cwd, layout.SBOMDir, filepath.Base(sbomViewFiles[0]))))
inspect := pterm.BgBlack.Sprint(pterm.FgWhite.Sprint(pterm.Bold.Sprintf("$ zarf package inspect %s", p.cfg.PkgOpts.PackageSource)))

artifactMsg := pterm.Bold.Sprintf("%d artifacts", len(p.sbomViewFiles)) + " to be reviewed. These are"
if len(p.sbomViewFiles) == 1 {
artifactMsg = pterm.Bold.Sprintf("%d artifact", len(p.sbomViewFiles)) + " to be reviewed. This is"
artifactMsg := pterm.Bold.Sprintf("%d artifacts", len(sbomViewFiles)) + " to be reviewed. These are"
if len(sbomViewFiles) == 1 {
artifactMsg = pterm.Bold.Sprintf("%d artifact", len(sbomViewFiles)) + " to be reviewed. This is"
}

msg := fmt.Sprintf("This package has %s available in a temporary '%s' folder in this directory and will be removed upon deployment.\n", artifactMsg, pterm.Bold.Sprint("zarf-sbom"))
Expand Down
3 changes: 1 addition & 2 deletions src/pkg/packager/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ func (p *Packager) Mirror(ctx context.Context) error {
if err != nil {
return err
}
p.sbomViewFiles = sbomViewFiles
warnings = append(warnings, sbomWarnings...)

// Confirm the overall package mirror
if !p.confirmAction(config.ZarfMirrorStage, warnings) {
if !p.confirmAction(config.ZarfMirrorStage, warnings, sbomViewFiles) {
return fmt.Errorf("mirror cancelled")
}

Expand Down

0 comments on commit 014d1d2

Please sign in to comment.