vendor: update buildkit to v0.14.0-rc2

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2024-06-06 16:17:17 -07:00
parent 82b6826cd7
commit aa0f90fdd6
59 changed files with 672 additions and 336 deletions

View File

@ -338,7 +338,7 @@ func Parse(rwc io.Reader) (*Result, error) {
warnings = append(warnings, Warning{
Short: "Empty continuation line found in: " + line,
Detail: [][]byte{[]byte("Empty continuation lines will become errors in a future release")},
URL: "https://github.com/moby/moby/pull/33719",
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuations/",
Location: &Range{Start: Position{Line: currentLine}, End: Position{Line: currentLine}},
})
}

View File

@ -169,10 +169,12 @@ func PrintLintViolations(dt []byte, w io.Writer) error {
})
for _, warning := range results.Warnings {
fmt.Fprintf(w, "\n- %s\n%s\n", warning.Detail, warning.Description)
fmt.Fprintf(w, "%s", warning.RuleName)
if warning.URL != "" {
fmt.Fprintf(w, "URL: %s\n", warning.URL)
fmt.Fprintf(w, " - %s", warning.URL)
}
fmt.Fprintf(w, "\n%s\n", warning.Description)
if warning.Location.SourceIndex < 0 {
continue
}
@ -185,6 +187,7 @@ func PrintLintViolations(dt []byte, w io.Writer) error {
if err != nil {
return err
}
fmt.Fprintln(w)
}
return nil
}

View File

