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

refactor: remove sbom view files property from packager #2695

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
p.cfg.Pkg = pkg

if !p.confirmAction(config.ZarfCreateStage, warnings) {
if !p.confirmAction(config.ZarfCreateStage, warnings, nil) {

Check warning on line 44 in src/pkg/packager/create.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/create.go#L44

Added line #L44 was not covered by tests
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 @@
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) {

Check warning on line 92 in src/pkg/packager/deploy.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/deploy.go#L92

Added line #L92 was not covered by tests
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 @@
"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) {

Check warning on line 21 in src/pkg/packager/interactive.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/interactive.go#L21

Added line #L21 was not covered by tests
pterm.Println()
message.HeaderInfof("📦 PACKAGE DEFINITION")
utils.ColorPrintYAML(p.cfg.Pkg, p.getPackageYAMLHints(stage), true)
Expand All @@ -30,14 +30,14 @@
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 {

Check warning on line 33 in src/pkg/packager/interactive.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/interactive.go#L33

Added line #L33 was not covered by tests
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]))))

Check warning on line 35 in src/pkg/packager/interactive.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/interactive.go#L35

Added line #L35 was not covered by tests
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"

Check warning on line 40 in src/pkg/packager/interactive.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/interactive.go#L38-L40

Added lines #L38 - L40 were not covered by tests
}

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 @@
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) {

Check warning on line 39 in src/pkg/packager/mirror.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/mirror.go#L39

Added line #L39 was not covered by tests
return fmt.Errorf("mirror cancelled")
}

Expand Down
Loading