mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to opentelemetry support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
2
vendor/github.com/moby/buildkit/util/progress/multireader.go
generated
vendored
2
vendor/github.com/moby/buildkit/util/progress/multireader.go
generated
vendored
@ -28,7 +28,7 @@ func (mr *MultiReader) Reader(ctx context.Context) Reader {
|
||||
defer mr.mu.Unlock()
|
||||
|
||||
pr, ctx, closeWriter := NewContext(ctx)
|
||||
pw, _, ctx := FromContext(ctx)
|
||||
pw, _, ctx := NewFromContext(ctx)
|
||||
|
||||
w := pw.(*progressWriter)
|
||||
mr.writers[w] = closeWriter
|
||||
|
41
vendor/github.com/moby/buildkit/util/progress/progress.go
generated
vendored
41
vendor/github.com/moby/buildkit/util/progress/progress.go
generated
vendored
@ -18,22 +18,37 @@ type contextKeyT string
|
||||
|
||||
var contextKey = contextKeyT("buildkit/util/progress")
|
||||
|
||||
// FromContext returns a progress writer from a context.
|
||||
func FromContext(ctx context.Context, opts ...WriterOption) (Writer, bool, context.Context) {
|
||||
// WriterFactory will generate a new progress Writer and return a new Context
|
||||
// with the new Writer stored. It is the callers responsibility to Close the
|
||||
// returned Writer to avoid resource leaks.
|
||||
type WriterFactory func(ctx context.Context) (Writer, bool, context.Context)
|
||||
|
||||
// FromContext returns a WriterFactory to generate new progress writers based
|
||||
// on a Writer previously stored in the Context.
|
||||
func FromContext(ctx context.Context, opts ...WriterOption) WriterFactory {
|
||||
v := ctx.Value(contextKey)
|
||||
pw, ok := v.(*progressWriter)
|
||||
if !ok {
|
||||
if pw, ok := v.(*MultiWriter); ok {
|
||||
return pw, true, ctx
|
||||
return func(ctx context.Context) (Writer, bool, context.Context) {
|
||||
pw, ok := v.(*progressWriter)
|
||||
if !ok {
|
||||
if pw, ok := v.(*MultiWriter); ok {
|
||||
return pw, true, ctx
|
||||
}
|
||||
return &noOpWriter{}, false, ctx
|
||||
}
|
||||
return &noOpWriter{}, false, ctx
|
||||
pw = newWriter(pw)
|
||||
for _, o := range opts {
|
||||
o(pw)
|
||||
}
|
||||
ctx = context.WithValue(ctx, contextKey, pw)
|
||||
return pw, true, ctx
|
||||
}
|
||||
pw = newWriter(pw)
|
||||
for _, o := range opts {
|
||||
o(pw)
|
||||
}
|
||||
ctx = context.WithValue(ctx, contextKey, pw)
|
||||
return pw, true, ctx
|
||||
}
|
||||
|
||||
// NewFromContext creates a new Writer based on a Writer previously stored
|
||||
// in the Context and returns a new Context with the new Writer stored. It is
|
||||
// the callers responsibility to Close the returned Writer to avoid resource leaks.
|
||||
func NewFromContext(ctx context.Context, opts ...WriterOption) (Writer, bool, context.Context) {
|
||||
return FromContext(ctx, opts...)(ctx)
|
||||
}
|
||||
|
||||
type WriterOption func(Writer)
|
||||
|
14
vendor/github.com/moby/buildkit/util/progress/progressui/display.go
generated
vendored
14
vendor/github.com/moby/buildkit/util/progress/progressui/display.go
generated
vendored
@ -2,6 +2,7 @@ package progressui
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"container/ring"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -12,11 +13,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/jaguilar/vt100"
|
||||
"github.com/moby/buildkit/client"
|
||||
"github.com/morikuni/aec"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/tonistiigi/units"
|
||||
"github.com/tonistiigi/vt100"
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
@ -130,6 +131,7 @@ type vertex struct {
|
||||
logs [][]byte
|
||||
logsPartial bool
|
||||
logsOffset int
|
||||
logsBuffer *ring.Ring // stores last logs to print them on error
|
||||
prev *client.Vertex
|
||||
events []string
|
||||
lastBlockTime *time.Time
|
||||
@ -295,10 +297,20 @@ func (t *trace) printErrorLogs(f io.Writer) {
|
||||
if v.Error != "" && !strings.HasSuffix(v.Error, context.Canceled.Error()) {
|
||||
fmt.Fprintln(f, "------")
|
||||
fmt.Fprintf(f, " > %s:\n", v.Name)
|
||||
// tty keeps original logs
|
||||
for _, l := range v.logs {
|
||||
f.Write(l)
|
||||
fmt.Fprintln(f)
|
||||
}
|
||||
// printer keeps last logs buffer
|
||||
if v.logsBuffer != nil {
|
||||
for i := 0; i < v.logsBuffer.Len(); i++ {
|
||||
if v.logsBuffer.Value != nil {
|
||||
fmt.Fprintln(f, string(v.logsBuffer.Value.([]byte)))
|
||||
}
|
||||
v.logsBuffer = v.logsBuffer.Next()
|
||||
}
|
||||
}
|
||||
fmt.Fprintln(f, "------")
|
||||
}
|
||||
}
|
||||
|
11
vendor/github.com/moby/buildkit/util/progress/progressui/printer.go
generated
vendored
11
vendor/github.com/moby/buildkit/util/progress/progressui/printer.go
generated
vendored
@ -1,6 +1,7 @@
|
||||
package progressui
|
||||
|
||||
import (
|
||||
"container/ring"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -18,6 +19,8 @@ const maxDelay = 10 * time.Second
|
||||
const minTimeDelta = 5 * time.Second
|
||||
const minProgressDelta = 0.05 // %
|
||||
|
||||
const logsBufferSize = 10
|
||||
|
||||
type lastStatus struct {
|
||||
Current int64
|
||||
Timestamp time.Time
|
||||
@ -61,7 +64,6 @@ func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
|
||||
fmt.Fprintf(p.w, "#%d %s\n", v.index, limitString(v.Name, 72))
|
||||
} else {
|
||||
fmt.Fprintf(p.w, "#%d %s\n", v.index, v.Name)
|
||||
fmt.Fprintf(p.w, "#%d %s\n", v.index, v.Digest)
|
||||
}
|
||||
|
||||
}
|
||||
@ -131,6 +133,13 @@ func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
|
||||
if i != len(v.logs)-1 || !v.logsPartial {
|
||||
fmt.Fprintln(p.w, "")
|
||||
}
|
||||
if v.logsBuffer == nil {
|
||||
v.logsBuffer = ring.New(logsBufferSize)
|
||||
}
|
||||
v.logsBuffer.Value = l
|
||||
if !v.logsPartial {
|
||||
v.logsBuffer = v.logsBuffer.Next()
|
||||
}
|
||||
}
|
||||
|
||||
if len(v.logs) > 0 {
|
||||
|
Reference in New Issue
Block a user