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
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
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
Loading