mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit and dockerd
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
63
vendor/github.com/moby/buildkit/util/progress/progressui/printer.go
generated
vendored
63
vendor/github.com/moby/buildkit/util/progress/progressui/printer.go
generated
vendored
@ -1,8 +1,12 @@
|
||||
package progressui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
@ -20,9 +24,10 @@ type lastStatus struct {
|
||||
}
|
||||
|
||||
type textMux struct {
|
||||
w io.Writer
|
||||
current digest.Digest
|
||||
last map[string]lastStatus
|
||||
w io.Writer
|
||||
current digest.Digest
|
||||
last map[string]lastStatus
|
||||
notFirst bool
|
||||
}
|
||||
|
||||
func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
|
||||
@ -43,10 +48,22 @@ func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
|
||||
}
|
||||
old.logsOffset = 0
|
||||
old.count = 0
|
||||
fmt.Fprintf(p.w, "#%d ...\n", v.index)
|
||||
fmt.Fprintf(p.w, "#%d ...\n", old.index)
|
||||
}
|
||||
|
||||
if p.notFirst {
|
||||
fmt.Fprintln(p.w, "")
|
||||
} else {
|
||||
p.notFirst = true
|
||||
}
|
||||
|
||||
if os.Getenv("PROGRESS_NO_TRUNC") == "1" {
|
||||
fmt.Fprintf(p.w, "#%d %s\n", v.index, v.Name)
|
||||
fmt.Fprintf(p.w, "#%d %s\n", v.index, v.Digest)
|
||||
} else {
|
||||
fmt.Fprintf(p.w, "#%d %s\n", v.index, limitString(v.Name, 72))
|
||||
}
|
||||
|
||||
fmt.Fprintf(p.w, "\n#%d %s\n", v.index, limitString(v.Name, 72))
|
||||
}
|
||||
|
||||
if len(v.events) != 0 {
|
||||
@ -127,18 +144,46 @@ func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
|
||||
}
|
||||
|
||||
p.current = dgst
|
||||
|
||||
if v.Completed != nil {
|
||||
p.current = ""
|
||||
v.count = 0
|
||||
fmt.Fprintf(p.w, "\n")
|
||||
|
||||
if v.Error != "" {
|
||||
if v.logsPartial {
|
||||
fmt.Fprintln(p.w, "")
|
||||
}
|
||||
if strings.HasSuffix(v.Error, context.Canceled.Error()) {
|
||||
fmt.Fprintf(p.w, "#%d CANCELED\n", v.index)
|
||||
} else {
|
||||
fmt.Fprintf(p.w, "#%d ERROR: %s\n", v.index, v.Error)
|
||||
}
|
||||
} else if v.Cached {
|
||||
fmt.Fprintf(p.w, "#%d CACHED\n", v.index)
|
||||
} else {
|
||||
tm := ""
|
||||
if v.Started != nil {
|
||||
tm = fmt.Sprintf(" %.1fs", v.Completed.Sub(*v.Started).Seconds())
|
||||
}
|
||||
fmt.Fprintf(p.w, "#%d DONE%s\n", v.index, tm)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete(t.updates, dgst)
|
||||
}
|
||||
|
||||
func (p *textMux) print(t *trace) {
|
||||
func sortCompleted(t *trace, m map[digest.Digest]struct{}) []digest.Digest {
|
||||
out := make([]digest.Digest, 0, len(m))
|
||||
for k := range m {
|
||||
out = append(out, k)
|
||||
}
|
||||
sort.Slice(out, func(i, j int) bool {
|
||||
return t.byDigest[out[i]].Completed.Before(*t.byDigest[out[j]].Completed)
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
func (p *textMux) print(t *trace) {
|
||||
completed := map[digest.Digest]struct{}{}
|
||||
rest := map[digest.Digest]struct{}{}
|
||||
|
||||
@ -161,7 +206,7 @@ func (p *textMux) print(t *trace) {
|
||||
p.printVtx(t, current)
|
||||
}
|
||||
|
||||
for dgst := range completed {
|
||||
for _, dgst := range sortCompleted(t, completed) {
|
||||
if dgst != current {
|
||||
p.printVtx(t, dgst)
|
||||
}
|
||||
|
Reference in New Issue
Block a user