Merge pull request #563 from ijc/progressui-custom-operation

progressui: allow caller to customise "Building" string
docker-18.09
Tõnis Tiigi 2018-08-09 10:49:29 -07:00 committed by GitHub
commit 785436a312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -228,7 +228,7 @@ func build(clicontext *cli.Context) error {
}
}
// not using shared context to not disrupt display but let is finish reporting errors
return progressui.DisplaySolveStatus(context.TODO(), c, os.Stdout, displayCh)
return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, displayCh)
})
return eg.Wait()

View File

@ -92,7 +92,7 @@ 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)
return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, ch)
})
eg.Go(func() error {
if err := loadDockerTar(pipeR); err != nil {

View File

@ -16,13 +16,17 @@ import (
"golang.org/x/time/rate"
)
func DisplaySolveStatus(ctx context.Context, 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) error {
modeConsole := c != nil
disp := &display{c: c}
disp := &display{c: c, phase: phase}
printer := &textMux{w: w}
if disp.phase == "" {
disp.phase = "Building"
}
t := newTrace(w)
var done bool
@ -323,6 +327,7 @@ func addTime(tm *time.Time, d time.Duration) *time.Time {
type display struct {
c console.Console
phase string
lineCount int
repeated bool
}
@ -359,7 +364,7 @@ func (disp *display) print(d displayInfo, all bool) {
fmt.Fprint(disp.c, aec.Hide)
defer fmt.Fprint(disp.c, aec.Show)
out := fmt.Sprintf("[+] Building %.1fs (%d/%d) %s", time.Since(d.startTime).Seconds(), d.countCompleted, d.countTotal, statusStr)
out := fmt.Sprintf("[+] %s %.1fs (%d/%d) %s", disp.phase, time.Since(d.startTime).Seconds(), d.countCompleted, d.countTotal, statusStr)
out = align(out, "", width)
fmt.Fprintln(disp.c, out)
lineCount := 0