progessui: return warnings from printer

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
master
Tonis Tiigi 2021-11-30 21:20:00 -08:00
parent d100814aad
commit 0dd260bcf5
3 changed files with 15 additions and 6 deletions

View File

@ -107,7 +107,8 @@ func action(clicontext *cli.Context) error {
c = cn
}
// not using shared context to not disrupt display but let is finish reporting errors
return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, ch)
_, err = progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, ch)
return err
})
eg.Go(func() error {
if err := loadDockerTar(pipeR); err != nil {

View File

@ -21,7 +21,7 @@ import (
"golang.org/x/time/rate"
)
func DisplaySolveStatus(ctx context.Context, phase string, c console.Console, w io.Writer, ch chan *client.SolveStatus) error {
func DisplaySolveStatus(ctx context.Context, phase string, c console.Console, w io.Writer, ch chan *client.SolveStatus) ([]client.VertexWarning, error) {
modeConsole := c != nil
disp := &display{c: c, phase: phase}
@ -57,7 +57,7 @@ func DisplaySolveStatus(ctx context.Context, phase string, c console.Console, w
for {
select {
case <-ctx.Done():
return ctx.Err()
return nil, ctx.Err()
case <-ticker.C:
case ss, ok := <-ch:
if ok {
@ -72,7 +72,7 @@ func DisplaySolveStatus(ctx context.Context, phase string, c console.Console, w
if done {
disp.print(t.displayInfo(), width, height, true)
t.printErrorLogs(c)
return nil
return t.warnings(), nil
} else if displayLimiter.Allow() {
ticker.Stop()
ticker = time.NewTicker(tickerTimeout)
@ -83,7 +83,7 @@ func DisplaySolveStatus(ctx context.Context, phase string, c console.Console, w
printer.print(t)
if done {
t.printErrorLogs(w)
return nil
return t.warnings(), nil
}
ticker.Stop()
ticker = time.NewTicker(tickerTimeout)
@ -172,6 +172,14 @@ func newTrace(w io.Writer, modeConsole bool) *trace {
}
}
func (t *trace) warnings() []client.VertexWarning {
var out []client.VertexWarning
for _, v := range t.vertexes {
out = append(out, v.warnings...)
}
return out
}
func (t *trace) triggerVertexEvent(v *client.Vertex) {
if v.Started == nil {
return

View File

@ -87,7 +87,7 @@ func NewPrinter(ctx context.Context, out console.File, mode string) (Writer, err
go func() {
// not using shared context to not disrupt display but let is finish reporting errors
pw.err = progressui.DisplaySolveStatus(ctx, "", c, out, statusCh)
_, pw.err = progressui.DisplaySolveStatus(ctx, "", c, out, statusCh)
close(doneCh)
}()
return pw, nil