mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: github.com/moby/buildkit v0.13.0-rc2
full diff: https://github.com/moby/buildkit/compare/8e3fe35738c2...v0.13.0-rc2 Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
4
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
4
vendor/github.com/moby/buildkit/client/client.go
generated
vendored
@ -102,8 +102,8 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
|
||||
|
||||
if tracerProvider != nil {
|
||||
var propagators = propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
|
||||
unary = append(unary, filterInterceptor(otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(tracerProvider), otelgrpc.WithPropagators(propagators))))
|
||||
stream = append(stream, otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(tracerProvider), otelgrpc.WithPropagators(propagators)))
|
||||
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
|
||||
}
|
||||
|
||||
if needDialer {
|
||||
|
12
vendor/github.com/moby/buildkit/client/llb/fileop.go
generated
vendored
12
vendor/github.com/moby/buildkit/client/llb/fileop.go
generated
vendored
@ -398,6 +398,18 @@ func WithAllowWildcard(b bool) RmOption {
|
||||
})
|
||||
}
|
||||
|
||||
type excludeOnCopyAction struct {
|
||||
patterns []string
|
||||
}
|
||||
|
||||
func (e *excludeOnCopyAction) SetCopyOption(i *CopyInfo) {
|
||||
i.ExcludePatterns = append(i.ExcludePatterns, e.patterns...)
|
||||
}
|
||||
|
||||
func WithExcludePatterns(patterns []string) CopyOption {
|
||||
return &excludeOnCopyAction{patterns}
|
||||
}
|
||||
|
||||
type fileActionRm struct {
|
||||
file string
|
||||
info RmInfo
|
||||
|
2
vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go
generated
vendored
2
vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go
generated
vendored
@ -13,6 +13,7 @@ const (
|
||||
ExporterImageConfigKey = "containerimage.config"
|
||||
ExporterImageConfigDigestKey = "containerimage.config.digest"
|
||||
ExporterImageDescriptorKey = "containerimage.descriptor"
|
||||
ExporterImageBaseConfigKey = "containerimage.base.config"
|
||||
ExporterPlatformsKey = "refs.platforms"
|
||||
)
|
||||
|
||||
@ -20,6 +21,7 @@ const (
|
||||
// a platform to become platform specific
|
||||
var KnownRefMetadataKeys = []string{
|
||||
ExporterImageConfigKey,
|
||||
ExporterImageBaseConfigKey,
|
||||
}
|
||||
|
||||
type Platforms struct {
|
||||
|
18
vendor/github.com/moby/buildkit/frontend/dockerui/build.go
generated
vendored
18
vendor/github.com/moby/buildkit/frontend/dockerui/build.go
generated
vendored
@ -14,7 +14,7 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
type BuildFunc func(ctx context.Context, platform *ocispecs.Platform, idx int) (client.Reference, *dockerspec.DockerOCIImage, error)
|
||||
type BuildFunc func(ctx context.Context, platform *ocispecs.Platform, idx int) (r client.Reference, img, baseImg *dockerspec.DockerOCIImage, err error)
|
||||
|
||||
func (bc *Client) Build(ctx context.Context, fn BuildFunc) (*ResultBuilder, error) {
|
||||
res := client.NewResult()
|
||||
@ -36,7 +36,7 @@ func (bc *Client) Build(ctx context.Context, fn BuildFunc) (*ResultBuilder, erro
|
||||
for i, tp := range targets {
|
||||
i, tp := i, tp
|
||||
eg.Go(func() error {
|
||||
ref, img, err := fn(ctx, tp, i)
|
||||
ref, img, baseImg, err := fn(ctx, tp, i)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -46,6 +46,14 @@ func (bc *Client) Build(ctx context.Context, fn BuildFunc) (*ResultBuilder, erro
|
||||
return errors.Wrapf(err, "failed to marshal image config")
|
||||
}
|
||||
|
||||
var baseConfig []byte
|
||||
if baseImg != nil {
|
||||
baseConfig, err = json.Marshal(baseImg)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to marshal source image config")
|
||||
}
|
||||
}
|
||||
|
||||
p := platforms.DefaultSpec()
|
||||
if tp != nil {
|
||||
p = *tp
|
||||
@ -67,9 +75,15 @@ func (bc *Client) Build(ctx context.Context, fn BuildFunc) (*ResultBuilder, erro
|
||||
if bc.MultiPlatformRequested {
|
||||
res.AddRef(k, ref)
|
||||
res.AddMeta(fmt.Sprintf("%s/%s", exptypes.ExporterImageConfigKey, k), config)
|
||||
if len(baseConfig) > 0 {
|
||||
res.AddMeta(fmt.Sprintf("%s/%s", exptypes.ExporterImageBaseConfigKey, k), baseConfig)
|
||||
}
|
||||
} else {
|
||||
res.SetRef(ref)
|
||||
res.AddMeta(exptypes.ExporterImageConfigKey, config)
|
||||
if len(baseConfig) > 0 {
|
||||
res.AddMeta(exptypes.ExporterImageBaseConfigKey, baseConfig)
|
||||
}
|
||||
}
|
||||
expPlatforms.Platforms[i] = exptypes.Platform{
|
||||
ID: k,
|
||||
|
4
vendor/github.com/moby/buildkit/session/grpc.go
generated
vendored
4
vendor/github.com/moby/buildkit/session/grpc.go
generated
vendored
@ -50,8 +50,8 @@ func grpcClientConn(ctx context.Context, conn net.Conn) (context.Context, *grpc.
|
||||
}
|
||||
|
||||
if span := trace.SpanFromContext(ctx); span.SpanContext().IsValid() {
|
||||
unary = append(unary, filterClient(otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(span.TracerProvider()), otelgrpc.WithPropagators(propagators))))
|
||||
stream = append(stream, otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(span.TracerProvider()), otelgrpc.WithPropagators(propagators)))
|
||||
unary = append(unary, filterClient(otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(span.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(span.TracerProvider()), otelgrpc.WithPropagators(propagators))) //nolint:staticcheck // TODO(thaJeztah): ignore SA1019 for deprecated options: see https://github.com/moby/buildkit/issues/4681
|
||||
}
|
||||
|
||||
unary = append(unary, grpcerrors.UnaryClientInterceptor)
|
||||
|
4
vendor/github.com/moby/buildkit/session/session.go
generated
vendored
4
vendor/github.com/moby/buildkit/session/session.go
generated
vendored
@ -59,8 +59,8 @@ func NewSession(ctx context.Context, name, sharedKey string) (*Session, error) {
|
||||
serverOpts := []grpc.ServerOption{}
|
||||
|
||||
if span := trace.SpanFromContext(ctx); span.SpanContext().IsValid() {
|
||||
unary = append(unary, filterServer(otelgrpc.UnaryServerInterceptor(otelgrpc.WithTracerProvider(span.TracerProvider()), otelgrpc.WithPropagators(propagators))))
|
||||
stream = append(stream, otelgrpc.StreamServerInterceptor(otelgrpc.WithTracerProvider(span.TracerProvider()), otelgrpc.WithPropagators(propagators)))
|
||||
unary = append(unary, filterServer(otelgrpc.UnaryServerInterceptor(otelgrpc.WithTracerProvider(span.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.StreamServerInterceptor(otelgrpc.WithTracerProvider(span.TracerProvider()), otelgrpc.WithPropagators(propagators))) //nolint:staticcheck // TODO(thaJeztah): ignore SA1019 for deprecated options: see https://github.com/moby/buildkit/issues/4681
|
||||
}
|
||||
|
||||
unary = append(unary, grpcerrors.UnaryServerInterceptor)
|
||||
|
3
vendor/github.com/moby/buildkit/util/tracing/detect/detect.go
generated
vendored
3
vendor/github.com/moby/buildkit/util/tracing/detect/detect.go
generated
vendored
@ -18,6 +18,7 @@ import (
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
)
|
||||
|
||||
type ExporterDetector func() (sdktrace.SpanExporter, sdkmetric.Exporter, error)
|
||||
@ -105,7 +106,7 @@ func getExporters() (sdktrace.SpanExporter, sdkmetric.Exporter, error) {
|
||||
}
|
||||
|
||||
func detect() error {
|
||||
tp = trace.NewNoopTracerProvider()
|
||||
tp = noop.NewTracerProvider()
|
||||
mp = sdkmetric.NewMeterProvider()
|
||||
|
||||
texp, mexp, err := getExporters()
|
||||
|
3
vendor/github.com/moby/buildkit/util/tracing/tracing.go
generated
vendored
3
vendor/github.com/moby/buildkit/util/tracing/tracing.go
generated
vendored
@ -14,13 +14,14 @@ import (
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
)
|
||||
|
||||
// StartSpan starts a new span as a child of the span in context.
|
||||
// If there is no span in context then this is a no-op.
|
||||
func StartSpan(ctx context.Context, operationName string, opts ...trace.SpanStartOption) (trace.Span, context.Context) {
|
||||
parent := trace.SpanFromContext(ctx)
|
||||
tracer := trace.NewNoopTracerProvider().Tracer("")
|
||||
tracer := noop.NewTracerProvider().Tracer("")
|
||||
if parent != nil && parent.SpanContext().IsValid() {
|
||||
tracer = parent.TracerProvider().Tracer("")
|
||||
}
|
||||
|
6
vendor/github.com/tonistiigi/fsutil/.gitignore
generated
vendored
6
vendor/github.com/tonistiigi/fsutil/.gitignore
generated
vendored
@ -1,9 +1,5 @@
|
||||
# if you want to ignore files created by your editor/tools, consider using a
|
||||
# global .gitignore or .git/info/exclude see https://help.github.com/articles/ignoring-files
|
||||
.*
|
||||
!.github
|
||||
!.gitignore
|
||||
!.travis.yml
|
||||
*.prof
|
||||
bin/
|
||||
# support running go modules in vendor mode for local development
|
||||
vendor/
|
||||
|
30
vendor/github.com/tonistiigi/fsutil/.golangci.yml
generated
vendored
Normal file
30
vendor/github.com/tonistiigi/fsutil/.golangci.yml
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
run:
|
||||
timeout: 10m
|
||||
skip-files:
|
||||
- ".*\\.pb\\.go$"
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- gofmt
|
||||
- govet
|
||||
- goimports
|
||||
- ineffassign
|
||||
- misspell
|
||||
- unused
|
||||
- staticcheck
|
||||
- typecheck
|
||||
disable-all: true
|
||||
|
||||
linters-settings:
|
||||
depguard:
|
||||
rules:
|
||||
main:
|
||||
deny:
|
||||
# The io/ioutil package has been deprecated.
|
||||
# https://go.dev/doc/go1.16#ioutil
|
||||
- pkg: "io/ioutil"
|
||||
desc: The io/ioutil package has been deprecated.
|
||||
|
||||
# show all
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
18
vendor/github.com/tonistiigi/fsutil/Dockerfile
generated
vendored
18
vendor/github.com/tonistiigi/fsutil/Dockerfile
generated
vendored
@ -1,7 +1,9 @@
|
||||
#syntax=docker/dockerfile:1
|
||||
ARG GO_VERSION=1.20
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.1.0 AS xx
|
||||
ARG GO_VERSION=1.21
|
||||
ARG XX_VERSION=1.4.0
|
||||
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base
|
||||
RUN apk add --no-cache git
|
||||
@ -18,13 +20,19 @@ FROM base AS test
|
||||
ARG TESTFLAGS
|
||||
RUN --mount=target=. --mount=target=/go/pkg/mod,type=cache \
|
||||
--mount=target=/root/.cache,type=cache \
|
||||
CGO_ENABLED=0 xx-go test -test.v ${TESTFLAGS} ./...
|
||||
CGO_ENABLED=0 xx-go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic ${TESTFLAGS} ./...
|
||||
|
||||
FROM base AS test-noroot
|
||||
RUN mkdir /go/pkg && chmod 0777 /go/pkg
|
||||
USER 1000:1000
|
||||
RUN --mount=target=. \
|
||||
--mount=target=/tmp/.cache,type=cache \
|
||||
CGO_ENABLED=0 GOCACHE=/tmp/gocache xx-go test -test.v ./...
|
||||
CGO_ENABLED=0 GOCACHE=/tmp/gocache xx-go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic ./...
|
||||
|
||||
FROM scratch AS test-coverage
|
||||
COPY --from=test /tmp/coverage.txt /coverage-root.txt
|
||||
|
||||
FROM scratch AS test-noroot-coverage
|
||||
COPY --from=test-noroot /tmp/coverage.txt /coverage-noroot.txt
|
||||
|
||||
FROM build
|
||||
|
12
vendor/github.com/tonistiigi/fsutil/codecov.yml
generated
vendored
Normal file
12
vendor/github.com/tonistiigi/fsutil/codecov.yml
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
comment: false
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project: # settings affecting project coverage
|
||||
default:
|
||||
target: auto # auto % coverage target
|
||||
threshold: 1% # allow for 1% reduction of coverage without failing
|
||||
patch: off
|
||||
|
||||
github_checks:
|
||||
annotations: false
|
7
vendor/github.com/tonistiigi/fsutil/diff_containerd.go
generated
vendored
7
vendor/github.com/tonistiigi/fsutil/diff_containerd.go
generated
vendored
@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/tonistiigi/fsutil/types"
|
||||
@ -110,7 +111,7 @@ func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b walkerFn, fil
|
||||
if filter != nil {
|
||||
filter(f2.path, &statCopy)
|
||||
}
|
||||
f2copy = ¤tPath{path: f2.path, stat: &statCopy}
|
||||
f2copy = ¤tPath{path: filepath.FromSlash(f2.path), stat: &statCopy}
|
||||
}
|
||||
k, p := pathChange(f1, f2copy)
|
||||
switch k {
|
||||
@ -127,7 +128,7 @@ func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b walkerFn, fil
|
||||
f1 = nil
|
||||
continue
|
||||
} else if rmdir == "" && f1.stat.IsDir() {
|
||||
rmdir = f1.path + string(os.PathSeparator)
|
||||
rmdir = f1.path + string(filepath.Separator)
|
||||
} else if rmdir != "" {
|
||||
rmdir = ""
|
||||
}
|
||||
@ -138,7 +139,7 @@ func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b walkerFn, fil
|
||||
return err
|
||||
}
|
||||
if f1.stat.IsDir() && !f2copy.stat.IsDir() {
|
||||
rmdir = f1.path + string(os.PathSeparator)
|
||||
rmdir = f1.path + string(filepath.Separator)
|
||||
} else if rmdir != "" {
|
||||
rmdir = ""
|
||||
}
|
||||
|
12
vendor/github.com/tonistiigi/fsutil/docker-bake.hcl
generated
vendored
12
vendor/github.com/tonistiigi/fsutil/docker-bake.hcl
generated
vendored
@ -1,5 +1,9 @@
|
||||
variable "GO_VERSION" {
|
||||
default = "1.20"
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "DESTDIR" {
|
||||
default = "./bin"
|
||||
}
|
||||
|
||||
group "default" {
|
||||
@ -18,12 +22,14 @@ group "test" {
|
||||
|
||||
target "test-root" {
|
||||
inherits = ["build"]
|
||||
target = "test"
|
||||
target = "test-coverage"
|
||||
output = ["${DESTDIR}/coverage"]
|
||||
}
|
||||
|
||||
target "test-noroot" {
|
||||
inherits = ["build"]
|
||||
target = "test-noroot"
|
||||
target = "test-noroot-coverage"
|
||||
output = ["${DESTDIR}/coverage"]
|
||||
}
|
||||
|
||||
target "lint" {
|
||||
|
22
vendor/github.com/tonistiigi/fsutil/filter.go
generated
vendored
22
vendor/github.com/tonistiigi/fsutil/filter.go
generated
vendored
@ -66,9 +66,9 @@ type filterFS struct {
|
||||
|
||||
// NewFilterFS creates a new FS that filters the given FS using the given
|
||||
// FilterOpt.
|
||||
|
||||
//
|
||||
// The returned FS will not contain any paths that do not match the provided
|
||||
// include and exclude patterns, or that are are exlcluded using the mapping
|
||||
// include and exclude patterns, or that are are excluded using the mapping
|
||||
// function.
|
||||
//
|
||||
// The FS is assumed to be a snapshot of the filesystem at the time of the
|
||||
@ -96,7 +96,7 @@ func NewFilterFS(fs FS, opt *FilterOpt) (FS, error) {
|
||||
}
|
||||
|
||||
patternChars := "*[]?^"
|
||||
if os.PathSeparator != '\\' {
|
||||
if filepath.Separator != '\\' {
|
||||
patternChars += `\`
|
||||
}
|
||||
|
||||
@ -176,6 +176,7 @@ func (fs *filterFS) Walk(ctx context.Context, target string, fn gofs.WalkDirFunc
|
||||
includeMatchInfo patternmatcher.MatchInfo
|
||||
excludeMatchInfo patternmatcher.MatchInfo
|
||||
calledFn bool
|
||||
skipFn bool
|
||||
}
|
||||
|
||||
// used only for include/exclude handling
|
||||
@ -333,6 +334,9 @@ func (fs *filterFS) Walk(ctx context.Context, target string, fn gofs.WalkDirFunc
|
||||
}
|
||||
}
|
||||
for i, parentDir := range parentDirs {
|
||||
if parentDir.skipFn {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
if parentDir.calledFn {
|
||||
continue
|
||||
}
|
||||
@ -352,15 +356,21 @@ func (fs *filterFS) Walk(ctx context.Context, target string, fn gofs.WalkDirFunc
|
||||
}
|
||||
if fs.mapFn != nil {
|
||||
result := fs.mapFn(parentStat.Path, parentStat)
|
||||
if result == MapResultSkipDir || result == MapResultExclude {
|
||||
if result == MapResultExclude {
|
||||
continue
|
||||
} else if result == MapResultSkipDir {
|
||||
parentDirs[i].skipFn = true
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
|
||||
if err := fn(parentStat.Path, &DirEntryInfo{Stat: parentStat}, nil); err != nil {
|
||||
parentDirs[i].calledFn = true
|
||||
if err := fn(parentStat.Path, &DirEntryInfo{Stat: parentStat}, nil); err == filepath.SkipDir {
|
||||
parentDirs[i].skipFn = true
|
||||
return filepath.SkipDir
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
parentDirs[i].calledFn = true
|
||||
}
|
||||
if err := fn(stat.Path, &DirEntryInfo{Stat: stat}, nil); err != nil {
|
||||
return err
|
||||
|
8
vendor/github.com/tonistiigi/fsutil/followlinks.go
generated
vendored
8
vendor/github.com/tonistiigi/fsutil/followlinks.go
generated
vendored
@ -137,8 +137,8 @@ func (r *symlinkResolver) readSymlink(p string, allowWildcard bool) ([]string, e
|
||||
func statFile(fs FS, root string) (os.DirEntry, error) {
|
||||
var out os.DirEntry
|
||||
|
||||
root = filepath.Clean(root)
|
||||
if root == "/" || root == "." {
|
||||
root = filepath.FromSlash(filepath.Clean(root))
|
||||
if root == string(filepath.Separator) || root == "." {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -168,8 +168,8 @@ func statFile(fs FS, root string) (os.DirEntry, error) {
|
||||
func readDir(fs FS, root string) ([]os.DirEntry, error) {
|
||||
var out []os.DirEntry
|
||||
|
||||
root = filepath.Clean(root)
|
||||
if root == "/" || root == "." {
|
||||
root = filepath.FromSlash(filepath.Clean(root))
|
||||
if root == string(filepath.Separator) || root == "." {
|
||||
root = "."
|
||||
out = make([]gofs.DirEntry, 0)
|
||||
}
|
||||
|
5
vendor/github.com/tonistiigi/fsutil/readme.md
generated
vendored
5
vendor/github.com/tonistiigi/fsutil/readme.md
generated
vendored
@ -1,3 +1,8 @@
|
||||
[](https://pkg.go.dev/github.com/tonistiigi/fsutil)
|
||||
[](https://github.com/tonistiigi/fsutil/actions?query=workflow%3Aci)
|
||||
[](https://goreportcard.com/report/github.com/tonistiigi/fsutil)
|
||||
[](https://codecov.io/gh/tonistiigi/fsutil)
|
||||
|
||||
Incremental file directory sync tools in golang.
|
||||
|
||||
```
|
||||
|
3
vendor/github.com/tonistiigi/fsutil/send.go
generated
vendored
3
vendor/github.com/tonistiigi/fsutil/send.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
@ -156,7 +157,7 @@ func (s *sender) walk(ctx context.Context) error {
|
||||
if !ok {
|
||||
return errors.WithStack(&os.PathError{Path: path, Err: syscall.EBADMSG, Op: "fileinfo without stat info"})
|
||||
}
|
||||
|
||||
stat.Path = filepath.ToSlash(stat.Path)
|
||||
p := &types.Packet{
|
||||
Type: types.PACKET_STAT,
|
||||
Stat: stat,
|
||||
|
2
vendor/github.com/tonistiigi/fsutil/stat.go
generated
vendored
2
vendor/github.com/tonistiigi/fsutil/stat.go
generated
vendored
@ -19,7 +19,7 @@ func mkstat(path, relpath string, fi os.FileInfo, inodemap map[uint64]string) (*
|
||||
relpath = filepath.ToSlash(relpath)
|
||||
|
||||
stat := &types.Stat{
|
||||
Path: relpath,
|
||||
Path: filepath.FromSlash(relpath),
|
||||
Mode: uint32(fi.Mode()),
|
||||
ModTime: fi.ModTime().UnixNano(),
|
||||
}
|
||||
|
22
vendor/github.com/tonistiigi/fsutil/validator.go
generated
vendored
22
vendor/github.com/tonistiigi/fsutil/validator.go
generated
vendored
@ -2,8 +2,7 @@ package fsutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
@ -28,21 +27,18 @@ func (v *Validator) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err
|
||||
if v.parentDirs == nil {
|
||||
v.parentDirs = make([]parent, 1, 10)
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
p = strings.Replace(p, "\\", "", -1)
|
||||
}
|
||||
if p != path.Clean(p) {
|
||||
if p != filepath.Clean(p) {
|
||||
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "unclean path"})
|
||||
}
|
||||
if path.IsAbs(p) {
|
||||
if filepath.IsAbs(p) {
|
||||
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "absolute path"})
|
||||
}
|
||||
dir := path.Dir(p)
|
||||
base := path.Base(p)
|
||||
dir := filepath.Dir(p)
|
||||
base := filepath.Base(p)
|
||||
if dir == "." {
|
||||
dir = ""
|
||||
}
|
||||
if dir == ".." || strings.HasPrefix(p, "../") {
|
||||
if dir == ".." || strings.HasPrefix(p, filepath.FromSlash("../")) {
|
||||
return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "escape check"})
|
||||
}
|
||||
|
||||
@ -56,12 +52,12 @@ func (v *Validator) HandleChange(kind ChangeKind, p string, fi os.FileInfo, err
|
||||
}
|
||||
|
||||
if dir != v.parentDirs[len(v.parentDirs)-1].dir || v.parentDirs[i].last >= base {
|
||||
return errors.Errorf("changes out of order: %q %q", p, path.Join(v.parentDirs[i].dir, v.parentDirs[i].last))
|
||||
return errors.Errorf("changes out of order: %q %q", p, filepath.Join(v.parentDirs[i].dir, v.parentDirs[i].last))
|
||||
}
|
||||
v.parentDirs[i].last = base
|
||||
if kind != ChangeKindDelete && fi.IsDir() {
|
||||
v.parentDirs = append(v.parentDirs, parent{
|
||||
dir: path.Join(dir, base),
|
||||
dir: filepath.Join(dir, base),
|
||||
last: "",
|
||||
})
|
||||
}
|
||||
@ -76,7 +72,7 @@ func ComparePath(p1, p2 string) int {
|
||||
switch {
|
||||
case p1[i] == p2[i]:
|
||||
continue
|
||||
case p2[i] != '/' && p1[i] < p2[i] || p1[i] == '/':
|
||||
case p2[i] != filepath.Separator && p1[i] < p2[i] || p1[i] == filepath.Separator:
|
||||
return -1
|
||||
default:
|
||||
return 1
|
||||
|
Reference in New Issue
Block a user