vendor: update buildkit to v0.18.0-rc1

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2024-11-21 12:57:27 -08:00
parent 1a039115bc
commit 13a426fca6
448 changed files with 35377 additions and 5707 deletions

View File

@ -5,6 +5,7 @@ import (
_ "crypto/sha256" // for opencontainers/go-digest
"os"
"path"
"path/filepath"
"strconv"
"strings"
"time"
@ -563,7 +564,7 @@ func (a *fileActionCopy) toProtoAction(ctx context.Context, parent string, base
}
func (a *fileActionCopy) sourcePath(ctx context.Context) (string, error) {
p := path.Clean(a.src)
p := filepath.ToSlash(path.Clean(a.src))
dir := "/"
var err error
if !path.IsAbs(p) {

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package config

View File

@ -1,5 +1,4 @@
//go:build windows
// +build windows
package config

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package errdefs

View File

@ -1,5 +1,4 @@
//go:build !linux
// +build !linux
package errdefs

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package shell

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package filesync

View File

@ -1,5 +1,4 @@
//go:build windows
// +build windows
package filesync

View File

@ -206,7 +206,7 @@ func FSSync(ctx context.Context, c session.Caller, opt FSSendRequestOpt) error {
opts[keyDirName] = []string{opt.Name}
ctx, cancel := context.WithCancelCause(ctx)
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
client := NewFileSyncClient(c.Conn())

View File

@ -74,7 +74,7 @@ func (sm *Manager) Any(ctx context.Context, g Group, f func(context.Context, str
timeoutCtx, cancel := context.WithCancelCause(ctx)
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
c, err := sm.Get(timeoutCtx, id, false)
if err != nil {
lastErr = err

View File

@ -99,7 +99,7 @@ func (sm *Manager) HandleConn(ctx context.Context, conn net.Conn, opts map[strin
// caller needs to take lock, this function will release it
func (sm *Manager) handleConn(ctx context.Context, conn net.Conn, opts map[string][]string) error {
ctx, cancel := context.WithCancelCause(ctx)
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
opts = canonicalHeaders(opts)
@ -154,7 +154,7 @@ func (sm *Manager) Get(ctx context.Context, id string, noWait bool) (Caller, err
}
ctx, cancel := context.WithCancelCause(ctx)
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
go func() {
<-ctx.Done()

View File

@ -96,7 +96,7 @@ func (s *Session) Run(ctx context.Context, dialer Dialer) error {
s.cancelCtx = cancel
s.done = make(chan struct{})
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
defer close(s.done)
meta := make(map[string][]string)

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package sshprovider

View File

@ -1,5 +1,4 @@
//go:build windows
// +build windows
package sshprovider

View File

@ -2,58 +2,100 @@ package pb
import "encoding/json"
func (m *Op) UnmarshalJSON(data []byte) error {
var v struct {
Inputs []*Input `json:"inputs,omitempty"`
Op struct {
*Op_Exec
*Op_Source
*Op_File
*Op_Build
*Op_Merge
*Op_Diff
}
Platform *Platform `json:"platform,omitempty"`
Constraints *WorkerConstraints `json:"constraints,omitempty"`
type jsonOp struct {
Inputs []*Input `json:"inputs,omitempty"`
Op struct {
Exec *ExecOp `json:"exec,omitempty"`
Source *SourceOp `json:"source,omitempty"`
File *FileOp `json:"file,omitempty"`
Build *BuildOp `json:"build,omitempty"`
Merge *MergeOp `json:"merge,omitempty"`
Diff *DiffOp `json:"diff,omitempty"`
}
Platform *Platform `json:"platform,omitempty"`
Constraints *WorkerConstraints `json:"constraints,omitempty"`
}
func (m *Op) MarshalJSON() ([]byte, error) {
var v jsonOp
v.Inputs = m.Inputs
switch op := m.Op.(type) {
case *Op_Exec:
v.Op.Exec = op.Exec
case *Op_Source:
v.Op.Source = op.Source
case *Op_File:
v.Op.File = op.File
case *Op_Build:
v.Op.Build = op.Build
case *Op_Merge:
v.Op.Merge = op.Merge
case *Op_Diff:
v.Op.Diff = op.Diff
}
v.Platform = m.Platform
v.Constraints = m.Constraints
return json.Marshal(v)
}
func (m *Op) UnmarshalJSON(data []byte) error {
var v jsonOp
if err := json.Unmarshal(data, &v); err != nil {
return err
}
m.Inputs = v.Inputs
switch {
case v.Op.Op_Exec != nil:
m.Op = v.Op.Op_Exec
case v.Op.Op_Source != nil:
m.Op = v.Op.Op_Source
case v.Op.Op_File != nil:
m.Op = v.Op.Op_File
case v.Op.Op_Build != nil:
m.Op = v.Op.Op_Build
case v.Op.Op_Merge != nil:
m.Op = v.Op.Op_Merge
case v.Op.Op_Diff != nil:
m.Op = v.Op.Op_Diff
case v.Op.Exec != nil:
m.Op = &Op_Exec{v.Op.Exec}
case v.Op.Source != nil:
m.Op = &Op_Source{v.Op.Source}
case v.Op.File != nil:
m.Op = &Op_File{v.Op.File}
case v.Op.Build != nil:
m.Op = &Op_Build{v.Op.Build}
case v.Op.Merge != nil:
m.Op = &Op_Merge{v.Op.Merge}
case v.Op.Diff != nil:
m.Op = &Op_Diff{v.Op.Diff}
}
m.Platform = v.Platform
m.Constraints = v.Constraints
return nil
}
func (m *FileAction) UnmarshalJSON(data []byte) error {
var v struct {
Input InputIndex `json:"input"`
SecondaryInput InputIndex `json:"secondaryInput"`
Output OutputIndex `json:"output"`
Action struct {
*FileAction_Copy
*FileAction_Mkfile
*FileAction_Mkdir
*FileAction_Rm
}
type jsonFileAction struct {
Input InputIndex `json:"input"`
SecondaryInput InputIndex `json:"secondaryInput"`
Output OutputIndex `json:"output"`
Action struct {
Copy *FileActionCopy `json:"copy,omitempty"`
Mkfile *FileActionMkFile `json:"mkfile,omitempty"`
Mkdir *FileActionMkDir `json:"mkdir,omitempty"`
Rm *FileActionRm `json:"rm,omitempty"`
}
}
func (m *FileAction) MarshalJSON() ([]byte, error) {
var v jsonFileAction
v.Input = InputIndex(m.Input)
v.SecondaryInput = InputIndex(m.SecondaryInput)
v.Output = OutputIndex(m.Output)
switch action := m.Action.(type) {
case *FileAction_Copy:
v.Action.Copy = action.Copy
case *FileAction_Mkfile:
v.Action.Mkfile = action.Mkfile
case *FileAction_Mkdir:
v.Action.Mkdir = action.Mkdir
case *FileAction_Rm:
v.Action.Rm = action.Rm
}
return json.Marshal(v)
}
func (m *FileAction) UnmarshalJSON(data []byte) error {
var v jsonFileAction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
@ -62,35 +104,47 @@ func (m *FileAction) UnmarshalJSON(data []byte) error {
m.SecondaryInput = int64(v.SecondaryInput)
m.Output = int64(v.Output)
switch {
case v.Action.FileAction_Copy != nil:
m.Action = v.Action.FileAction_Copy
case v.Action.FileAction_Mkfile != nil:
m.Action = v.Action.FileAction_Mkfile
case v.Action.FileAction_Mkdir != nil:
m.Action = v.Action.FileAction_Mkdir
case v.Action.FileAction_Rm != nil:
m.Action = v.Action.FileAction_Rm
case v.Action.Copy != nil:
m.Action = &FileAction_Copy{v.Action.Copy}
case v.Action.Mkfile != nil:
m.Action = &FileAction_Mkfile{v.Action.Mkfile}
case v.Action.Mkdir != nil:
m.Action = &FileAction_Mkdir{v.Action.Mkdir}
case v.Action.Rm != nil:
m.Action = &FileAction_Rm{v.Action.Rm}
}
return nil
}
func (m *UserOpt) UnmarshalJSON(data []byte) error {
var v struct {
User struct {
*UserOpt_ByName
*UserOpt_ByID
}
type jsonUserOpt struct {
User struct {
ByName *NamedUserOpt `json:"byName,omitempty"`
ByID uint32 `json:"byId,omitempty"`
}
}
func (m *UserOpt) MarshalJSON() ([]byte, error) {
var v jsonUserOpt
switch userOpt := m.User.(type) {
case *UserOpt_ByName:
v.User.ByName = userOpt.ByName
case *UserOpt_ByID:
v.User.ByID = userOpt.ByID
}
return json.Marshal(v)
}
func (m *UserOpt) UnmarshalJSON(data []byte) error {
var v jsonUserOpt
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch {
case v.User.UserOpt_ByName != nil:
m.User = v.User.UserOpt_ByName
case v.User.UserOpt_ByID != nil:
m.User = v.User.UserOpt_ByID
case v.User.ByName != nil:
m.User = &UserOpt_ByName{v.User.ByName}
default:
m.User = &UserOpt_ByID{v.User.ByID}
}
return nil
}

View File

@ -1,5 +1,7 @@
package pb
import proto "google.golang.org/protobuf/proto"
func (m *Definition) IsNil() bool {
return m == nil || m.Metadata == nil
}
@ -13,7 +15,7 @@ func (m *Definition) Unmarshal(dAtA []byte) error {
}
func (m *Op) Marshal() ([]byte, error) {
return m.MarshalVT()
return proto.MarshalOptions{Deterministic: true}.Marshal(m)
}
func (m *Op) Unmarshal(dAtA []byte) error {

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package appcontext

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package appdefaults

View File

@ -1,5 +1,4 @@
//go:build openbsd
// +build openbsd
package disk

View File

@ -1,5 +1,4 @@
//go:build !windows && !openbsd
// +build !windows,!openbsd
package disk

View File

@ -1,5 +1,4 @@
//go:build windows
// +build windows
package disk

View File

@ -118,7 +118,7 @@ func newCall[T any](fn func(ctx context.Context) (T, error)) *call[T] {
func (c *call[T]) run() {
defer c.closeProgressWriter(errors.WithStack(context.Canceled))
ctx, cancel := context.WithCancelCause(c.ctx)
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
v, err := c.fn(ctx)
c.mu.Lock()
c.result = v
@ -157,7 +157,7 @@ func (c *call[T]) wait(ctx context.Context) (v T, err error) {
}
ctx, cancel := context.WithCancelCause(ctx)
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
c.ctxs = append(c.ctxs, ctx)

View File

@ -1,21 +0,0 @@
//go:build !windows
// +build !windows
package system
import (
iofs "io/fs"
"syscall"
"time"
"github.com/containerd/continuity/fs"
"github.com/pkg/errors"
)
func Atime(st iofs.FileInfo) (time.Time, error) {
stSys, ok := st.Sys().(*syscall.Stat_t)
if !ok {
return time.Time{}, errors.Errorf("expected st.Sys() to be *syscall.Stat_t, got %T", st.Sys())
}
return fs.StatATimeAsTime(stSys), nil
}

View File

@ -1,18 +0,0 @@
package system
import (
iofs "io/fs"
"syscall"
"time"
"github.com/pkg/errors"
)
func Atime(st iofs.FileInfo) (time.Time, error) {
stSys, ok := st.Sys().(*syscall.Win32FileAttributeData)
if !ok {
return time.Time{}, errors.Errorf("expected st.Sys() to be *syscall.Win32FileAttributeData, got %T", st.Sys())
}
// ref: https://github.com/golang/go/blob/go1.19.2/src/os/types_windows.go#L230
return time.Unix(0, stSys.LastAccessTime.Nanoseconds()), nil
}

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package integration

View File

@ -69,7 +69,7 @@ http:
ctx, cancel := context.WithCancelCause(context.Background())
ctx, _ = context.WithTimeoutCause(ctx, 5*time.Second, errors.WithStack(context.DeadlineExceeded))
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
url, err = detectPort(ctx, rc)
if err != nil {
return "", nil, err

View File

@ -198,7 +198,7 @@ func Run(t *testing.T, testCases []Test, opt ...TestOpt) {
defer sandboxLimiter.Release(1)
ctx, cancel := context.WithCancelCause(ctx)
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
sb, closer, err := newSandbox(ctx, br, getMirror(), mv)
require.NoError(t, err)
@ -427,7 +427,16 @@ func prepareValueMatrix(tc testConf) []matrixValue {
// Skips tests on platform
func SkipOnPlatform(t *testing.T, goos string) {
if runtime.GOOS == goos {
skip := false
// support for negation
if strings.HasPrefix(goos, "!") {
goos = strings.TrimPrefix(goos, "!")
skip = runtime.GOOS != goos
} else {
skip = runtime.GOOS == goos
}
if skip {
t.Skipf("Skipped on %s", goos)
}
}

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package integration

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package integration

View File

@ -135,11 +135,12 @@ func (c *Containerd) New(ctx context.Context, cfg *integration.BackendConfig) (b
deferF.Append(func() error { return os.RemoveAll(tmpdir) })
address := getContainerdSock(tmpdir)
config := fmt.Sprintf(`root = %q
config := fmt.Sprintf(`version = 2
root = %q
state = %q
# CRI plugins listens on 10010/tcp for stream server.
# We disable CRI plugin so that multiple instance can run simultaneously.
disabled_plugins = ["cri"]
disabled_plugins = ["io.containerd.grpc.v1.cri"]
[grpc]
address = %q

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package workers

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
package workers

View File

@ -1,3 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package detect
import (
@ -7,8 +10,9 @@ import (
"sync"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/sdk"
"go.opentelemetry.io/otel/sdk/resource"
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
)
var (
@ -23,7 +27,7 @@ func Resource() *resource.Resource {
res, err := resource.New(context.Background(),
resource.WithDetectors(serviceNameDetector{}),
resource.WithFromEnv(),
resource.WithTelemetrySDK(),
resource.WithDetectors(telemetrySDK{}),
)
if err != nil {
otel.Handle(err)
@ -42,7 +46,15 @@ func OverrideResource(res *resource.Resource) {
})
}
type serviceNameDetector struct{}
type (
telemetrySDK struct{}
serviceNameDetector struct{}
)
var (
_ resource.Detector = telemetrySDK{}
_ resource.Detector = serviceNameDetector{}
)
func (serviceNameDetector) Detect(ctx context.Context) (*resource.Resource, error) {
return resource.StringDetector(
@ -56,3 +68,13 @@ func (serviceNameDetector) Detect(ctx context.Context) (*resource.Resource, erro
},
).Detect(ctx)
}
// Detect returns a *Resource that describes the OpenTelemetry SDK used.
func (telemetrySDK) Detect(context.Context) (*resource.Resource, error) {
return resource.NewWithAttributes(
semconv.SchemaURL,
semconv.TelemetrySDKName("opentelemetry"),
semconv.TelemetrySDKLanguageGo,
semconv.TelemetrySDKVersion(sdk.Version()),
), nil
}

View File

@ -70,7 +70,7 @@ func (c *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc
}
ctx, cancel := c.connection.ContextWithStop(ctx)
defer cancel(errors.WithStack(context.Canceled))
defer func() { cancel(errors.WithStack(context.Canceled)) }()
ctx, tCancel := context.WithCancelCause(ctx)
ctx, _ = context.WithTimeoutCause(ctx, 30*time.Second, errors.WithStack(context.DeadlineExceeded))
defer tCancel(errors.WithStack(context.Canceled))

View File

@ -11,7 +11,7 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"