vendor: update buildkit to v0.17.0-rc2

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2024-10-28 14:56:43 -07:00
parent 202c390fca
commit 6fcc6853d9
195 changed files with 3522 additions and 5281 deletions

View File

@ -12,5 +12,11 @@ linters:
disable:
- errcheck
issues:
exclude-rules:
- linters:
- revive
text: "unused-parameter"
run:
timeout: 3m

View File

@ -57,7 +57,7 @@ test:
root-test:
@echo "+ $@"
@go test -exec sudo ${TEST_REQUIRES_ROOT_PACKAGES} -test.root
@go test -exec sudo ${TEST_REQUIRES_ROOT_PACKAGES} -test.root -test.v
test-compile:
@echo "+ $@"

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build freebsd || dragonfly
// +build freebsd dragonfly
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !(freebsd || windows)
// +build !freebsd,!windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build go1.13
// +build go1.13
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build darwin || freebsd || netbsd || openbsd || dragonfly || solaris
// +build darwin freebsd netbsd openbsd dragonfly solaris
/*
Copyright The containerd Authors.

View File

@ -22,7 +22,7 @@ import (
"os"
"path/filepath"
"github.com/sirupsen/logrus"
"github.com/containerd/log"
)
// XAttrErrorHandler transform a non-nil xattr error.
@ -161,7 +161,7 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
return fmt.Errorf("failed to create irregular file: %w", err)
}
default:
logrus.Warnf("unsupported mode: %s: %s", source, fileInfo.Mode())
log.L.Warnf("unsupported mode: %s: %s", source, fileInfo.Mode())
return nil
}

View File

@ -1,5 +1,4 @@
//go:build !windows && !freebsd
// +build !windows,!freebsd
/*
Copyright The containerd Authors.

View File

@ -17,6 +17,7 @@
package fs
import (
"errors"
"fmt"
"os"
"syscall"
@ -64,6 +65,9 @@ func copyFileInfo(fi os.FileInfo, src, name string) error {
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
xattrKeys, err := sysx.LListxattr(src)
if err != nil {
if errors.Is(err, unix.ENOTSUP) {
return nil
}
e := fmt.Errorf("failed to list xattrs on %s: %w", src, err)
if errorHandler != nil {
e = errorHandler(dst, src, "", e)

View File

@ -1,5 +1,4 @@
//go:build !darwin
// +build !darwin
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build darwin || freebsd || openbsd || netbsd || dragonfly || solaris
// +build darwin freebsd openbsd netbsd dragonfly solaris
/*
Copyright The containerd Authors.
@ -20,12 +19,14 @@
package fs
import (
"errors"
"fmt"
"os"
"runtime"
"syscall"
"github.com/containerd/continuity/sysx"
"golang.org/x/sys/unix"
)
func copyFileInfo(fi os.FileInfo, src, name string) error {
@ -67,6 +68,9 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt
// On darwin, character devices do not permit listing xattrs
return nil
}
if errors.Is(err, unix.ENOTSUP) {
return nil
}
e := fmt.Errorf("failed to list xattrs on %s: %w", src, err)
if errorHandler != nil {
e = errorHandler(dst, src, "", e)

View File

@ -18,11 +18,12 @@ package fs
import (
"context"
"errors"
"os"
"path/filepath"
"strings"
"github.com/sirupsen/logrus"
"github.com/containerd/log"
"golang.org/x/sync/errgroup"
)
@ -100,14 +101,11 @@ type ChangeFunc func(ChangeKind, string, os.FileInfo, error) error
// is to account for timestamp truncation during archiving.
func Changes(ctx context.Context, a, b string, changeFn ChangeFunc) error {
if a == "" {
logrus.Debugf("Using single walk diff for %s", b)
log.G(ctx).Debugf("Using single walk diff for %s", b)
return addDirChanges(ctx, changeFn, b)
} else if diffOptions := detectDirDiff(b, a); diffOptions != nil {
logrus.Debugf("Using single walk diff for %s from %s", diffOptions.diffDir, a)
return diffDirChanges(ctx, changeFn, a, diffOptions)
}
logrus.Debugf("Using double walk diff for %s from %s", b, a)
log.G(ctx).Debugf("Using double walk diff for %s from %s", b, a)
return doubleWalkDiff(ctx, changeFn, a, b)
}
@ -134,24 +132,53 @@ func addDirChanges(ctx context.Context, changeFn ChangeFunc, root string) error
})
}
// DiffChangeSource is the source of diff directory.
type DiffSource int
const (
// DiffSourceOverlayFS indicates that a diff directory is from
// OverlayFS.
DiffSourceOverlayFS DiffSource = iota
)
// diffDirOptions is used when the diff can be directly calculated from
// a diff directory to its base, without walking both trees.
type diffDirOptions struct {
diffDir string
skipChange func(string) (bool, error)
deleteChange func(string, string, os.FileInfo) (string, error)
skipChange func(string, os.FileInfo) (bool, error)
deleteChange func(string, string, os.FileInfo, ChangeFunc) (bool, error)
}
// diffDirChanges walks the diff directory and compares changes against the base.
func diffDirChanges(ctx context.Context, changeFn ChangeFunc, base string, o *diffDirOptions) error {
// DiffDirChanges walks the diff directory and compares changes against the base.
//
// NOTE: If all the children of a dir are removed, or that dir are recreated
// after remove, we will mark non-existing `.wh..opq` file as deleted. It's
// unlikely to create explicit whiteout files for all the children and all
// descendants. And based on OCI spec, it's not possible to create a file or
// dir with a name beginning with `.wh.`. So, after `.wh..opq` file has been
// deleted, the ChangeFunc, the receiver will add whiteout prefix to create a
// opaque whiteout `.wh..wh..opq`.
//
// REF: https://github.com/opencontainers/image-spec/blob/v1.0/layer.md#whiteouts
func DiffDirChanges(ctx context.Context, baseDir, diffDir string, source DiffSource, changeFn ChangeFunc) error {
var o *diffDirOptions
switch source {
case DiffSourceOverlayFS:
o = &diffDirOptions{
deleteChange: overlayFSWhiteoutConvert,
}
default:
return errors.New("unknown diff change source")
}
changedDirs := make(map[string]struct{})
return filepath.Walk(o.diffDir, func(path string, f os.FileInfo, err error) error {
return filepath.Walk(diffDir, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
// Rebase path
path, err = filepath.Rel(o.diffDir, path)
path, err = filepath.Rel(diffDir, path)
if err != nil {
return err
}
@ -163,38 +190,45 @@ func diffDirChanges(ctx context.Context, changeFn ChangeFunc, base string, o *di
return nil
}
// TODO: handle opaqueness, start new double walker at this
// location to get deletes, and skip tree in single walker
if o.skipChange != nil {
if skip, err := o.skipChange(path); skip {
if skip, err := o.skipChange(path, f); skip {
return err
}
}
var kind ChangeKind
deletedFile, err := o.deleteChange(o.diffDir, path, f)
if err != nil {
return err
deletedFile := false
if o.deleteChange != nil {
deletedFile, err = o.deleteChange(diffDir, path, f, changeFn)
if err != nil {
return err
}
_, err = os.Stat(filepath.Join(baseDir, path))
if err != nil {
if !os.IsNotExist(err) {
return err
}
deletedFile = false
}
}
// Find out what kind of modification happened
if deletedFile != "" {
path = deletedFile
if deletedFile {
kind = ChangeKindDelete
f = nil
} else {
// Otherwise, the file was added
kind = ChangeKindAdd
// ...Unless it already existed in a base, in which case, it's a modification
stat, err := os.Stat(filepath.Join(base, path))
// ...Unless it already existed in a baseDir, in which case, it's a modification
stat, err := os.Stat(filepath.Join(baseDir, path))
if err != nil && !os.IsNotExist(err) {
return err
}
if err == nil {
// The file existed in the base, so that's a modification
// The file existed in the baseDir, so that's a modification
// However, if it's a directory, maybe it wasn't actually modified.
// If you modify /foo/bar/baz, then /foo will be part of the changed files only because it's the parent of bar
@ -215,10 +249,12 @@ func diffDirChanges(ctx context.Context, changeFn ChangeFunc, base string, o *di
if f.IsDir() {
changedDirs[path] = struct{}{}
}
if kind == ChangeKindAdd || kind == ChangeKindDelete {
parent := filepath.Dir(path)
if _, ok := changedDirs[parent]; !ok && parent != "/" {
pi, err := os.Stat(filepath.Join(o.diffDir, parent))
pi, err := os.Stat(filepath.Join(diffDir, parent))
if err := changeFn(ChangeKindModify, parent, pi, err); err != nil {
return err
}
@ -226,6 +262,9 @@ func diffDirChanges(ctx context.Context, changeFn ChangeFunc, base string, o *di
}
}
if kind == ChangeKindDelete {
f = nil
}
return changeFn(kind, path, f, nil)
})
}

View File

@ -0,0 +1,101 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fs
import (
"errors"
"fmt"
"os"
"path/filepath"
"syscall"
"github.com/containerd/continuity/devices"
"github.com/containerd/continuity/sysx"
"golang.org/x/sys/unix"
)
const (
// whiteoutPrefix prefix means file is a whiteout. If this is followed
// by a filename this means that file has been removed from the base
// layer.
//
// See https://github.com/opencontainers/image-spec/blob/master/layer.md#whiteouts
whiteoutPrefix = ".wh."
)
// overlayFSWhiteoutConvert detects whiteouts and opaque directories.
//
// It returns deleted indicator if the file is a character device with 0/0
// device number. And call changeFn with ChangeKindDelete for opaque
// directories.
//
// Check: https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt
func overlayFSWhiteoutConvert(diffDir, path string, f os.FileInfo, changeFn ChangeFunc) (deleted bool, _ error) {
if f.Mode()&os.ModeCharDevice != 0 {
if _, ok := f.Sys().(*syscall.Stat_t); !ok {
return false, nil
}
maj, min, err := devices.DeviceInfo(f)
if err != nil {
return false, err
}
return (maj == 0 && min == 0), nil
}
if f.IsDir() {
originalPath := filepath.Join(diffDir, path)
opaque, err := getOpaqueValue(originalPath)
if err != nil {
if errors.Is(err, unix.ENODATA) {
return false, nil
}
return false, err
}
if len(opaque) == 1 && opaque[0] == 'y' {
opaqueDirPath := filepath.Join(path, whiteoutPrefix+".opq")
return false, changeFn(ChangeKindDelete, opaqueDirPath, nil, nil)
}
}
return false, nil
}
// getOpaqueValue returns opaque value for a given file.
func getOpaqueValue(filePath string) ([]byte, error) {
for _, xattr := range []string{
"trusted.overlay.opaque",
// TODO(fuweid):
//
// user.overlay.* is available since 5.11. We should check
// kernel version before read.
//
// REF: https://github.com/torvalds/linux/commit/2d2f2d7322ff43e0fe92bf8cccdc0b09449bf2e1
"user.overlay.opaque",
} {
opaque, err := sysx.LGetxattr(filePath, xattr)
if err != nil {
if errors.Is(err, unix.ENODATA) || errors.Is(err, unix.ENOTSUP) {
continue
}
return nil, fmt.Errorf("failed to retrieve %s attr: %w", xattr, err)
}
return opaque, nil
}
return nil, unix.ENODATA
}

View File

@ -0,0 +1,28 @@
//go:build !linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fs
import (
"errors"
"os"
)
func overlayFSWhiteoutConvert(string, string, os.FileInfo, ChangeFunc) (bool, error) {
return false, errors.New("unsupported")
}

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.
@ -28,16 +27,6 @@ import (
"github.com/containerd/continuity/sysx"
)
// detectDirDiff returns diff dir options if a directory could
// be found in the mount info for upper which is the direct
// diff with the provided lower directory
func detectDirDiff(upper, lower string) *diffDirOptions {
// TODO: get mount options for upper
// TODO: detect AUFS
// TODO: detect overlay
return nil
}
// compareSysStat returns whether the stats are equivalent,
// whether the files are considered the same file, and
// an error

View File

@ -22,10 +22,6 @@ import (
"golang.org/x/sys/windows"
)
func detectDirDiff(upper, lower string) *diffDirOptions {
return nil
}
func compareSysStat(s1, s2 interface{}) (bool, error) {
f1, ok := s1.(windows.Win32FileAttributeData)
if !ok {

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build windows
// +build windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.
@ -20,9 +19,11 @@
package fstest
import (
"os"
"path/filepath"
"time"
"github.com/containerd/continuity/devices"
"github.com/containerd/continuity/sysx"
"golang.org/x/sys/unix"
)
@ -46,6 +47,14 @@ func Lchtimes(name string, atime, mtime time.Time) Applier {
})
}
// CreateDeviceFile provides creates devices Applier.
func CreateDeviceFile(name string, mode os.FileMode, maj, min int) Applier {
return applyFn(func(root string) error {
fullPath := filepath.Join(root, name)
return devices.Mknod(fullPath, mode, maj, min)
})
}
func Base() Applier {
return applyFn(func(root string) error {
// do nothing, as the base is not special

View File

@ -18,9 +18,17 @@ package fstest
import (
"errors"
"os"
"time"
)
// SetXAttr sets the xatter for the file
func SetXAttr(name, key, value string) Applier {
return applyFn(func(root string) error {
return errors.New("Not implemented")
})
}
// Lchtimes changes access and mod time of file without following symlink
func Lchtimes(name string, atime, mtime time.Time) Applier {
return applyFn(func(root string) error {
@ -28,6 +36,13 @@ func Lchtimes(name string, atime, mtime time.Time) Applier {
})
}
// CreateDeviceFile provides creates devices Applier.
func CreateDeviceFile(name string, mode os.FileMode, maj, min int) Applier {
return applyFn(func(root string) error {
return errors.New("Not implemented")
})
}
// Base applies the files required to make a valid Windows container layer
// that the filter will mount. It is used for testing the snapshotter
func Base() Applier {

View File

@ -0,0 +1,44 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fstest
import (
"os/exec"
"testing"
"github.com/containerd/continuity/testutil"
"github.com/containerd/continuity/testutil/loopback"
)
func WithMkfs(t *testing.T, f func(), mkfs ...string) {
testutil.RequiresRoot(t)
mnt := t.TempDir()
loop, err := loopback.New(100 << 20) // 100 MB
if err != nil {
t.Fatal(err)
}
defer loop.Close()
if out, err := exec.Command(mkfs[0], append(mkfs[1:], loop.Device)...).CombinedOutput(); err != nil {
t.Fatalf("could not mkfs (%v) %s: %v (out: %q)", mkfs, loop.Device, err, string(out))
}
if out, err := exec.Command("mount", loop.Device, mnt).CombinedOutput(); err != nil {
t.Fatalf("could not mount %s: %v (out: %q)", loop.Device, err, string(out))
}
defer testutil.Unmount(t, mnt)
t.Setenv("TMPDIR", mnt)
f()
}

View File

@ -0,0 +1,25 @@
//go:build !linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fstest
import "testing"
func WithMkfs(t *testing.T, f func(), mkfs ...string) {
t.Fatal("WithMkfs requires Linux")
}

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.

View File

@ -0,0 +1,123 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Copyright 2013-2018 Docker, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Original source: https://github.com/moby/moby/blob/v26.0.0/daemon/graphdriver/driver_linux.go
package fs
import (
"path/filepath"
"syscall"
)
// Magic unsigned id of the filesystem in use.
type Magic uint32
const (
// MagicUnsupported is a predefined constant value other than a valid filesystem id.
MagicUnsupported = Magic(0x00000000)
)
const (
// MagicAufs filesystem id for Aufs
MagicAufs = Magic(0x61756673)
// MagicBtrfs filesystem id for Btrfs
MagicBtrfs = Magic(0x9123683E)
// MagicCramfs filesystem id for Cramfs
MagicCramfs = Magic(0x28cd3d45)
// MagicEcryptfs filesystem id for eCryptfs
MagicEcryptfs = Magic(0xf15f)
// MagicExtfs filesystem id for Extfs
MagicExtfs = Magic(0x0000EF53)
// MagicF2fs filesystem id for F2fs
MagicF2fs = Magic(0xF2F52010)
// MagicGPFS filesystem id for GPFS
MagicGPFS = Magic(0x47504653)
// MagicJffs2Fs filesystem if for Jffs2Fs
MagicJffs2Fs = Magic(0x000072b6)
// MagicJfs filesystem id for Jfs
MagicJfs = Magic(0x3153464a)
// MagicNfsFs filesystem id for NfsFs
MagicNfsFs = Magic(0x00006969)
// MagicRAMFs filesystem id for RamFs
MagicRAMFs = Magic(0x858458f6)
// MagicReiserFs filesystem id for ReiserFs
MagicReiserFs = Magic(0x52654973)
// MagicSmbFs filesystem id for SmbFs
MagicSmbFs = Magic(0x0000517B)
// MagicSquashFs filesystem id for SquashFs
MagicSquashFs = Magic(0x73717368)
// MagicTmpFs filesystem id for TmpFs
MagicTmpFs = Magic(0x01021994)
// MagicVxFS filesystem id for VxFs
MagicVxFS = Magic(0xa501fcf5)
// MagicXfs filesystem id for Xfs
MagicXfs = Magic(0x58465342)
// MagicZfs filesystem id for Zfs
MagicZfs = Magic(0x2fc12fc1)
// MagicOverlay filesystem id for overlay
MagicOverlay = Magic(0x794C7630)
)
var (
// FsNames maps filesystem id to name of the filesystem.
FsNames = map[Magic]string{
MagicAufs: "aufs",
MagicBtrfs: "btrfs",
MagicCramfs: "cramfs",
MagicExtfs: "extfs",
MagicF2fs: "f2fs",
MagicGPFS: "gpfs",
MagicJffs2Fs: "jffs2",
MagicJfs: "jfs",
MagicNfsFs: "nfs",
MagicOverlay: "overlayfs",
MagicRAMFs: "ramfs",
MagicReiserFs: "reiserfs",
MagicSmbFs: "smb",
MagicSquashFs: "squashfs",
MagicTmpFs: "tmpfs",
MagicUnsupported: "unsupported",
MagicVxFS: "vxfs",
MagicXfs: "xfs",
MagicZfs: "zfs",
}
)
// GetMagic returns the filesystem id given the path.
func GetMagic(rootpath string) (Magic, error) {
var buf syscall.Statfs_t
if err := syscall.Statfs(filepath.Dir(rootpath), &buf); err != nil {
return 0, err
}
return Magic(buf.Type), nil
}

View File

@ -1,5 +1,4 @@
//go:build darwin || freebsd || netbsd
// +build darwin freebsd netbsd
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build linux || openbsd || dragonfly || solaris
// +build linux openbsd dragonfly solaris
/*
Copyright The containerd Authors.
@ -20,10 +19,36 @@
package fs
import (
"fmt"
"io/fs"
"syscall"
"time"
)
func Atime(st fs.FileInfo) (time.Time, error) {
stSys, ok := st.Sys().(*syscall.Stat_t)
if !ok {
return time.Time{}, fmt.Errorf("expected st.Sys() to be *syscall.Stat_t, got %T", st.Sys())
}
return StatATimeAsTime(stSys), nil
}
func Ctime(st fs.FileInfo) (time.Time, error) {
stSys, ok := st.Sys().(*syscall.Stat_t)
if !ok {
return time.Time{}, fmt.Errorf("expected st.Sys() to be *syscall.Stat_t, got %T", st.Sys())
}
return time.Unix(stSys.Atim.Unix()), nil
}
func Mtime(st fs.FileInfo) (time.Time, error) {
stSys, ok := st.Sys().(*syscall.Stat_t)
if !ok {
return time.Time{}, fmt.Errorf("expected st.Sys() to be *syscall.Stat_t, got %T", st.Sys())
}
return time.Unix(stSys.Mtim.Unix()), nil
}
// StatAtime returns the Atim
func StatAtime(st *syscall.Stat_t) syscall.Timespec {
return st.Atim

View File

@ -0,0 +1,33 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fs
import (
"fmt"
"io/fs"
"syscall"
"time"
)
func Atime(st fs.FileInfo) (time.Time, error) {
stSys, ok := st.Sys().(*syscall.Win32FileAttributeData)
if !ok {
return time.Time{}, fmt.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 || linux)
// +build !windows,!linux
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !(linux || solaris || windows)
// +build !linux,!solaris,!windows
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build linux || darwin
// +build linux darwin
/*
Copyright The containerd Authors.

View File

@ -1,5 +1,4 @@
//go:build !linux && !darwin
// +build !linux,!darwin
/*
Copyright The containerd Authors.

View File

@ -0,0 +1,27 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testutil
import (
"flag"
)
var rootEnabled bool
func init() {
flag.BoolVar(&rootEnabled, "test.root", false, "enable tests that require root")
}

View File

@ -0,0 +1,57 @@
//go:build !windows
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testutil
import (
"os"
"testing"
"golang.org/x/sys/unix"
)
// Unmount unmounts a given mountPoint and sets t.Error if it fails
func Unmount(t *testing.T, mountPoint string) {
t.Log("unmount", mountPoint)
if err := unmountAll(mountPoint); err != nil {
t.Error("Could not umount", mountPoint, err)
}
}
// RequiresRoot skips tests that require root, unless the test.root flag has
// been set
func RequiresRoot(t testing.TB) {
if !rootEnabled {
t.Skip("skipping test that requires root")
return
}
if os.Getuid() != 0 {
t.Error("This test must be run as root.")
}
}
func unmountAll(mountpoint string) error {
for {
if err := unix.Unmount(mountpoint, unmountFlags); err != nil {
if err == unix.EINVAL {
return nil
}
return err
}
}
}

View File

@ -0,0 +1,32 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testutil
import "testing"
// RequiresRoot does nothing on Windows
func RequiresRoot(t testing.TB) {
}
// RequiresRootM is similar to RequiresRoot but intended to be called from *testing.M.
func RequiresRootM() {
}
// Unmount unmounts a given mountPoint and sets t.Error if it fails
// Does nothing on Windows
func Unmount(t *testing.T, mountPoint string) {
}

View File

@ -0,0 +1,118 @@
//go:build linux
// +build linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package loopback
import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
"strings"
"syscall"
"github.com/containerd/log"
)
// New creates a loopback device
func New(size int64) (*Loopback, error) {
// create temporary file for the disk image
file, err := os.CreateTemp("", "containerd-test-loopback")
if err != nil {
return nil, fmt.Errorf("could not create temporary file for loopback: %w", err)
}
if err := file.Truncate(size); err != nil {
file.Close()
os.Remove(file.Name())
return nil, fmt.Errorf("failed to resize temp file: %w", err)
}
file.Close()
// create device
losetup := exec.Command("losetup", "--find", "--show", file.Name())
var stdout, stderr bytes.Buffer
losetup.Stdout = &stdout
losetup.Stderr = &stderr
if err := losetup.Run(); err != nil {
os.Remove(file.Name())
return nil, fmt.Errorf("loopback setup failed (%v): stdout=%q, stderr=%q: %w", losetup.Args, stdout.String(), stderr.String(), err)
}
deviceName := strings.TrimSpace(stdout.String())
log.L.Debugf("Created loop device %s (using %s)", deviceName, file.Name())
cleanup := func() error {
// detach device
log.L.Debugf("Removing loop device %s", deviceName)
losetup := exec.Command("losetup", "--detach", deviceName)
if out, err := losetup.CombinedOutput(); err != nil {
return fmt.Errorf("Could not remove loop device %s (%v): %q: %w", deviceName, losetup.Args, string(out), err)
}
// remove file
log.L.Debugf("Removing temporary file %s", file.Name())
return os.Remove(file.Name())
}
l := Loopback{
File: file.Name(),
Device: deviceName,
close: cleanup,
}
return &l, nil
}
// Loopback device
type Loopback struct {
// File is the underlying sparse file
File string
// Device is /dev/loopX
Device string
close func() error
}
// SoftSize returns st_size
func (l *Loopback) SoftSize() (int64, error) {
st, err := os.Stat(l.File)
if err != nil {
return 0, err
}
return st.Size(), nil
}
// HardSize returns st_blocks * 512; see stat(2)
func (l *Loopback) HardSize() (int64, error) {
st, err := os.Stat(l.File)
if err != nil {
return 0, err
}
st2, ok := st.Sys().(*syscall.Stat_t)
if !ok {
return 0, errors.New("st.Sys() is not a *syscall.Stat_t")
}
// NOTE: st_blocks has nothing to do with st_blksize; see stat(2)
return st2.Blocks * 512, nil
}
// Close detaches the device and removes the underlying file
func (l *Loopback) Close() error {
return l.close()
}

View File

@ -0,0 +1,21 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testutil
import "golang.org/x/sys/unix"
const unmountFlags int = unix.MNT_DETACH

View File

@ -0,0 +1,21 @@
//go:build !linux && !windows
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testutil
const unmountFlags int = 0

View File

@ -0,0 +1,62 @@
package md2man
import (
"fmt"
"io"
"os"
"strings"
"github.com/russross/blackfriday/v2"
)
func fmtListFlags(flags blackfriday.ListType) string {
knownFlags := []struct {
name string
flag blackfriday.ListType
}{
{"ListTypeOrdered", blackfriday.ListTypeOrdered},
{"ListTypeDefinition", blackfriday.ListTypeDefinition},
{"ListTypeTerm", blackfriday.ListTypeTerm},
{"ListItemContainsBlock", blackfriday.ListItemContainsBlock},
{"ListItemBeginningOfList", blackfriday.ListItemBeginningOfList},
{"ListItemEndOfList", blackfriday.ListItemEndOfList},
}
var f []string
for _, kf := range knownFlags {
if flags&kf.flag != 0 {
f = append(f, kf.name)
flags &^= kf.flag
}
}
if flags != 0 {
f = append(f, fmt.Sprintf("Unknown(%#x)", flags))
}
return strings.Join(f, "|")
}
type debugDecorator struct {
blackfriday.Renderer
}
func depth(node *blackfriday.Node) int {
d := 0
for n := node.Parent; n != nil; n = n.Parent {
d++
}
return d
}
func (d *debugDecorator) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
fmt.Fprintf(os.Stderr, "%s%s %v %v\n",
strings.Repeat(" ", depth(node)),
map[bool]string{true: "+", false: "-"}[entering],
node,
fmtListFlags(node.ListFlags))
var b strings.Builder
status := d.Renderer.RenderNode(io.MultiWriter(&b, w), node, entering)
if b.Len() > 0 {
fmt.Fprintf(os.Stderr, ">> %q\n", b.String())
}
return status
}

View File

@ -1,16 +1,23 @@
package md2man
import (
"os"
"strconv"
"github.com/russross/blackfriday/v2"
)
// Render converts a markdown document into a roff formatted document.
func Render(doc []byte) []byte {
renderer := NewRoffRenderer()
var r blackfriday.Renderer = renderer
if v, _ := strconv.ParseBool(os.Getenv("MD2MAN_DEBUG")); v {
r = &debugDecorator{Renderer: r}
}
return blackfriday.Run(doc,
[]blackfriday.Option{
blackfriday.WithRenderer(renderer),
blackfriday.WithRenderer(r),
blackfriday.WithExtensions(renderer.GetExtensions()),
}...)
}

View File

@ -14,10 +14,8 @@ import (
// roffRenderer implements the blackfriday.Renderer interface for creating
// roff format (manpages) from markdown text
type roffRenderer struct {
extensions blackfriday.Extensions
listCounters []int
firstHeader bool
firstDD bool
listDepth int
}
@ -43,7 +41,7 @@ const (
quoteTag = "\n.PP\n.RS\n"
quoteCloseTag = "\n.RE\n"
listTag = "\n.RS\n"
listCloseTag = "\n.RE\n"
listCloseTag = ".RE\n"
dtTag = "\n.TP\n"
dd2Tag = "\n"
tableStart = "\n.TS\nallbox;\n"
@ -56,23 +54,18 @@ const (
// NewRoffRenderer creates a new blackfriday Renderer for generating roff documents
// from markdown
func NewRoffRenderer() *roffRenderer { // nolint: golint
var extensions blackfriday.Extensions
extensions |= blackfriday.NoIntraEmphasis
extensions |= blackfriday.Tables
extensions |= blackfriday.FencedCode
extensions |= blackfriday.SpaceHeadings
extensions |= blackfriday.Footnotes
extensions |= blackfriday.Titleblock
extensions |= blackfriday.DefinitionLists
return &roffRenderer{
extensions: extensions,
}
return &roffRenderer{}
}
// GetExtensions returns the list of extensions used by this renderer implementation
func (r *roffRenderer) GetExtensions() blackfriday.Extensions {
return r.extensions
func (*roffRenderer) GetExtensions() blackfriday.Extensions {
return blackfriday.NoIntraEmphasis |
blackfriday.Tables |
blackfriday.FencedCode |
blackfriday.SpaceHeadings |
blackfriday.Footnotes |
blackfriday.Titleblock |
blackfriday.DefinitionLists
}
// RenderHeader handles outputting the header at document start
@ -103,7 +96,23 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
switch node.Type {
case blackfriday.Text:
escapeSpecialChars(w, node.Literal)
// Special case: format the NAME section as required for proper whatis parsing.
// Refer to the lexgrog(1) and groff_man(7) manual pages for details.
if node.Parent != nil &&
node.Parent.Type == blackfriday.Paragraph &&
node.Parent.Prev != nil &&
node.Parent.Prev.Type == blackfriday.Heading &&
node.Parent.Prev.FirstChild != nil &&
bytes.EqualFold(node.Parent.Prev.FirstChild.Literal, []byte("NAME")) {
before, after, found := bytes.Cut(node.Literal, []byte(" - "))
escapeSpecialChars(w, before)
if found {
out(w, ` \- `)
escapeSpecialChars(w, after)
}
} else {
escapeSpecialChars(w, node.Literal)
}
case blackfriday.Softbreak:
out(w, crTag)
case blackfriday.Hardbreak:
@ -141,14 +150,25 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
case blackfriday.Document:
break
case blackfriday.Paragraph:
// roff .PP markers break lists
if r.listDepth > 0 {
return blackfriday.GoToNext
}
if entering {
out(w, paraTag)
if r.listDepth > 0 {
// roff .PP markers break lists
if node.Prev != nil { // continued paragraph
if node.Prev.Type == blackfriday.List && node.Prev.ListFlags&blackfriday.ListTypeDefinition == 0 {
out(w, ".IP\n")
} else {
out(w, crTag)
}
}
} else if node.Prev != nil && node.Prev.Type == blackfriday.Heading {
out(w, crTag)
} else {
out(w, paraTag)
}
} else {
out(w, crTag)
if node.Next == nil || node.Next.Type != blackfriday.List {
out(w, crTag)
}
}
case blackfriday.BlockQuote:
if entering {
@ -211,6 +231,10 @@ func (r *roffRenderer) handleHeading(w io.Writer, node *blackfriday.Node, enteri
func (r *roffRenderer) handleList(w io.Writer, node *blackfriday.Node, entering bool) {
openTag := listTag
closeTag := listCloseTag
if (entering && r.listDepth == 0) || (!entering && r.listDepth == 1) {
openTag = crTag
closeTag = ""
}
if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
// tags for definition lists handled within Item node
openTag = ""
@ -239,23 +263,25 @@ func (r *roffRenderer) handleItem(w io.Writer, node *blackfriday.Node, entering
} else if node.ListFlags&blackfriday.ListTypeTerm != 0 {
// DT (definition term): line just before DD (see below).
out(w, dtTag)
r.firstDD = true
} else if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
// DD (definition description): line that starts with ": ".
//
// We have to distinguish between the first DD and the
// subsequent ones, as there should be no vertical
// whitespace between the DT and the first DD.
if r.firstDD {
r.firstDD = false
} else {
out(w, dd2Tag)
if node.Prev != nil && node.Prev.ListFlags&(blackfriday.ListTypeTerm|blackfriday.ListTypeDefinition) == blackfriday.ListTypeDefinition {
if node.Prev.Type == blackfriday.Item &&
node.Prev.LastChild != nil &&
node.Prev.LastChild.Type == blackfriday.List &&
node.Prev.LastChild.ListFlags&blackfriday.ListTypeDefinition == 0 {
out(w, ".IP\n")
} else {
out(w, dd2Tag)
}
}
} else {
out(w, ".IP \\(bu 2\n")
}
} else {
out(w, "\n")
}
}

View File

@ -1,5 +1,5 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
version: 2
before:
hooks:
- ./gen.sh
@ -99,7 +99,7 @@ archives:
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
version_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:

View File

@ -16,6 +16,27 @@ This package provides various compression algorithms.
# changelog
* Sep 23rd, 2024 - [1.17.10](https://github.com/klauspost/compress/releases/tag/v1.17.10)
* gzhttp: Add TransportAlwaysDecompress option. https://github.com/klauspost/compress/pull/978
* gzhttp: Add supported decompress request body by @mirecl in https://github.com/klauspost/compress/pull/1002
* s2: Add EncodeBuffer buffer recycling callback https://github.com/klauspost/compress/pull/982
* zstd: Improve memory usage on small streaming encodes https://github.com/klauspost/compress/pull/1007
* flate: read data written with partial flush by @vajexal in https://github.com/klauspost/compress/pull/996
* Jun 12th, 2024 - [1.17.9](https://github.com/klauspost/compress/releases/tag/v1.17.9)
* s2: Reduce ReadFrom temporary allocations https://github.com/klauspost/compress/pull/949
* flate, zstd: Shave some bytes off amd64 matchLen by @greatroar in https://github.com/klauspost/compress/pull/963
* Upgrade zip/zlib to 1.22.4 upstream https://github.com/klauspost/compress/pull/970 https://github.com/klauspost/compress/pull/971
* zstd: BuildDict fails with RLE table https://github.com/klauspost/compress/pull/951
* Apr 9th, 2024 - [1.17.8](https://github.com/klauspost/compress/releases/tag/v1.17.8)
* zstd: Reject blocks where reserved values are not 0 https://github.com/klauspost/compress/pull/885
* zstd: Add RLE detection+encoding https://github.com/klauspost/compress/pull/938
* Feb 21st, 2024 - [1.17.7](https://github.com/klauspost/compress/releases/tag/v1.17.7)
* s2: Add AsyncFlush method: Complete the block without flushing by @Jille in https://github.com/klauspost/compress/pull/927
* s2: Fix literal+repeat exceeds dst crash https://github.com/klauspost/compress/pull/930
* Feb 5th, 2024 - [1.17.6](https://github.com/klauspost/compress/releases/tag/v1.17.6)
* zstd: Fix incorrect repeat coding in best mode https://github.com/klauspost/compress/pull/923
* s2: Fix DecodeConcurrent deadlock on errors https://github.com/klauspost/compress/pull/925
@ -81,7 +102,7 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp
* zstd: Various minor improvements by @greatroar in https://github.com/klauspost/compress/pull/788 https://github.com/klauspost/compress/pull/794 https://github.com/klauspost/compress/pull/795
* s2: Fix huge block overflow https://github.com/klauspost/compress/pull/779
* s2: Allow CustomEncoder fallback https://github.com/klauspost/compress/pull/780
* gzhttp: Suppport ResponseWriter Unwrap() in gzhttp handler by @jgimenez in https://github.com/klauspost/compress/pull/799
* gzhttp: Support ResponseWriter Unwrap() in gzhttp handler by @jgimenez in https://github.com/klauspost/compress/pull/799
* Mar 13, 2023 - [v1.16.1](https://github.com/klauspost/compress/releases/tag/v1.16.1)
* zstd: Speed up + improve best encoder by @greatroar in https://github.com/klauspost/compress/pull/776
@ -136,7 +157,7 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp
* zstd: Add [WithDecodeAllCapLimit](https://pkg.go.dev/github.com/klauspost/compress@v1.15.10/zstd#WithDecodeAllCapLimit) https://github.com/klauspost/compress/pull/649
* Add Go 1.19 - deprecate Go 1.16 https://github.com/klauspost/compress/pull/651
* flate: Improve level 5+6 compression https://github.com/klauspost/compress/pull/656
* zstd: Improve "better" compresssion https://github.com/klauspost/compress/pull/657
* zstd: Improve "better" compression https://github.com/klauspost/compress/pull/657
* s2: Improve "best" compression https://github.com/klauspost/compress/pull/658
* s2: Improve "better" compression. https://github.com/klauspost/compress/pull/635
* s2: Slightly faster non-assembly decompression https://github.com/klauspost/compress/pull/646
@ -339,7 +360,7 @@ While the release has been extensively tested, it is recommended to testing when
* s2: Fix binaries.
* Feb 25, 2021 (v1.11.8)
* s2: Fixed occational out-of-bounds write on amd64. Upgrade recommended.
* s2: Fixed occasional out-of-bounds write on amd64. Upgrade recommended.
* s2: Add AMD64 assembly for better mode. 25-50% faster. [#315](https://github.com/klauspost/compress/pull/315)
* s2: Less upfront decoder allocation. [#322](https://github.com/klauspost/compress/pull/322)
* zstd: Faster "compression" of incompressible data. [#314](https://github.com/klauspost/compress/pull/314)
@ -518,7 +539,7 @@ While the release has been extensively tested, it is recommended to testing when
* Feb 19, 2016: Faster bit writer, level -2 is 15% faster, level 1 is 4% faster.
* Feb 19, 2016: Handle small payloads faster in level 1-3.
* Feb 19, 2016: Added faster level 2 + 3 compression modes.
* Feb 19, 2016: [Rebalanced compression levels](https://blog.klauspost.com/rebalancing-deflate-compression-levels/), so there is a more even progresssion in terms of compression. New default level is 5.
* Feb 19, 2016: [Rebalanced compression levels](https://blog.klauspost.com/rebalancing-deflate-compression-levels/), so there is a more even progression in terms of compression. New default level is 5.
* Feb 14, 2016: Snappy: Merge upstream changes.
* Feb 14, 2016: Snappy: Fix aggressive skipping.
* Feb 14, 2016: Snappy: Update benchmark.

View File

@ -15,7 +15,7 @@ const (
// It is possible, but by no way guaranteed that corrupt data will
// return an error.
// It is up to the caller to verify integrity of the returned data.
// Use a predefined Scrach to set maximum acceptable output size.
// Use a predefined Scratch to set maximum acceptable output size.
func Decompress(b []byte, s *Scratch) ([]byte, error) {
s, err := s.prepare(b)
if err != nil {

View File

@ -1136,7 +1136,7 @@ func (s *Scratch) matches(ct cTable, w io.Writer) {
errs++
}
if errs > 0 {
fmt.Fprintf(w, "%d errros in base, stopping\n", errs)
fmt.Fprintf(w, "%d errors in base, stopping\n", errs)
continue
}
// Ensure that all combinations are covered.
@ -1152,7 +1152,7 @@ func (s *Scratch) matches(ct cTable, w io.Writer) {
errs++
}
if errs > 20 {
fmt.Fprintf(w, "%d errros, stopping\n", errs)
fmt.Fprintf(w, "%d errors, stopping\n", errs)
break
}
}

View File

@ -598,7 +598,9 @@ func (b *blockDec) prepareSequences(in []byte, hist *history) (err error) {
printf("RLE set to 0x%x, code: %v", symb, v)
}
case compModeFSE:
println("Reading table for", tableIndex(i))
if debugDecoder {
println("Reading table for", tableIndex(i))
}
if seq.fse == nil || seq.fse.preDefined {
seq.fse = fseDecoderPool.Get().(*fseDecoder)
}

View File

@ -179,9 +179,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well.
var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch)
seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards.
// Extend as long as we can.
@ -210,12 +210,12 @@ encodeLoop:
// Index match start+1 (long) -> s - 1
index0 := s + repOff
s += lenght + repOff
s += length + repOff
nextEmit = s
if s >= sLimit {
if debugEncoder {
println("repeat ended", s, lenght)
println("repeat ended", s, length)
}
break encodeLoop
@ -241,9 +241,9 @@ encodeLoop:
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
// Consider history as well.
var seq seq
lenght := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
length := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
seq.matchLen = uint32(lenght - zstdMinMatch)
seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards.
// Extend as long as we can.
@ -270,11 +270,11 @@ encodeLoop:
}
blk.sequences = append(blk.sequences, seq)
s += lenght + repOff2
s += length + repOff2
nextEmit = s
if s >= sLimit {
if debugEncoder {
println("repeat ended", s, lenght)
println("repeat ended", s, length)
}
break encodeLoop
@ -708,9 +708,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well.
var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch)
seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards.
// Extend as long as we can.
@ -738,12 +738,12 @@ encodeLoop:
blk.sequences = append(blk.sequences, seq)
// Index match start+1 (long) -> s - 1
s += lenght + repOff
s += length + repOff
nextEmit = s
if s >= sLimit {
if debugEncoder {
println("repeat ended", s, lenght)
println("repeat ended", s, length)
}
break encodeLoop
@ -772,9 +772,9 @@ encodeLoop:
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
// Consider history as well.
var seq seq
lenght := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
length := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
seq.matchLen = uint32(lenght - zstdMinMatch)
seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards.
// Extend as long as we can.
@ -801,11 +801,11 @@ encodeLoop:
}
blk.sequences = append(blk.sequences, seq)
s += lenght + repOff2
s += length + repOff2
nextEmit = s
if s >= sLimit {
if debugEncoder {
println("repeat ended", s, lenght)
println("repeat ended", s, length)
}
break encodeLoop

View File

@ -138,9 +138,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well.
var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch)
seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards.
// Extend as long as we can.
@ -166,11 +166,11 @@ encodeLoop:
println("repeat sequence", seq, "next s:", s)
}
blk.sequences = append(blk.sequences, seq)
s += lenght + repOff
s += length + repOff
nextEmit = s
if s >= sLimit {
if debugEncoder {
println("repeat ended", s, lenght)
println("repeat ended", s, length)
}
break encodeLoop
@ -798,9 +798,9 @@ encodeLoop:
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
// Consider history as well.
var seq seq
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
seq.matchLen = uint32(lenght - zstdMinMatch)
seq.matchLen = uint32(length - zstdMinMatch)
// We might be able to match backwards.
// Extend as long as we can.
@ -826,11 +826,11 @@ encodeLoop:
println("repeat sequence", seq, "next s:", s)
}
blk.sequences = append(blk.sequences, seq)
s += lenght + repOff
s += length + repOff
nextEmit = s
if s >= sLimit {
if debugEncoder {
println("repeat ended", s, lenght)
println("repeat ended", s, length)
}
break encodeLoop

View File

@ -6,6 +6,7 @@ package zstd
import (
"crypto/rand"
"errors"
"fmt"
"io"
"math"
@ -149,6 +150,9 @@ func (e *Encoder) ResetContentSize(w io.Writer, size int64) {
// and write CRC if requested.
func (e *Encoder) Write(p []byte) (n int, err error) {
s := &e.state
if s.eofWritten {
return 0, ErrEncoderClosed
}
for len(p) > 0 {
if len(p)+len(s.filling) < e.o.blockSize {
if e.o.crc {
@ -202,7 +206,7 @@ func (e *Encoder) nextBlock(final bool) error {
return nil
}
if final && len(s.filling) > 0 {
s.current = e.EncodeAll(s.filling, s.current[:0])
s.current = e.encodeAll(s.encoder, s.filling, s.current[:0])
var n2 int
n2, s.err = s.w.Write(s.current)
if s.err != nil {
@ -288,6 +292,9 @@ func (e *Encoder) nextBlock(final bool) error {
s.filling, s.current, s.previous = s.previous[:0], s.filling, s.current
s.nInput += int64(len(s.current))
s.wg.Add(1)
if final {
s.eofWritten = true
}
go func(src []byte) {
if debugEncoder {
println("Adding block,", len(src), "bytes, final:", final)
@ -303,9 +310,6 @@ func (e *Encoder) nextBlock(final bool) error {
blk := enc.Block()
enc.Encode(blk, src)
blk.last = final
if final {
s.eofWritten = true
}
// Wait for pending writes.
s.wWg.Wait()
if s.writeErr != nil {
@ -401,12 +405,20 @@ func (e *Encoder) Flush() error {
if len(s.filling) > 0 {
err := e.nextBlock(false)
if err != nil {
// Ignore Flush after Close.
if errors.Is(s.err, ErrEncoderClosed) {
return nil
}
return err
}
}
s.wg.Wait()
s.wWg.Wait()
if s.err != nil {
// Ignore Flush after Close.
if errors.Is(s.err, ErrEncoderClosed) {
return nil
}
return s.err
}
return s.writeErr
@ -422,6 +434,9 @@ func (e *Encoder) Close() error {
}
err := e.nextBlock(true)
if err != nil {
if errors.Is(s.err, ErrEncoderClosed) {
return nil
}
return err
}
if s.frameContentSize > 0 {
@ -459,6 +474,11 @@ func (e *Encoder) Close() error {
}
_, s.err = s.w.Write(frame)
}
if s.err == nil {
s.err = ErrEncoderClosed
return nil
}
return s.err
}
@ -469,6 +489,15 @@ func (e *Encoder) Close() error {
// Data compressed with EncodeAll can be decoded with the Decoder,
// using either a stream or DecodeAll.
func (e *Encoder) EncodeAll(src, dst []byte) []byte {
e.init.Do(e.initialize)
enc := <-e.encoders
defer func() {
e.encoders <- enc
}()
return e.encodeAll(enc, src, dst)
}
func (e *Encoder) encodeAll(enc encoder, src, dst []byte) []byte {
if len(src) == 0 {
if e.o.fullZero {
// Add frame header.
@ -491,13 +520,7 @@ func (e *Encoder) EncodeAll(src, dst []byte) []byte {
}
return dst
}
e.init.Do(e.initialize)
enc := <-e.encoders
defer func() {
// Release encoder reference to last block.
// If a non-single block is needed the encoder will reset again.
e.encoders <- enc
}()
// Use single segments when above minimum window and below window size.
single := len(src) <= e.o.windowSize && len(src) > MinWindowSize
if e.o.single != nil {

View File

@ -146,7 +146,9 @@ func (d *frameDec) reset(br byteBuffer) error {
}
return err
}
printf("raw: %x, mantissa: %d, exponent: %d\n", wd, wd&7, wd>>3)
if debugDecoder {
printf("raw: %x, mantissa: %d, exponent: %d\n", wd, wd&7, wd>>3)
}
windowLog := 10 + (wd >> 3)
windowBase := uint64(1) << windowLog
windowAdd := (windowBase / 8) * uint64(wd&0x7)

View File

@ -146,7 +146,7 @@ func (s *sequenceDecs) decodeSyncSimple(hist []byte) (bool, error) {
return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize)
default:
return true, fmt.Errorf("sequenceDecs_decode returned erronous code %d", errCode)
return true, fmt.Errorf("sequenceDecs_decode returned erroneous code %d", errCode)
}
s.seqSize += ctx.litRemain
@ -292,7 +292,7 @@ func (s *sequenceDecs) decode(seqs []seqVals) error {
return io.ErrUnexpectedEOF
}
return fmt.Errorf("sequenceDecs_decode_amd64 returned erronous code %d", errCode)
return fmt.Errorf("sequenceDecs_decode_amd64 returned erroneous code %d", errCode)
}
if ctx.litRemain < 0 {

View File

@ -1814,7 +1814,7 @@ TEXT ·sequenceDecs_decodeSync_amd64(SB), $64-32
MOVQ 40(SP), AX
ADDQ AX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R10, 32(SP)
// outBase += outPosition
@ -2376,7 +2376,7 @@ TEXT ·sequenceDecs_decodeSync_bmi2(SB), $64-32
MOVQ 40(SP), CX
ADDQ CX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R9, 32(SP)
// outBase += outPosition
@ -2896,7 +2896,7 @@ TEXT ·sequenceDecs_decodeSync_safe_amd64(SB), $64-32
MOVQ 40(SP), AX
ADDQ AX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R10, 32(SP)
// outBase += outPosition
@ -3560,7 +3560,7 @@ TEXT ·sequenceDecs_decodeSync_safe_bmi2(SB), $64-32
MOVQ 40(SP), CX
ADDQ CX, 48(SP)
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
ADDQ R9, 32(SP)
// outBase += outPosition

View File

@ -88,6 +88,10 @@ var (
// Close has been called.
ErrDecoderClosed = errors.New("decoder used after Close")
// ErrEncoderClosed will be returned if the Encoder was used after
// Close has been called.
ErrEncoderClosed = errors.New("encoder used after Close")
// ErrDecoderNilInput is returned when a nil Reader was provided
// and an operation other than Reset/DecodeAll/Close was attempted.
ErrDecoderNilInput = errors.New("nil input provided as reader")

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/api/services/control/control.proto
@ -89,11 +89,9 @@ type PruneRequest struct {
func (x *PruneRequest) Reset() {
*x = PruneRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PruneRequest) String() string {
@ -104,7 +102,7 @@ func (*PruneRequest) ProtoMessage() {}
func (x *PruneRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -171,11 +169,9 @@ type DiskUsageRequest struct {
func (x *DiskUsageRequest) Reset() {
*x = DiskUsageRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DiskUsageRequest) String() string {
@ -186,7 +182,7 @@ func (*DiskUsageRequest) ProtoMessage() {}
func (x *DiskUsageRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -218,11 +214,9 @@ type DiskUsageResponse struct {
func (x *DiskUsageResponse) Reset() {
*x = DiskUsageResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DiskUsageResponse) String() string {
@ -233,7 +227,7 @@ func (*DiskUsageResponse) ProtoMessage() {}
func (x *DiskUsageResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -277,11 +271,9 @@ type UsageRecord struct {
func (x *UsageRecord) Reset() {
*x = UsageRecord{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UsageRecord) String() string {
@ -292,7 +284,7 @@ func (*UsageRecord) ProtoMessage() {}
func (x *UsageRecord) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -417,11 +409,9 @@ type SolveRequest struct {
func (x *SolveRequest) Reset() {
*x = SolveRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SolveRequest) String() string {
@ -432,7 +422,7 @@ func (*SolveRequest) ProtoMessage() {}
func (x *SolveRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -564,11 +554,9 @@ type CacheOptions struct {
func (x *CacheOptions) Reset() {
*x = CacheOptions{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CacheOptions) String() string {
@ -579,7 +567,7 @@ func (*CacheOptions) ProtoMessage() {}
func (x *CacheOptions) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -643,11 +631,9 @@ type CacheOptionsEntry struct {
func (x *CacheOptionsEntry) Reset() {
*x = CacheOptionsEntry{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CacheOptionsEntry) String() string {
@ -658,7 +644,7 @@ func (*CacheOptionsEntry) ProtoMessage() {}
func (x *CacheOptionsEntry) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -697,11 +683,9 @@ type SolveResponse struct {
func (x *SolveResponse) Reset() {
*x = SolveResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SolveResponse) String() string {
@ -712,7 +696,7 @@ func (*SolveResponse) ProtoMessage() {}
func (x *SolveResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -744,11 +728,9 @@ type StatusRequest struct {
func (x *StatusRequest) Reset() {
*x = StatusRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *StatusRequest) String() string {
@ -759,7 +741,7 @@ func (*StatusRequest) ProtoMessage() {}
func (x *StatusRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -794,11 +776,9 @@ type StatusResponse struct {
func (x *StatusResponse) Reset() {
*x = StatusResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *StatusResponse) String() string {
@ -809,7 +789,7 @@ func (*StatusResponse) ProtoMessage() {}
func (x *StatusResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -869,11 +849,9 @@ type Vertex struct {
func (x *Vertex) Reset() {
*x = Vertex{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Vertex) String() string {
@ -884,7 +862,7 @@ func (*Vertex) ProtoMessage() {}
func (x *Vertex) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -972,11 +950,9 @@ type VertexStatus struct {
func (x *VertexStatus) Reset() {
*x = VertexStatus{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VertexStatus) String() string {
@ -987,7 +963,7 @@ func (*VertexStatus) ProtoMessage() {}
func (x *VertexStatus) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1071,11 +1047,9 @@ type VertexLog struct {
func (x *VertexLog) Reset() {
*x = VertexLog{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VertexLog) String() string {
@ -1086,7 +1060,7 @@ func (*VertexLog) ProtoMessage() {}
func (x *VertexLog) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1145,11 +1119,9 @@ type VertexWarning struct {
func (x *VertexWarning) Reset() {
*x = VertexWarning{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VertexWarning) String() string {
@ -1160,7 +1132,7 @@ func (*VertexWarning) ProtoMessage() {}
func (x *VertexWarning) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1234,11 +1206,9 @@ type BytesMessage struct {
func (x *BytesMessage) Reset() {
*x = BytesMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BytesMessage) String() string {
@ -1249,7 +1219,7 @@ func (*BytesMessage) ProtoMessage() {}
func (x *BytesMessage) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[14]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1281,11 +1251,9 @@ type ListWorkersRequest struct {
func (x *ListWorkersRequest) Reset() {
*x = ListWorkersRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListWorkersRequest) String() string {
@ -1296,7 +1264,7 @@ func (*ListWorkersRequest) ProtoMessage() {}
func (x *ListWorkersRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[15]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1328,11 +1296,9 @@ type ListWorkersResponse struct {
func (x *ListWorkersResponse) Reset() {
*x = ListWorkersResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListWorkersResponse) String() string {
@ -1343,7 +1309,7 @@ func (*ListWorkersResponse) ProtoMessage() {}
func (x *ListWorkersResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[16]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1373,11 +1339,9 @@ type InfoRequest struct {
func (x *InfoRequest) Reset() {
*x = InfoRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *InfoRequest) String() string {
@ -1388,7 +1352,7 @@ func (*InfoRequest) ProtoMessage() {}
func (x *InfoRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[17]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1413,11 +1377,9 @@ type InfoResponse struct {
func (x *InfoResponse) Reset() {
*x = InfoResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *InfoResponse) String() string {
@ -1428,7 +1390,7 @@ func (*InfoResponse) ProtoMessage() {}
func (x *InfoResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[18]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1462,11 +1424,9 @@ type BuildHistoryRequest struct {
func (x *BuildHistoryRequest) Reset() {
*x = BuildHistoryRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BuildHistoryRequest) String() string {
@ -1477,7 +1437,7 @@ func (*BuildHistoryRequest) ProtoMessage() {}
func (x *BuildHistoryRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[19]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1524,11 +1484,9 @@ type BuildHistoryEvent struct {
func (x *BuildHistoryEvent) Reset() {
*x = BuildHistoryEvent{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BuildHistoryEvent) String() string {
@ -1539,7 +1497,7 @@ func (*BuildHistoryEvent) ProtoMessage() {}
func (x *BuildHistoryEvent) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[20]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1596,11 +1554,9 @@ type BuildHistoryRecord struct {
func (x *BuildHistoryRecord) Reset() {
*x = BuildHistoryRecord{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BuildHistoryRecord) String() string {
@ -1611,7 +1567,7 @@ func (*BuildHistoryRecord) ProtoMessage() {}
func (x *BuildHistoryRecord) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[21]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1772,11 +1728,9 @@ type UpdateBuildHistoryRequest struct {
func (x *UpdateBuildHistoryRequest) Reset() {
*x = UpdateBuildHistoryRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UpdateBuildHistoryRequest) String() string {
@ -1787,7 +1741,7 @@ func (*UpdateBuildHistoryRequest) ProtoMessage() {}
func (x *UpdateBuildHistoryRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[22]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1838,11 +1792,9 @@ type UpdateBuildHistoryResponse struct {
func (x *UpdateBuildHistoryResponse) Reset() {
*x = UpdateBuildHistoryResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UpdateBuildHistoryResponse) String() string {
@ -1853,7 +1805,7 @@ func (*UpdateBuildHistoryResponse) ProtoMessage() {}
func (x *UpdateBuildHistoryResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[23]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1881,11 +1833,9 @@ type Descriptor struct {
func (x *Descriptor) Reset() {
*x = Descriptor{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Descriptor) String() string {
@ -1896,7 +1846,7 @@ func (*Descriptor) ProtoMessage() {}
func (x *Descriptor) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[24]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -1951,11 +1901,9 @@ type BuildResultInfo struct {
func (x *BuildResultInfo) Reset() {
*x = BuildResultInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BuildResultInfo) String() string {
@ -1966,7 +1914,7 @@ func (*BuildResultInfo) ProtoMessage() {}
func (x *BuildResultInfo) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[25]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -2016,11 +1964,9 @@ type Exporter struct {
func (x *Exporter) Reset() {
*x = Exporter{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[26]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[26]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Exporter) String() string {
@ -2031,7 +1977,7 @@ func (*Exporter) ProtoMessage() {}
func (x *Exporter) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[26]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -2549,7 +2495,7 @@ func file_github_com_moby_buildkit_api_services_control_control_proto_rawDescGZI
var file_github_com_moby_buildkit_api_services_control_control_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes = make([]protoimpl.MessageInfo, 39)
var file_github_com_moby_buildkit_api_services_control_control_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_api_services_control_control_proto_goTypes = []any{
(BuildHistoryEventType)(0), // 0: moby.buildkit.v1.BuildHistoryEventType
(*PruneRequest)(nil), // 1: moby.buildkit.v1.PruneRequest
(*DiskUsageRequest)(nil), // 2: moby.buildkit.v1.DiskUsageRequest
@ -2682,332 +2628,6 @@ func file_github_com_moby_buildkit_api_services_control_control_proto_init() {
if File_github_com_moby_buildkit_api_services_control_control_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PruneRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DiskUsageRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DiskUsageResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UsageRecord); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SolveRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CacheOptions); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CacheOptionsEntry); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SolveResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StatusRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StatusResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Vertex); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VertexStatus); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VertexLog); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VertexWarning); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BytesMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListWorkersRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListWorkersResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*InfoRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*InfoResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BuildHistoryRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BuildHistoryEvent); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BuildHistoryRecord); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateBuildHistoryRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateBuildHistoryResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Descriptor); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BuildResultInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_services_control_control_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Exporter); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/api/types/worker.proto
@ -35,11 +35,9 @@ type WorkerRecord struct {
func (x *WorkerRecord) Reset() {
*x = WorkerRecord{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *WorkerRecord) String() string {
@ -50,7 +48,7 @@ func (*WorkerRecord) ProtoMessage() {}
func (x *WorkerRecord) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -116,11 +114,9 @@ type GCPolicy struct {
func (x *GCPolicy) Reset() {
*x = GCPolicy{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GCPolicy) String() string {
@ -131,7 +127,7 @@ func (*GCPolicy) ProtoMessage() {}
func (x *GCPolicy) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -200,11 +196,9 @@ type BuildkitVersion struct {
func (x *BuildkitVersion) Reset() {
*x = BuildkitVersion{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BuildkitVersion) String() string {
@ -215,7 +209,7 @@ func (*BuildkitVersion) ProtoMessage() {}
func (x *BuildkitVersion) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -322,7 +316,7 @@ func file_github_com_moby_buildkit_api_types_worker_proto_rawDescGZIP() []byte {
}
var file_github_com_moby_buildkit_api_types_worker_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_github_com_moby_buildkit_api_types_worker_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_api_types_worker_proto_goTypes = []any{
(*WorkerRecord)(nil), // 0: moby.buildkit.v1.types.WorkerRecord
(*GCPolicy)(nil), // 1: moby.buildkit.v1.types.GCPolicy
(*BuildkitVersion)(nil), // 2: moby.buildkit.v1.types.BuildkitVersion
@ -346,44 +340,6 @@ func file_github_com_moby_buildkit_api_types_worker_proto_init() {
if File_github_com_moby_buildkit_api_types_worker_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*WorkerRecord); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GCPolicy); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_api_types_worker_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BuildkitVersion); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -5,6 +5,7 @@ import (
"io"
"os"
"path"
"syscall"
"github.com/gofrs/flock"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
@ -36,15 +37,18 @@ func (s StoreIndex) Read() (*ocispecs.Index, error) {
lock := flock.New(s.lockPath)
locked, err := lock.TryRLock()
if err != nil {
return nil, errors.Wrapf(err, "could not lock %s", s.lockPath)
if !errors.Is(err, syscall.EPERM) && !errors.Is(err, syscall.EROFS) {
return nil, errors.Wrapf(err, "could not lock %s", s.lockPath)
}
} else {
if !locked {
return nil, errors.Errorf("could not lock %s", s.lockPath)
}
defer func() {
lock.Unlock()
os.RemoveAll(s.lockPath)
}()
}
if !locked {
return nil, errors.Errorf("could not lock %s", s.lockPath)
}
defer func() {
lock.Unlock()
os.RemoveAll(s.lockPath)
}()
b, err := os.ReadFile(s.indexPath)
if err != nil {

View File

@ -172,5 +172,6 @@ var (
Format: func(instruction, defName string) string {
return fmt.Sprintf("Comment for %s should follow the format: `# %s <description>`", instruction, defName)
},
Experimental: true,
}
)

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/session/auth/auth.proto
@ -30,11 +30,9 @@ type CredentialsRequest struct {
func (x *CredentialsRequest) Reset() {
*x = CredentialsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CredentialsRequest) String() string {
@ -45,7 +43,7 @@ func (*CredentialsRequest) ProtoMessage() {}
func (x *CredentialsRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -78,11 +76,9 @@ type CredentialsResponse struct {
func (x *CredentialsResponse) Reset() {
*x = CredentialsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CredentialsResponse) String() string {
@ -93,7 +89,7 @@ func (*CredentialsResponse) ProtoMessage() {}
func (x *CredentialsResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -136,11 +132,9 @@ type FetchTokenRequest struct {
func (x *FetchTokenRequest) Reset() {
*x = FetchTokenRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FetchTokenRequest) String() string {
@ -151,7 +145,7 @@ func (*FetchTokenRequest) ProtoMessage() {}
func (x *FetchTokenRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -213,11 +207,9 @@ type FetchTokenResponse struct {
func (x *FetchTokenResponse) Reset() {
*x = FetchTokenResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FetchTokenResponse) String() string {
@ -228,7 +220,7 @@ func (*FetchTokenResponse) ProtoMessage() {}
func (x *FetchTokenResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -275,11 +267,9 @@ type GetTokenAuthorityRequest struct {
func (x *GetTokenAuthorityRequest) Reset() {
*x = GetTokenAuthorityRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetTokenAuthorityRequest) String() string {
@ -290,7 +280,7 @@ func (*GetTokenAuthorityRequest) ProtoMessage() {}
func (x *GetTokenAuthorityRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -329,11 +319,9 @@ type GetTokenAuthorityResponse struct {
func (x *GetTokenAuthorityResponse) Reset() {
*x = GetTokenAuthorityResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetTokenAuthorityResponse) String() string {
@ -344,7 +332,7 @@ func (*GetTokenAuthorityResponse) ProtoMessage() {}
func (x *GetTokenAuthorityResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -378,11 +366,9 @@ type VerifyTokenAuthorityRequest struct {
func (x *VerifyTokenAuthorityRequest) Reset() {
*x = VerifyTokenAuthorityRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VerifyTokenAuthorityRequest) String() string {
@ -393,7 +379,7 @@ func (*VerifyTokenAuthorityRequest) ProtoMessage() {}
func (x *VerifyTokenAuthorityRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -439,11 +425,9 @@ type VerifyTokenAuthorityResponse struct {
func (x *VerifyTokenAuthorityResponse) Reset() {
*x = VerifyTokenAuthorityResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *VerifyTokenAuthorityResponse) String() string {
@ -454,7 +438,7 @@ func (*VerifyTokenAuthorityResponse) ProtoMessage() {}
func (x *VerifyTokenAuthorityResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -568,7 +552,7 @@ func file_github_com_moby_buildkit_session_auth_auth_proto_rawDescGZIP() []byte
}
var file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_github_com_moby_buildkit_session_auth_auth_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_session_auth_auth_proto_goTypes = []any{
(*CredentialsRequest)(nil), // 0: moby.filesync.v1.CredentialsRequest
(*CredentialsResponse)(nil), // 1: moby.filesync.v1.CredentialsResponse
(*FetchTokenRequest)(nil), // 2: moby.filesync.v1.FetchTokenRequest
@ -599,104 +583,6 @@ func file_github_com_moby_buildkit_session_auth_auth_proto_init() {
if File_github_com_moby_buildkit_session_auth_auth_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CredentialsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CredentialsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FetchTokenRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FetchTokenResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetTokenAuthorityRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetTokenAuthorityResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VerifyTokenAuthorityRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_auth_auth_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VerifyTokenAuthorityResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -24,6 +24,7 @@ import (
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/auth"
"github.com/moby/buildkit/util/progress/progresswriter"
"github.com/moby/buildkit/util/tracing"
"github.com/pkg/errors"
"golang.org/x/crypto/nacl/sign"
"google.golang.org/grpc"
@ -73,7 +74,7 @@ func (ap *authProvider) Register(server *grpc.Server) {
}
func (ap *authProvider) FetchToken(ctx context.Context, req *auth.FetchTokenRequest) (rr *auth.FetchTokenResponse, err error) {
ac, err := ap.getAuthConfig(req.Host)
ac, err := ap.getAuthConfig(ctx, req.Host)
if err != nil {
return nil, err
}
@ -83,7 +84,7 @@ func (ap *authProvider) FetchToken(ctx context.Context, req *auth.FetchTokenRequ
return toTokenResponse(ac.RegistryToken, time.Time{}, 0), nil
}
creds, err := ap.credentials(req.Host)
creds, err := ap.credentials(ctx, req.Host)
if err != nil {
return nil, err
}
@ -96,11 +97,11 @@ func (ap *authProvider) FetchToken(ctx context.Context, req *auth.FetchTokenRequ
Secret: creds.Secret,
}
httpClient := http.DefaultClient()
httpClient := tracing.DefaultClient
if tc, err := ap.tlsConfig(req.Host); err == nil && tc != nil {
transport := http.DefaultTransport()
transport.TLSClientConfig = tc
httpClient.Transport = transport
httpClient.Transport = tracing.NewTransport(transport)
}
if creds.Secret != "" {
@ -186,8 +187,8 @@ func (ap *authProvider) tlsConfig(host string) (*tls.Config, error) {
return tc, nil
}
func (ap *authProvider) credentials(host string) (*auth.CredentialsResponse, error) {
ac, err := ap.getAuthConfig(host)
func (ap *authProvider) credentials(ctx context.Context, host string) (*auth.CredentialsResponse, error) {
ac, err := ap.getAuthConfig(ctx, host)
if err != nil {
return nil, err
}
@ -202,7 +203,7 @@ func (ap *authProvider) credentials(host string) (*auth.CredentialsResponse, err
}
func (ap *authProvider) Credentials(ctx context.Context, req *auth.CredentialsRequest) (*auth.CredentialsResponse, error) {
resp, err := ap.credentials(req.Host)
resp, err := ap.credentials(ctx, req.Host)
if err != nil || resp.Secret != "" {
ap.mu.Lock()
defer ap.mu.Unlock()
@ -218,7 +219,7 @@ func (ap *authProvider) Credentials(ctx context.Context, req *auth.CredentialsRe
}
func (ap *authProvider) GetTokenAuthority(ctx context.Context, req *auth.GetTokenAuthorityRequest) (*auth.GetTokenAuthorityResponse, error) {
key, err := ap.getAuthorityKey(req.Host, req.Salt)
key, err := ap.getAuthorityKey(ctx, req.Host, req.Salt)
if err != nil {
return nil, err
}
@ -227,7 +228,7 @@ func (ap *authProvider) GetTokenAuthority(ctx context.Context, req *auth.GetToke
}
func (ap *authProvider) VerifyTokenAuthority(ctx context.Context, req *auth.VerifyTokenAuthorityRequest) (*auth.VerifyTokenAuthorityResponse, error) {
key, err := ap.getAuthorityKey(req.Host, req.Salt)
key, err := ap.getAuthorityKey(ctx, req.Host, req.Salt)
if err != nil {
return nil, err
}
@ -238,7 +239,7 @@ func (ap *authProvider) VerifyTokenAuthority(ctx context.Context, req *auth.Veri
return &auth.VerifyTokenAuthorityResponse{Signed: sign.Sign(nil, req.Payload, priv)}, nil
}
func (ap *authProvider) getAuthConfig(host string) (*types.AuthConfig, error) {
func (ap *authProvider) getAuthConfig(ctx context.Context, host string) (*types.AuthConfig, error) {
ap.mu.Lock()
defer ap.mu.Unlock()
@ -247,7 +248,9 @@ func (ap *authProvider) getAuthConfig(host string) (*types.AuthConfig, error) {
}
if _, exists := ap.authConfigCache[host]; !exists {
span, _ := tracing.StartSpan(ctx, fmt.Sprintf("load credentials for %s", host))
ac, err := ap.config.GetAuthConfig(host)
tracing.FinishWithError(span, err)
if err != nil {
return nil, err
}
@ -257,12 +260,12 @@ func (ap *authProvider) getAuthConfig(host string) (*types.AuthConfig, error) {
return ap.authConfigCache[host], nil
}
func (ap *authProvider) getAuthorityKey(host string, salt []byte) (ed25519.PrivateKey, error) {
func (ap *authProvider) getAuthorityKey(ctx context.Context, host string, salt []byte) (ed25519.PrivateKey, error) {
if v, err := strconv.ParseBool(os.Getenv("BUILDKIT_NO_CLIENT_TOKEN")); err == nil && v {
return nil, status.Errorf(codes.Unavailable, "client side tokens disabled")
}
creds, err := ap.credentials(host)
creds, err := ap.credentials(ctx, host)
if err != nil {
return nil, err
}

View File

@ -129,8 +129,9 @@ func syncTargetDiffCopy(ds grpc.ServerStream, dest string) error {
}
func writeTargetFile(ds grpc.ServerStream, wc io.WriteCloser) error {
var bm BytesMessage
for {
bm := BytesMessage{}
bm.Data = bm.Data[:0]
if err := ds.RecvMsg(&bm); err != nil {
if errors.Is(err, io.EOF) {
return nil

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/session/filesync/filesync.proto
@ -32,11 +32,9 @@ type BytesMessage struct {
func (x *BytesMessage) Reset() {
*x = BytesMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_filesync_filesync_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_filesync_filesync_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BytesMessage) String() string {
@ -47,7 +45,7 @@ func (*BytesMessage) ProtoMessage() {}
func (x *BytesMessage) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_filesync_filesync_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -115,7 +113,7 @@ func file_github_com_moby_buildkit_session_filesync_filesync_proto_rawDescGZIP()
}
var file_github_com_moby_buildkit_session_filesync_filesync_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_github_com_moby_buildkit_session_filesync_filesync_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_session_filesync_filesync_proto_goTypes = []any{
(*BytesMessage)(nil), // 0: moby.filesync.v1.BytesMessage
(*types.Packet)(nil), // 1: fsutil.types.Packet
}
@ -138,20 +136,6 @@ func file_github_com_moby_buildkit_session_filesync_filesync_proto_init() {
if File_github_com_moby_buildkit_session_filesync_filesync_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_session_filesync_filesync_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BytesMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/session/secrets/secrets.proto
@ -31,11 +31,9 @@ type GetSecretRequest struct {
func (x *GetSecretRequest) Reset() {
*x = GetSecretRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetSecretRequest) String() string {
@ -46,7 +44,7 @@ func (*GetSecretRequest) ProtoMessage() {}
func (x *GetSecretRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -85,11 +83,9 @@ type GetSecretResponse struct {
func (x *GetSecretResponse) Reset() {
*x = GetSecretResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetSecretResponse) String() string {
@ -100,7 +96,7 @@ func (*GetSecretResponse) ProtoMessage() {}
func (x *GetSecretResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -171,7 +167,7 @@ func file_github_com_moby_buildkit_session_secrets_secrets_proto_rawDescGZIP() [
}
var file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_github_com_moby_buildkit_session_secrets_secrets_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_session_secrets_secrets_proto_goTypes = []any{
(*GetSecretRequest)(nil), // 0: moby.buildkit.secrets.v1.GetSecretRequest
(*GetSecretResponse)(nil), // 1: moby.buildkit.secrets.v1.GetSecretResponse
nil, // 2: moby.buildkit.secrets.v1.GetSecretRequest.AnnotationsEntry
@ -192,32 +188,6 @@ func file_github_com_moby_buildkit_session_secrets_secrets_proto_init() {
if File_github_com_moby_buildkit_session_secrets_secrets_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetSecretRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_secrets_secrets_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetSecretResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/session/sshforward/ssh.proto
@ -31,11 +31,9 @@ type BytesMessage struct {
func (x *BytesMessage) Reset() {
*x = BytesMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BytesMessage) String() string {
@ -46,7 +44,7 @@ func (*BytesMessage) ProtoMessage() {}
func (x *BytesMessage) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -78,11 +76,9 @@ type CheckAgentRequest struct {
func (x *CheckAgentRequest) Reset() {
*x = CheckAgentRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckAgentRequest) String() string {
@ -93,7 +89,7 @@ func (*CheckAgentRequest) ProtoMessage() {}
func (x *CheckAgentRequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -123,11 +119,9 @@ type CheckAgentResponse struct {
func (x *CheckAgentResponse) Reset() {
*x = CheckAgentResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckAgentResponse) String() string {
@ -138,7 +132,7 @@ func (*CheckAgentResponse) ProtoMessage() {}
func (x *CheckAgentResponse) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -197,7 +191,7 @@ func file_github_com_moby_buildkit_session_sshforward_ssh_proto_rawDescGZIP() []
}
var file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_github_com_moby_buildkit_session_sshforward_ssh_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_session_sshforward_ssh_proto_goTypes = []any{
(*BytesMessage)(nil), // 0: moby.sshforward.v1.BytesMessage
(*CheckAgentRequest)(nil), // 1: moby.sshforward.v1.CheckAgentRequest
(*CheckAgentResponse)(nil), // 2: moby.sshforward.v1.CheckAgentResponse
@ -219,44 +213,6 @@ func file_github_com_moby_buildkit_session_sshforward_ssh_proto_init() {
if File_github_com_moby_buildkit_session_sshforward_ssh_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BytesMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CheckAgentRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_session_sshforward_ssh_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CheckAgentResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/session/upload/upload.proto
@ -31,11 +31,9 @@ type BytesMessage struct {
func (x *BytesMessage) Reset() {
*x = BytesMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_session_upload_upload_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_session_upload_upload_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BytesMessage) String() string {
@ -46,7 +44,7 @@ func (*BytesMessage) ProtoMessage() {}
func (x *BytesMessage) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_session_upload_upload_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -101,7 +99,7 @@ func file_github_com_moby_buildkit_session_upload_upload_proto_rawDescGZIP() []b
}
var file_github_com_moby_buildkit_session_upload_upload_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_github_com_moby_buildkit_session_upload_upload_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_session_upload_upload_proto_goTypes = []any{
(*BytesMessage)(nil), // 0: moby.upload.v1.BytesMessage
}
var file_github_com_moby_buildkit_session_upload_upload_proto_depIdxs = []int32{
@ -119,20 +117,6 @@ func file_github_com_moby_buildkit_session_upload_upload_proto_init() {
if File_github_com_moby_buildkit_session_upload_upload_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_session_upload_upload_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BytesMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/solver/errdefs/errdefs.proto
@ -31,11 +31,9 @@ type Vertex struct {
func (x *Vertex) Reset() {
*x = Vertex{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Vertex) String() string {
@ -46,7 +44,7 @@ func (*Vertex) ProtoMessage() {}
func (x *Vertex) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -79,11 +77,9 @@ type Source struct {
func (x *Source) Reset() {
*x = Source{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Source) String() string {
@ -94,7 +90,7 @@ func (*Source) ProtoMessage() {}
func (x *Source) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -133,11 +129,9 @@ type FrontendCap struct {
func (x *FrontendCap) Reset() {
*x = FrontendCap{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FrontendCap) String() string {
@ -148,7 +142,7 @@ func (*FrontendCap) ProtoMessage() {}
func (x *FrontendCap) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -180,11 +174,9 @@ type Subrequest struct {
func (x *Subrequest) Reset() {
*x = Subrequest{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Subrequest) String() string {
@ -195,7 +187,7 @@ func (*Subrequest) ProtoMessage() {}
func (x *Subrequest) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -235,11 +227,9 @@ type Solve struct {
func (x *Solve) Reset() {
*x = Solve{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Solve) String() string {
@ -250,7 +240,7 @@ func (*Solve) ProtoMessage() {}
func (x *Solve) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -341,11 +331,9 @@ type FileAction struct {
func (x *FileAction) Reset() {
*x = FileAction{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FileAction) String() string {
@ -356,7 +344,7 @@ func (*FileAction) ProtoMessage() {}
func (x *FileAction) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -389,11 +377,9 @@ type ContentCache struct {
func (x *ContentCache) Reset() {
*x = ContentCache{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ContentCache) String() string {
@ -404,7 +390,7 @@ func (*ContentCache) ProtoMessage() {}
func (x *ContentCache) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -491,7 +477,7 @@ func file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_rawDescGZIP() []
}
var file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_goTypes = []any{
(*Vertex)(nil), // 0: errdefs.Vertex
(*Source)(nil), // 1: errdefs.Source
(*FrontendCap)(nil), // 2: errdefs.FrontendCap
@ -523,93 +509,7 @@ func file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_init() {
if File_github_com_moby_buildkit_solver_errdefs_errdefs_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Vertex); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Source); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FrontendCap); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Subrequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Solve); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FileAction); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ContentCache); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[4].OneofWrappers = []interface{}{
file_github_com_moby_buildkit_solver_errdefs_errdefs_proto_msgTypes[4].OneofWrappers = []any{
(*Solve_File)(nil),
(*Solve_Cache)(nil),
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/sourcepolicy/pb/policy.proto
@ -189,11 +189,9 @@ type Rule struct {
func (x *Rule) Reset() {
*x = Rule{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Rule) String() string {
@ -204,7 +202,7 @@ func (*Rule) ProtoMessage() {}
func (x *Rule) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -252,11 +250,9 @@ type Update struct {
func (x *Update) Reset() {
*x = Update{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Update) String() string {
@ -267,7 +263,7 @@ func (*Update) ProtoMessage() {}
func (x *Update) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -310,11 +306,9 @@ type Selector struct {
func (x *Selector) Reset() {
*x = Selector{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Selector) String() string {
@ -325,7 +319,7 @@ func (*Selector) ProtoMessage() {}
func (x *Selector) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -374,11 +368,9 @@ type AttrConstraint struct {
func (x *AttrConstraint) Reset() {
*x = AttrConstraint{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AttrConstraint) String() string {
@ -389,7 +381,7 @@ func (*AttrConstraint) ProtoMessage() {}
func (x *AttrConstraint) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -437,11 +429,9 @@ type Policy struct {
func (x *Policy) Reset() {
*x = Policy{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Policy) String() string {
@ -452,7 +442,7 @@ func (*Policy) ProtoMessage() {}
func (x *Policy) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -571,7 +561,7 @@ func file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_rawDescGZIP() []
var file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_goTypes = []any{
(PolicyAction)(0), // 0: moby.buildkit.v1.sourcepolicy.PolicyAction
(AttrMatch)(0), // 1: moby.buildkit.v1.sourcepolicy.AttrMatch
(MatchType)(0), // 2: moby.buildkit.v1.sourcepolicy.MatchType
@ -603,68 +593,6 @@ func file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_init() {
if File_github_com_moby_buildkit_sourcepolicy_pb_policy_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Rule); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Update); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Selector); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AttrConstraint); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_sourcepolicy_pb_policy_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Policy); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/util/apicaps/pb/caps.proto
@ -36,11 +36,9 @@ type APICap struct {
func (x *APICap) Reset() {
*x = APICap{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *APICap) String() string {
@ -51,7 +49,7 @@ func (*APICap) ProtoMessage() {}
func (x *APICap) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -150,7 +148,7 @@ func file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_rawDescGZIP() []by
}
var file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_goTypes = []any{
(*APICap)(nil), // 0: moby.buildkit.v1.apicaps.APICap
}
var file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_depIdxs = []int32{
@ -166,20 +164,6 @@ func file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_init() {
if File_github_com_moby_buildkit_util_apicaps_pb_caps_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_util_apicaps_pb_caps_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*APICap); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -5,12 +5,14 @@ package disk
import (
"syscall"
"github.com/pkg/errors"
)
func GetDiskStat(root string) (DiskStat, error) {
var st syscall.Statfs_t
if err := syscall.Statfs(root, &st); err != nil {
return DiskStat{}, err
return DiskStat{}, errors.Wrapf(err, "could not stat fs at %s", root)
}
return DiskStat{

View File

@ -5,12 +5,14 @@ package disk
import (
"syscall"
"github.com/pkg/errors"
)
func GetDiskStat(root string) (DiskStat, error) {
var st syscall.Statfs_t
if err := syscall.Statfs(root, &st); err != nil {
return DiskStat{}, err
return DiskStat{}, errors.Wrapf(err, "could not stat fs at %s", root)
}
return DiskStat{

View File

@ -4,13 +4,14 @@
package disk
import (
"github.com/pkg/errors"
"golang.org/x/sys/windows"
)
func GetDiskStat(root string) (DiskStat, error) {
rootUTF16, err := windows.UTF16FromString(root)
if err != nil {
return DiskStat{}, err
return DiskStat{}, errors.Wrapf(err, "could not encode %s", root)
}
var (
totalBytes uint64
@ -22,7 +23,7 @@ func GetDiskStat(root string) (DiskStat, error) {
&freeAvailableBytes,
&totalBytes,
&totalFreeBytes); err != nil {
return DiskStat{}, err
return DiskStat{}, errors.Wrapf(err, "could not stat fs at %s", root)
}
return DiskStat{

View File

@ -218,6 +218,14 @@ func (cli *GitCLI) Run(ctx context.Context, args ...string) (_ []byte, err error
continue
}
}
if strings.Contains(errbuf.String(), "not our ref") || strings.Contains(errbuf.String(), "unadvertised object") {
// server-side error: https://github.com/git/git/blob/34b6ce9b30747131b6e781ff718a45328aa887d0/upload-pack.c#L811-L812
// client-side error: https://github.com/git/git/blob/34b6ce9b30747131b6e781ff718a45328aa887d0/fetch-pack.c#L2250-L2253
if newArgs := argsNoCommitRefspec(args); len(args) > len(newArgs) {
args = newArgs
continue
}
}
return buf.Bytes(), errors.Wrapf(err, "git stderr:\n%s", errbuf.String())
}
@ -244,3 +252,19 @@ func argsNoDepth(args []string) []string {
}
return out
}
func argsNoCommitRefspec(args []string) []string {
if len(args) <= 2 {
return args
}
if args[0] != "fetch" {
return args
}
// assume the refspec is the last arg
if IsCommitSHA(args[len(args)-1]) {
return args[:len(args)-1]
}
return args
}

View File

@ -0,0 +1,19 @@
package gitutil
func IsCommitSHA(str string) bool {
if len(str) != 40 {
return false
}
for _, ch := range str {
if ch >= '0' && ch <= '9' {
continue
}
if ch >= 'a' && ch <= 'f' {
continue
}
return false
}
return true
}

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc-gen-go v1.35.1
// protoc v3.11.4
// source: github.com/moby/buildkit/util/stack/stack.proto
@ -34,11 +34,9 @@ type Stack struct {
func (x *Stack) Reset() {
*x = Stack{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Stack) String() string {
@ -49,7 +47,7 @@ func (*Stack) ProtoMessage() {}
func (x *Stack) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -111,11 +109,9 @@ type Frame struct {
func (x *Frame) Reset() {
*x = Frame{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Frame) String() string {
@ -126,7 +122,7 @@ func (*Frame) ProtoMessage() {}
func (x *Frame) ProtoReflect() protoreflect.Message {
mi := &file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -200,7 +196,7 @@ func file_github_com_moby_buildkit_util_stack_stack_proto_rawDescGZIP() []byte {
}
var file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_github_com_moby_buildkit_util_stack_stack_proto_goTypes = []interface{}{
var file_github_com_moby_buildkit_util_stack_stack_proto_goTypes = []any{
(*Stack)(nil), // 0: stack.Stack
(*Frame)(nil), // 1: stack.Frame
}
@ -218,32 +214,6 @@ func file_github_com_moby_buildkit_util_stack_stack_proto_init() {
if File_github_com_moby_buildkit_util_stack_stack_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Stack); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_moby_buildkit_util_stack_stack_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Frame); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -6,6 +6,7 @@ import (
"path"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
"time"
@ -79,8 +80,10 @@ func Copy(ctx context.Context, srcRoot, src, dstRoot, dst string, opts ...Opt) e
if err != nil {
return err
}
if err := MkdirAll(ensureDstPath, 0755, ci.Chown, ci.Utime); err != nil {
if createdDirs, err := MkdirAll(ensureDstPath, 0755, ci.Chown, ci.Utime); err != nil {
return err
} else {
defer fixCreatedParentDirs(createdDirs, ci.Utime)
}
}
@ -120,10 +123,11 @@ func Copy(ctx context.Context, srcRoot, src, dstRoot, dst string, opts ...Opt) e
if err != nil {
return err
}
dst, err := c.prepareTargetDir(srcFollowed, src, dst, ci.CopyDirContents)
dst, createdDirs, err := c.prepareTargetDir(srcFollowed, src, dst, ci.CopyDirContents)
if err != nil {
return err
}
defer fixCreatedParentDirs(createdDirs, ci.Utime)
if err := c.copy(ctx, srcFollowed, "", dst, false, patternmatcher.MatchInfo{}, patternmatcher.MatchInfo{}); err != nil {
return err
}
@ -132,16 +136,16 @@ func Copy(ctx context.Context, srcRoot, src, dstRoot, dst string, opts ...Opt) e
return nil
}
func (c *copier) prepareTargetDir(srcFollowed, src, destPath string, copyDirContents bool) (string, error) {
func (c *copier) prepareTargetDir(srcFollowed, src, destPath string, copyDirContents bool) (string, []string, error) {
fiSrc, err := os.Lstat(srcFollowed)
if err != nil {
return "", err
return "", nil, err
}
fiDest, err := os.Stat(destPath)
if err != nil {
if !os.IsNotExist(err) {
return "", errors.Wrap(err, "failed to lstat destination path")
return "", nil, errors.Wrap(err, "failed to lstat destination path")
}
}
@ -154,11 +158,14 @@ func (c *copier) prepareTargetDir(srcFollowed, src, destPath string, copyDirCont
if copyDirContents && fiSrc.IsDir() && fiDest == nil {
target = destPath
}
if err := MkdirAll(target, 0755, c.chown, c.utime); err != nil {
return "", err
var createdDirs []string
if dirs, err := MkdirAll(target, 0755, c.chown, c.utime); err != nil {
return "", nil, err
} else {
createdDirs = dirs
}
return destPath, nil
return destPath, createdDirs, nil
}
type User struct {
@ -689,3 +696,15 @@ func rel(basepath, targpath string) (string, error) {
}
return filepath.Rel(basepath, targpath)
}
func fixCreatedParentDirs(dirs []string, tm *time.Time) error {
slices.Reverse(dirs)
for _, d := range dirs {
if tm != nil {
if err := Utimes(d, tm); err != nil {
return err
}
}
}
return nil
}

View File

@ -7,14 +7,14 @@ import (
)
// MkdirAll is forked os.MkdirAll
func MkdirAll(path string, perm os.FileMode, user Chowner, tm *time.Time) error {
func MkdirAll(path string, perm os.FileMode, user Chowner, tm *time.Time) ([]string, error) {
// Fast path: if we can tell whether path is a directory or file, stop with success or error.
dir, err := os.Stat(path)
if err == nil {
if dir.IsDir() {
return nil
return nil, nil
}
return &os.PathError{Op: "mkdir", Path: path, Err: syscall.ENOTDIR}
return nil, &os.PathError{Op: "mkdir", Path: path, Err: syscall.ENOTDIR}
}
// Slow path: make sure parent exists and then call Mkdir for path.
@ -28,17 +28,19 @@ func MkdirAll(path string, perm os.FileMode, user Chowner, tm *time.Time) error
j--
}
var createdDirs []string
if j > 1 {
// Create parent.
err = MkdirAll(fixRootDirectory(path[:j-1]), perm, user, tm)
createdDirs, err = MkdirAll(fixRootDirectory(path[:j-1]), perm, user, tm)
if err != nil {
return err
return nil, err
}
}
dir, err1 := os.Lstat(path)
if err1 == nil && dir.IsDir() {
return nil
return createdDirs, nil
}
// Parent now exists; invoke Mkdir and use its result.
@ -48,18 +50,19 @@ func MkdirAll(path string, perm os.FileMode, user Chowner, tm *time.Time) error
// double-checking that directory doesn't exist.
dir, err1 := os.Lstat(path)
if err1 == nil && dir.IsDir() {
return nil
return createdDirs, nil
}
return err
return nil, err
}
createdDirs = append(createdDirs, path)
if err := Chown(path, nil, user); err != nil {
return err
return nil, err
}
if err := Utimes(path, tm); err != nil {
return err
return nil, err
}
return nil
return createdDirs, nil
}