mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: github.com/moby/buildkit 25bec7145b39 (v0.14.0-dev)
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
23
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
23
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
@ -101,7 +101,7 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
}
|
||||
|
||||
if tracerProvider != nil {
|
||||
var propagators = propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
|
||||
propagators := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
|
||||
unary = append(unary, filterInterceptor(otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(tracerProvider), otelgrpc.WithPropagators(propagators)))) //nolint:staticcheck // TODO(thaJeztah): ignore SA1019 for deprecated options: see https://github.com/moby/buildkit/issues/4681
|
||||
stream = append(stream, otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(tracerProvider), otelgrpc.WithPropagators(propagators))) //nolint:staticcheck // TODO(thaJeztah): ignore SA1019 for deprecated options: see https://github.com/moby/buildkit/issues/4681
|
||||
}
|
||||
@ -111,11 +111,17 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gopts = append(gopts, grpc.WithContextDialer(dialFn))
|
||||
if dialFn != nil {
|
||||
gopts = append(gopts, grpc.WithContextDialer(dialFn))
|
||||
}
|
||||
}
|
||||
if address == "" {
|
||||
address = appdefaults.Address
|
||||
}
|
||||
uri, err := url.Parse(address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Setting :authority pseudo header
|
||||
// - HTTP/2 (RFC7540) defines :authority pseudo header includes
|
||||
@ -130,12 +136,14 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
}
|
||||
if authority == "" {
|
||||
// authority as hostname from target address
|
||||
uri, err := url.Parse(address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
authority = uri.Host
|
||||
}
|
||||
if uri.Scheme == "tcp" {
|
||||
// remove tcp scheme from address, since default dialer doesn't expect that
|
||||
// name resolution is done by grpc according to the following spec: https://github.com/grpc/grpc/blob/master/doc/naming.md
|
||||
address = uri.Host
|
||||
}
|
||||
|
||||
gopts = append(gopts, grpc.WithAuthority(authority))
|
||||
|
||||
unary = append(unary, grpcerrors.UnaryClientInterceptor)
|
||||
@ -375,8 +383,7 @@ func resolveDialer(address string) (func(context.Context, string) (net.Conn, err
|
||||
if ch != nil {
|
||||
return ch.ContextDialer, nil
|
||||
}
|
||||
// basic dialer
|
||||
return dialer, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func filterInterceptor(intercept grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor {
|
||||
|
21
vendor/github.com/moby/buildkit/client/client_unix.go
generated
vendored
21
vendor/github.com/moby/buildkit/client/client_unix.go
generated
vendored
@ -1,21 +0,0 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func dialer(ctx context.Context, address string) (net.Conn, error) {
|
||||
addrParts := strings.SplitN(address, "://", 2)
|
||||
if len(addrParts) != 2 {
|
||||
return nil, errors.Errorf("invalid address %s", address)
|
||||
}
|
||||
var d net.Dialer
|
||||
return d.DialContext(ctx, addrParts[0], addrParts[1])
|
||||
}
|
25
vendor/github.com/moby/buildkit/client/client_windows.go
generated
vendored
25
vendor/github.com/moby/buildkit/client/client_windows.go
generated
vendored
@ -1,25 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
winio "github.com/Microsoft/go-winio"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func dialer(ctx context.Context, address string) (net.Conn, error) {
|
||||
addrParts := strings.SplitN(address, "://", 2)
|
||||
if len(addrParts) != 2 {
|
||||
return nil, errors.Errorf("invalid address %s", address)
|
||||
}
|
||||
switch addrParts[0] {
|
||||
case "npipe":
|
||||
address = strings.Replace(addrParts[1], "/", "\\", -1)
|
||||
return winio.DialPipeContext(ctx, address)
|
||||
default:
|
||||
var d net.Dialer
|
||||
return d.DialContext(ctx, addrParts[0], addrParts[1])
|
||||
}
|
||||
}
|
8
vendor/github.com/moby/buildkit/client/connhelper/npipe/npipe.go
generated
vendored
Normal file
8
vendor/github.com/moby/buildkit/client/connhelper/npipe/npipe.go
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
// Package npipe provides connhelper for npipe://<address>
|
||||
package npipe
|
||||
|
||||
import "github.com/moby/buildkit/client/connhelper"
|
||||
|
||||
func init() {
|
||||
connhelper.Register("npipe", Helper)
|
||||
}
|
14
vendor/github.com/moby/buildkit/client/connhelper/npipe/npipe_other.go
generated
vendored
Normal file
14
vendor/github.com/moby/buildkit/client/connhelper/npipe/npipe_other.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
//go:build !windows
|
||||
|
||||
package npipe
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
|
||||
"github.com/moby/buildkit/client/connhelper"
|
||||
)
|
||||
|
||||
func Helper(u *url.URL) (*connhelper.ConnectionHelper, error) {
|
||||
return nil, errors.New("npipe connections are only supported on windows")
|
||||
}
|
28
vendor/github.com/moby/buildkit/client/connhelper/npipe/npipe_windows.go
generated
vendored
Normal file
28
vendor/github.com/moby/buildkit/client/connhelper/npipe/npipe_windows.go
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
//go:build windows
|
||||
|
||||
package npipe
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
"github.com/moby/buildkit/client/connhelper"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Helper returns helper for connecting to a url via npipes.
|
||||
func Helper(u *url.URL) (*connhelper.ConnectionHelper, error) {
|
||||
addrParts := strings.SplitN(u.String(), "://", 2)
|
||||
if len(addrParts) != 2 {
|
||||
return nil, errors.Errorf("invalid address %s", u)
|
||||
}
|
||||
address := strings.Replace(addrParts[1], "/", "\\", -1)
|
||||
return &connhelper.ConnectionHelper{
|
||||
ContextDialer: func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
return winio.DialPipeContext(ctx, address)
|
||||
},
|
||||
}, nil
|
||||
}
|
18
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
18
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
@ -438,15 +438,23 @@ func (e *ExecOp) Output() Output {
|
||||
}
|
||||
|
||||
func (e *ExecOp) Inputs() (inputs []Output) {
|
||||
mm := map[Output]struct{}{}
|
||||
// make sure mounts are sorted
|
||||
// the same sort occurs in (*ExecOp).Marshal, and this
|
||||
// sort must be the same
|
||||
sort.Slice(e.mounts, func(i int, j int) bool {
|
||||
return e.mounts[i].target < e.mounts[j].target
|
||||
})
|
||||
|
||||
seen := map[Output]struct{}{}
|
||||
for _, m := range e.mounts {
|
||||
if m.source != nil {
|
||||
mm[m.source] = struct{}{}
|
||||
if _, ok := seen[m.source]; !ok {
|
||||
inputs = append(inputs, m.source)
|
||||
seen[m.source] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
for o := range mm {
|
||||
inputs = append(inputs, o)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
38
vendor/github.com/moby/buildkit/client/llb/fileop.go
generated
vendored
38
vendor/github.com/moby/buildkit/client/llb/fileop.go
generated
vendored
@ -96,24 +96,35 @@ func (fa *FileAction) Copy(input CopyInput, src, dest string, opt ...CopyOption)
|
||||
return a
|
||||
}
|
||||
|
||||
func (fa *FileAction) allOutputs(m map[Output]struct{}) {
|
||||
func (fa *FileAction) allOutputs(seen map[Output]struct{}, outputs []Output) []Output {
|
||||
if fa == nil {
|
||||
return
|
||||
return outputs
|
||||
}
|
||||
if fa.state != nil && fa.state.Output() != nil {
|
||||
m[fa.state.Output()] = struct{}{}
|
||||
|
||||
if fa.state != nil {
|
||||
out := fa.state.Output()
|
||||
if out != nil {
|
||||
if _, ok := seen[out]; !ok {
|
||||
outputs = append(outputs, out)
|
||||
seen[out] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if a, ok := fa.action.(*fileActionCopy); ok {
|
||||
if a.state != nil {
|
||||
if out := a.state.Output(); out != nil {
|
||||
m[out] = struct{}{}
|
||||
out := a.state.Output()
|
||||
if out != nil {
|
||||
if _, ok := seen[out]; !ok {
|
||||
outputs = append(outputs, out)
|
||||
seen[out] = struct{}{}
|
||||
}
|
||||
}
|
||||
} else if a.fas != nil {
|
||||
a.fas.allOutputs(m)
|
||||
outputs = a.fas.allOutputs(seen, outputs)
|
||||
}
|
||||
}
|
||||
fa.prev.allOutputs(m)
|
||||
return fa.prev.allOutputs(seen, outputs)
|
||||
}
|
||||
|
||||
func (fa *FileAction) bind(s State) *FileAction {
|
||||
@ -806,15 +817,8 @@ func (f *FileOp) Output() Output {
|
||||
return f.output
|
||||
}
|
||||
|
||||
func (f *FileOp) Inputs() (inputs []Output) {
|
||||
mm := map[Output]struct{}{}
|
||||
|
||||
f.action.allOutputs(mm)
|
||||
|
||||
for o := range mm {
|
||||
inputs = append(inputs, o)
|
||||
}
|
||||
return inputs
|
||||
func (f *FileOp) Inputs() []Output {
|
||||
return f.action.allOutputs(map[Output]struct{}{}, []Output{})
|
||||
}
|
||||
|
||||
func getIndex(input pb.InputIndex, len int, relative *int) pb.InputIndex {
|
||||
|
9
vendor/github.com/moby/buildkit/client/llb/source.go
generated
vendored
9
vendor/github.com/moby/buildkit/client/llb/source.go
generated
vendored
@ -227,6 +227,11 @@ type ImageInfo struct {
|
||||
RecordType string
|
||||
}
|
||||
|
||||
const (
|
||||
GitAuthHeaderKey = "GIT_AUTH_HEADER"
|
||||
GitAuthTokenKey = "GIT_AUTH_TOKEN"
|
||||
)
|
||||
|
||||
// Git returns a state that represents a git repository.
|
||||
// Example:
|
||||
//
|
||||
@ -267,8 +272,8 @@ func Git(url, ref string, opts ...GitOption) State {
|
||||
}
|
||||
|
||||
gi := &GitInfo{
|
||||
AuthHeaderSecret: "GIT_AUTH_HEADER",
|
||||
AuthTokenSecret: "GIT_AUTH_TOKEN",
|
||||
AuthHeaderSecret: GitAuthHeaderKey,
|
||||
AuthTokenSecret: GitAuthTokenKey,
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.SetGitOption(gi)
|
||||
|
17
vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
generated
vendored
17
vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
generated
vendored
@ -102,6 +102,7 @@ func (s StoreIndex) Put(tag string, desc ocispecs.Descriptor) error {
|
||||
}
|
||||
}
|
||||
|
||||
setOCIIndexDefaults(&idx)
|
||||
if err = insertDesc(&idx, desc, tag); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -145,6 +146,19 @@ func (s StoreIndex) GetSingle() (*ocispecs.Descriptor, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// setOCIIndexDefaults updates zero values in index to their default values.
|
||||
func setOCIIndexDefaults(index *ocispecs.Index) {
|
||||
if index == nil {
|
||||
return
|
||||
}
|
||||
if index.SchemaVersion == 0 {
|
||||
index.SchemaVersion = 2
|
||||
}
|
||||
if index.MediaType == "" {
|
||||
index.MediaType = ocispecs.MediaTypeImageIndex
|
||||
}
|
||||
}
|
||||
|
||||
// insertDesc puts desc to index with tag.
|
||||
// Existing manifests with the same tag will be removed from the index.
|
||||
func insertDesc(index *ocispecs.Index, desc ocispecs.Descriptor, tag string) error {
|
||||
@ -152,9 +166,6 @@ func insertDesc(index *ocispecs.Index, desc ocispecs.Descriptor, tag string) err
|
||||
return nil
|
||||
}
|
||||
|
||||
if index.SchemaVersion == 0 {
|
||||
index.SchemaVersion = 2
|
||||
}
|
||||
if tag != "" {
|
||||
if desc.Annotations == nil {
|
||||
desc.Annotations = make(map[string]string)
|
||||
|
Reference in New Issue
Block a user