@ -5,8 +5,8 @@ import (
api "github.com/containerd/containerd/api/services/content/v1"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/services/content/contentserver"
cerrdefs "github.com/containerd/errdefs"
"github.com/moby/buildkit/session"
digest "github.com/opencontainers/go-digest"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
@ -25,17 +25,17 @@ type attachableContentStore struct {
func (cs *attachableContentStore) choose(ctx context.Context) (content.Store, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, errors.Wrap(errdefs.ErrInvalidArgument, "request lacks metadata")
return nil, errors.Wrap(cerrdefs.ErrInvalidArgument, "request lacks metadata")
}
values := md[GRPCHeaderID]
if len(values) == 0 {
return nil, errors.Wrapf(errdefs.ErrInvalidArgument, "request lacks metadata %q", GRPCHeaderID)
return nil, errors.Wrapf(cerrdefs.ErrInvalidArgument, "request lacks metadata %q", GRPCHeaderID)
}
id := values[0]
store, ok := cs.stores[id]
if !ok {
return nil, errors.Wrapf(errdefs.ErrNotFound, "unknown store %s", id)
return nil, errors.Wrapf(cerrdefs.ErrNotFound, "unknown store %s", id)
}
return store, nil
}

View File

@ -9,7 +9,7 @@ import (
"time"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
cerrdefs "github.com/containerd/errdefs"
digest "github.com/opencontainers/go-digest"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
@ -43,7 +43,7 @@ func (b *buffer) Info(ctx context.Context, dgst digest.Digest) (content.Info, er
v, ok := b.infos[dgst]
b.mu.Unlock()
if !ok {
return content.Info{}, errdefs.ErrNotFound
return content.Info{}, cerrdefs.ErrNotFound
}
return v, nil
}
@ -54,7 +54,7 @@ func (b *buffer) Update(ctx context.Context, new content.Info, fieldpaths ...str
updated, ok := b.infos[new.Digest]
if !ok {
return content.Info{}, errdefs.ErrNotFound
return content.Info{}, cerrdefs.ErrNotFound
}
if len(fieldpaths) == 0 {
@ -96,7 +96,7 @@ func (b *buffer) Writer(ctx context.Context, opts ...content.WriterOpt) (content
}
b.mu.Lock()
if _, ok := b.refs[wOpts.Ref]; ok {
return nil, errors.Wrapf(errdefs.ErrUnavailable, "ref %s locked", wOpts.Ref)
return nil, errors.Wrapf(cerrdefs.ErrUnavailable, "ref %s locked", wOpts.Ref)
}
b.mu.Unlock()
return &bufferedWriter{
@ -128,7 +128,7 @@ func (b *buffer) getBytesReader(dgst digest.Digest) (*bytes.Reader, error) {
return bytes.NewReader(dt), nil
}
return nil, errors.Wrapf(errdefs.ErrNotFound, "content %v", dgst)
return nil, errors.Wrapf(cerrdefs.ErrNotFound, "content %v", dgst)
}
func (b *buffer) addValue(k digest.Digest, dt []byte) {

View File

@ -5,7 +5,7 @@ import (
"sync"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
cerrdefs "github.com/containerd/errdefs"
"github.com/moby/buildkit/session"
digest "github.com/opencontainers/go-digest"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
@ -60,7 +60,7 @@ func (mp *MultiProvider) ReaderAt(ctx context.Context, desc ocispecs.Descriptor)
}
mp.mu.RUnlock()
if mp.base == nil {
return nil, errors.Wrapf(errdefs.ErrNotFound, "content %v", desc.Digest)
return nil, errors.Wrapf(cerrdefs.ErrNotFound, "content %v", desc.Digest)
}
return mp.base.ReaderAt(ctx, desc)
}
@ -74,7 +74,7 @@ func (mp *MultiProvider) Info(ctx context.Context, dgst digest.Digest) (content.
}
mp.mu.RUnlock()
if mp.base == nil {
return content.Info{}, errors.Wrapf(errdefs.ErrNotFound, "content %v", dgst)
return content.Info{}, errors.Wrapf(cerrdefs.ErrNotFound, "content %v", dgst)
}
return mp.base.Info(ctx, dgst)
}

View File

@ -7,8 +7,8 @@ import (
"time"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/remotes"
cerrdefs "github.com/containerd/errdefs"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)
@ -41,7 +41,7 @@ func (i *pushingIngester) Writer(ctx context.Context, opts ...content.WriterOpt)
}
}
if wOpts.Ref == "" {
return nil, errors.Wrap(errdefs.ErrInvalidArgument, "ref must not be empty")
return nil, errors.Wrap(cerrdefs.ErrInvalidArgument, "ref must not be empty")
}
st := time.Now()
@ -50,7 +50,7 @@ func (i *pushingIngester) Writer(ctx context.Context, opts ...content.WriterOpt)
for {
if time.Since(st) > time.Hour {
i.mu.Unlock()
return nil, errors.Wrapf(errdefs.ErrUnavailable, "ref %v locked", wOpts.Desc.Digest)
return nil, errors.Wrapf(cerrdefs.ErrUnavailable, "ref %v locked", wOpts.Desc.Digest)
}
if _, ok := i.active[wOpts.Desc.Digest]; ok {
i.c.Wait()

View File

@ -6,9 +6,9 @@ import (
"sync"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
cerrdefs "github.com/containerd/errdefs"
"github.com/moby/buildkit/version"
"github.com/moby/locker"
digest "github.com/opencontainers/go-digest"
@ -70,7 +70,7 @@ func (w *ingester) Writer(ctx context.Context, opts ...content.WriterOpt) (conte
}
}
if wo.Ref == "" {
return nil, errors.Wrap(errdefs.ErrInvalidArgument, "ref must not be empty")
return nil, errors.Wrap(cerrdefs.ErrInvalidArgument, "ref must not be empty")
}
w.locker.Lock(wo.Ref)
var once sync.Once

View File

@ -4,7 +4,7 @@ import (
"net/url"
"strings"
"github.com/containerd/containerd/errdefs"
cerrdefs "github.com/containerd/errdefs"
"github.com/pkg/errors"
)
@ -58,7 +58,7 @@ func ParseGitRef(ref string) (*GitRef, error) {
)
if strings.HasPrefix(ref, "./") || strings.HasPrefix(ref, "../") {
return nil, errdefs.ErrInvalidArgument
return nil, cerrdefs.ErrInvalidArgument
} else if strings.HasPrefix(ref, "github.com/") {
res.IndistinguishableFromLocal = true // Deprecated
remote = fromURL(&url.URL{
@ -84,7 +84,7 @@ func ParseGitRef(ref string) (*GitRef, error) {
// An HTTP(S) URL is considered to be a valid git ref only when it has the ".git[...]" suffix.
case HTTPProtocol, HTTPSProtocol:
if !strings.HasSuffix(remote.Path, ".git") {
return nil, errdefs.ErrInvalidArgument
return nil, cerrdefs.ErrInvalidArgument
}
}
}

View File

@ -46,22 +46,23 @@ func Helper() {
func Traces(err error) []*Stack {
var st []*Stack
wrapped, ok := err.(interface {
Unwrap() error
})
if ok {
st = Traces(wrapped.Unwrap())
switch e := err.(type) {
case interface{ Unwrap() error }:
st = Traces(e.Unwrap())
case interface{ Unwrap() []error }:
for _, ue := range e.Unwrap() {
st = Traces(ue)
// Only take first stack
if len(st) > 0 {
break
}
}
}
if ste, ok := err.(interface {
StackTrace() errors.StackTrace
}); ok {
switch ste := err.(type) {
case interface{ StackTrace() errors.StackTrace }:
st = append(st, convertStack(ste.StackTrace()))
}
if ste, ok := err.(interface {
StackTrace() *Stack
}); ok {
case interface{ StackTrace() *Stack }:
st = append(st, ste.StackTrace())
}

View File

@ -6,7 +6,6 @@ import (
"net/http"
"net/http/httptrace"
"github.com/moby/buildkit/util/bklog"
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel/attribute"
@ -15,6 +14,11 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"github.com/pkg/errors"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/stack"
)
// StartSpan starts a new span as a child of the span in context.
@ -30,14 +34,30 @@ func StartSpan(ctx context.Context, operationName string, opts ...trace.SpanStar
return span, ctx
}
func hasStacktrace(err error) bool {
switch e := err.(type) {
case interface{ StackTrace() *stack.Stack }:
return true
case interface{ StackTrace() errors.StackTrace }:
return true
case interface{ Unwrap() error }:
return hasStacktrace(e.Unwrap())
case interface{ Unwrap() []error }:
for _, ue := range e.Unwrap() {
if hasStacktrace(ue) {
return true
}
}
}
return false
}
// FinishWithError finalizes the span and sets the error if one is passed
func FinishWithError(span trace.Span, err error) {
if err != nil {
span.RecordError(err)
if _, ok := err.(interface {
Cause() error
}); ok {
span.SetAttributes(attribute.String(string(semconv.ExceptionStacktraceKey), fmt.Sprintf("%+v", err)))
if hasStacktrace(err) {
span.SetAttributes(attribute.String(string(semconv.ExceptionStacktraceKey), fmt.Sprintf("%+v", stack.Formatter(err))))
}
span.SetStatus(codes.Error, err.Error())
}