mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to v0.8
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
26
vendor/github.com/moby/buildkit/util/stack/stack.go
generated
vendored
26
vendor/github.com/moby/buildkit/util/stack/stack.go
generated
vendored
@ -4,15 +4,22 @@ import (
|
||||
"fmt"
|
||||
io "io"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var helpers map[string]struct{}
|
||||
var helpersMu sync.RWMutex
|
||||
|
||||
func init() {
|
||||
typeurl.Register((*Stack)(nil), "github.com/moby/buildkit", "stack.Stack+json")
|
||||
|
||||
helpers = map[string]struct{}{}
|
||||
}
|
||||
|
||||
var version string
|
||||
@ -23,6 +30,19 @@ func SetVersionInfo(v, r string) {
|
||||
revision = r
|
||||
}
|
||||
|
||||
func Helper() {
|
||||
var pc [1]uintptr
|
||||
n := runtime.Callers(2, pc[:])
|
||||
if n == 0 {
|
||||
return
|
||||
}
|
||||
frames := runtime.CallersFrames(pc[:n])
|
||||
frame, _ := frames.Next()
|
||||
helpersMu.Lock()
|
||||
helpers[frame.Function] = struct{}{}
|
||||
helpersMu.Unlock()
|
||||
}
|
||||
|
||||
func Traces(err error) []*Stack {
|
||||
var st []*Stack
|
||||
|
||||
@ -52,6 +72,7 @@ func Enable(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
Helper()
|
||||
if !hasLocalStackTrace(err) {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
@ -112,6 +133,8 @@ func (w *formatter) Format(s fmt.State, verb rune) {
|
||||
|
||||
func convertStack(s errors.StackTrace) *Stack {
|
||||
var out Stack
|
||||
helpersMu.RLock()
|
||||
defer helpersMu.RUnlock()
|
||||
for _, f := range s {
|
||||
dt, err := f.MarshalText()
|
||||
if err != nil {
|
||||
@ -121,6 +144,9 @@ func convertStack(s errors.StackTrace) *Stack {
|
||||
if len(p) != 2 {
|
||||
continue
|
||||
}
|
||||
if _, ok := helpers[p[0]]; ok {
|
||||
continue
|
||||
}
|
||||
idx := strings.LastIndexByte(p[1], ':')
|
||||
if idx == -1 {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user