Skip to content
Open
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
16 changes: 15 additions & 1 deletion commands/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba
progressMode := progressui.DisplayMode(cFlags.progress)

var printer *progress.Printer
printWarningsOnClose := true
defer func() {
if printer != nil {
printer.Wait()
Expand All @@ -198,7 +199,9 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba
progress.WithDesc(progressTextDesc, progressConsoleDesc),
progress.WithMetrics(mp, attributes),
progress.WithOnClose(func() {
printWarnings(os.Stderr, printer.Warnings(), progressMode)
if printWarningsOnClose {
printWarnings(os.Stderr, printer.Warnings(), progressMode)
}
}),
)
return err
Expand Down Expand Up @@ -334,6 +337,13 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba
}
}

for _, opt := range bo {
if opt.CallFunc != nil {
printWarningsOnClose = false
break
}
}

exp, err := ent.Validate(bo)
if err != nil {
return err
Expand Down Expand Up @@ -499,6 +509,10 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba
}
}

if !printWarningsOnClose {
printWarnings(os.Stderr, printer.Warnings(), progressMode)
}

if exitCode != 0 {
return cobrautil.ExitCodeError(exitCode)
}
Expand Down
8 changes: 6 additions & 2 deletions commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ func runBuild(ctx context.Context, dockerCli command.Cli, debugOpts debuggerOpti
),
progress.WithMetrics(mp, attributes),
progress.WithOnClose(func() {
printWarnings(os.Stderr, printer.Warnings(), progressMode)
if opts.CallFunc == nil {
printWarnings(os.Stderr, printer.Warnings(), progressMode)
}
}),
)
if err != nil {
Expand Down Expand Up @@ -450,7 +452,9 @@ func runBuild(ctx context.Context, dockerCli command.Cli, debugOpts debuggerOpti
}
}
if opts.CallFunc != nil {
if exitCode, err := printResult(dockerCli.Out(), opts.CallFunc, resp.ExporterResponse, options.target, inputs); err != nil {
exitCode, err := printResult(dockerCli.Out(), opts.CallFunc, resp.ExporterResponse, options.target, inputs)
printWarnings(os.Stderr, printer.Warnings(), progressMode)
if err != nil {
return err
} else if exitCode != 0 {
return cobrautil.ExitCodeError(exitCode)
Expand Down