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

feat: print warnings before confirm with slogger #3325

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
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
Next Next commit
warnings to slog
Signed-off-by: Austin Abro <[email protected]>
AustinAbro321 committed Dec 12, 2024
commit 034dde5e99084272196d08959d9f88b61a98133d
3 changes: 0 additions & 3 deletions src/pkg/packager/create.go
Original file line number Diff line number Diff line change
@@ -56,9 +56,6 @@ func (p *Packager) Create(ctx context.Context) error {
}
// Store on packager config
p.cfg.Pkg = pkg
for _, warning := range warnings {
l.Warn(warning)
}
l.Info("package loaded",
"kind", pkg.Kind,
"name", pkg.Metadata.Name,
6 changes: 0 additions & 6 deletions src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
@@ -94,18 +94,12 @@ func (p *Packager) Deploy(ctx context.Context) error {
return err
}
warnings = append(warnings, validateWarnings...)
for _, warning := range validateWarnings {
l.Warn(warning)
}

sbomViewFiles, sbomWarnings, err := p.layout.SBOMs.StageSBOMViewFiles()
if err != nil {
return err
}
warnings = append(warnings, sbomWarnings...)
for _, warning := range sbomWarnings {
l.Warn(warning)
}

// Confirm the overall package deployment
if !p.confirmAction(ctx, config.ZarfDeployStage, warnings, sbomViewFiles) {
4 changes: 3 additions & 1 deletion src/pkg/packager/interactive.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import (
func (p *Packager) confirmAction(ctx context.Context, stage string, warnings []string, sbomViewFiles []string) bool {
pterm.Println()
message.HeaderInfof("📦 PACKAGE DEFINITION")
l := logger.From(ctx)
err := utils.ColorPrintYAML(p.cfg.Pkg, p.getPackageYAMLHints(stage), true)
if err != nil {
message.WarnErr(err, "unable to print yaml")
@@ -52,7 +53,7 @@ func (p *Packager) confirmAction(ctx context.Context, stage string, warnings []s
message.Note(msg)
pterm.Println(viewNow)
pterm.Println(viewLater)
logger.From(ctx).Info("this package has SBOMs available for review in a temporary directory", "directory", filepath.Join(cwd, layout.SBOMDir))
l.Info("this package has SBOMs available for review in a temporary directory", "directory", filepath.Join(cwd, layout.SBOMDir))
} else {
message.Warn("This package does NOT contain an SBOM. If you require an SBOM, please contact the creator of this package to request a version that includes an SBOM.")
}
@@ -64,6 +65,7 @@ func (p *Packager) confirmAction(ctx context.Context, stage string, warnings []s
message.Title("Package Warnings", "the following warnings were flagged while reading the package")
for _, warning := range warnings {
message.Warn(warning)
l.Warn(warning)
}
}