Skip to content

Commit

Permalink
feat: print warnings before confirm with slogger (#3325)
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 authored Dec 12, 2024
1 parent 7af3336 commit ec814ca
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func New(cfg Config) (*slog.Logger, error) {
})
case FormatDev:
opts.AddSource = true
handler = devslog.NewHandler(DestinationDefault, &devslog.Options{
handler = devslog.NewHandler(cfg.Destination, &devslog.Options{
HandlerOptions: &opts,
NewLineAfterLog: true,
NoColor: !bool(cfg.Color),
Expand Down
3 changes: 0 additions & 3 deletions src/pkg/packager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/packager/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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.")
}
Expand All @@ -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)
}
}

Expand Down

0 comments on commit ec814ca

Please sign in to comment.