vendor: github.com/moby/buildkit v0.21.0-rc1

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
Jonathan A. Sternberg
2025-04-09 10:28:03 -05:00
parent a34cdff84e
commit 8fb1157b5f
221 changed files with 6530 additions and 3986 deletions

View File

@@ -262,8 +262,10 @@ func ParseWithUmask(s string, umask uint) (Set, error) {
case 'w':
perm |= iWUser | iWGroup | iWOther
case 'X':
if op == '+' {
if op != '-' {
permX = iXUser | iXGroup | iXOther
} else {
perm |= iXUser | iXGroup | iXOther
}
case 'x':
perm |= iXUser | iXGroup | iXOther

View File

@@ -18,6 +18,8 @@ import (
"github.com/tonistiigi/fsutil"
)
const defaultDirectoryMode = 0755
var bufferPool = &sync.Pool{
New: func() interface{} {
buffer := make([]byte, 32*1024)
@@ -80,7 +82,11 @@ func Copy(ctx context.Context, srcRoot, src, dstRoot, dst string, opts ...Opt) e
if err != nil {
return err
}
if createdDirs, err := MkdirAll(ensureDstPath, 0755, ci.Chown, ci.Utime); err != nil {
perm := defaultDirectoryMode
if ci.Mode != nil {
perm = *ci.Mode
}
if createdDirs, err := MkdirAll(ensureDstPath, os.FileMode(perm), ci.Chown, ci.Utime); err != nil {
return err
} else {
defer fixCreatedParentDirs(createdDirs, ci.Utime)
@@ -159,7 +165,11 @@ func (c *copier) prepareTargetDir(srcFollowed, src, destPath string, copyDirCont
target = destPath
}
var createdDirs []string
if dirs, err := MkdirAll(target, 0755, c.chown, c.utime); err != nil {
mode := defaultDirectoryMode
if c.mode != nil {
mode = *c.mode
}
if dirs, err := MkdirAll(target, os.FileMode(mode), c.chown, c.utime); err != nil {
return "", nil, err
} else {
createdDirs = dirs
@@ -335,13 +345,13 @@ func (c *copier) copy(ctx context.Context, src, srcComponents, target string, ov
if srcComponents != "" {
matchesIncludePattern := false
matchesExcludePattern := false
matchesIncludePattern, includeMatchInfo, err = c.include(srcComponents, fi, parentIncludeMatchInfo)
matchesIncludePattern, includeMatchInfo, err = c.include(srcComponents, parentIncludeMatchInfo)
if err != nil {
return err
}
include = matchesIncludePattern
matchesExcludePattern, excludeMatchInfo, err = c.exclude(srcComponents, fi, parentExcludeMatchInfo)
matchesExcludePattern, excludeMatchInfo, err = c.exclude(srcComponents, parentExcludeMatchInfo)
if err != nil {
return err
}
@@ -351,11 +361,11 @@ func (c *copier) copy(ctx context.Context, src, srcComponents, target string, ov
}
if include {
if err := c.removeTargetIfNeeded(src, target, fi, targetFi); err != nil {
if err := c.removeTargetIfNeeded(target, fi, targetFi); err != nil {
return err
}
if err := c.createParentDirs(src, srcComponents, target, overwriteTargetMetadata); err != nil {
if err := c.createParentDirs(src, overwriteTargetMetadata); err != nil {
return err
}
}
@@ -447,7 +457,7 @@ func (c *copier) notifyChange(target string, fi os.FileInfo) error {
return nil
}
func (c *copier) include(path string, fi os.FileInfo, parentIncludeMatchInfo patternmatcher.MatchInfo) (bool, patternmatcher.MatchInfo, error) {
func (c *copier) include(path string, parentIncludeMatchInfo patternmatcher.MatchInfo) (bool, patternmatcher.MatchInfo, error) {
if c.includePatternMatcher == nil {
return true, patternmatcher.MatchInfo{}, nil
}
@@ -459,7 +469,7 @@ func (c *copier) include(path string, fi os.FileInfo, parentIncludeMatchInfo pat
return m, matchInfo, nil
}
func (c *copier) exclude(path string, fi os.FileInfo, parentExcludeMatchInfo patternmatcher.MatchInfo) (bool, patternmatcher.MatchInfo, error) {
func (c *copier) exclude(path string, parentExcludeMatchInfo patternmatcher.MatchInfo) (bool, patternmatcher.MatchInfo, error) {
if c.excludePatternMatcher == nil {
return false, patternmatcher.MatchInfo{}, nil
}
@@ -471,7 +481,7 @@ func (c *copier) exclude(path string, fi os.FileInfo, parentExcludeMatchInfo pat
return m, matchInfo, nil
}
func (c *copier) removeTargetIfNeeded(src, target string, srcFi, targetFi os.FileInfo) error {
func (c *copier) removeTargetIfNeeded(target string, srcFi, targetFi os.FileInfo) error {
if !c.alwaysReplaceExistingDestPaths {
return nil
}
@@ -488,7 +498,7 @@ func (c *copier) removeTargetIfNeeded(src, target string, srcFi, targetFi os.Fil
// Delayed creation of parent directories when a file or dir matches an include
// pattern.
func (c *copier) createParentDirs(src, srcComponents, target string, overwriteTargetMetadata bool) error {
func (c *copier) createParentDirs(src string, overwriteTargetMetadata bool) error {
for i, parentDir := range c.parentDirs {
if parentDir.copied {
continue
@@ -502,7 +512,7 @@ func (c *copier) createParentDirs(src, srcComponents, target string, overwriteTa
return errors.Errorf("%s is not a directory", parentDir.srcPath)
}
created, err := copyDirectoryOnly(parentDir.srcPath, parentDir.dstPath, fi, overwriteTargetMetadata)
created, err := copyDirectoryOnly(parentDir.dstPath, fi, overwriteTargetMetadata)
if err != nil {
return err
}
@@ -549,7 +559,7 @@ func (c *copier) copyDirectory(
// encounter a/b/c.
if include {
var err error
created, err = copyDirectoryOnly(src, dst, stat, overwriteTargetMetadata)
created, err = copyDirectoryOnly(dst, stat, overwriteTargetMetadata)
if err != nil {
return created, err
}
@@ -586,7 +596,7 @@ func (c *copier) copyDirectory(
return created, nil
}
func copyDirectoryOnly(src, dst string, stat os.FileInfo, overwriteTargetMetadata bool) (bool, error) {
func copyDirectoryOnly(dst string, stat os.FileInfo, overwriteTargetMetadata bool) (bool, error) {
if st, err := os.Lstat(dst); err != nil {
if !os.IsNotExist(err) {
return false, err

View File

@@ -15,7 +15,7 @@ func getUIDGID(fi os.FileInfo) (uid, gid int) {
return int(st.Uid), int(st.Gid)
}
func (c *copier) copyFileInfo(fi os.FileInfo, src, name string) error {
func (c *copier) copyFileInfo(fi os.FileInfo, _, name string) error {
chown := c.chown
uid, gid := getUIDGID(fi)
old := &User{UID: uid, GID: gid}

View File

@@ -16,7 +16,7 @@ func getUIDGID(fi os.FileInfo) (uid, gid int) {
return int(st.Uid), int(st.Gid)
}
func (c *copier) copyFileInfo(fi os.FileInfo, src, name string) error {
func (c *copier) copyFileInfo(fi os.FileInfo, _, name string) error {
chown := c.chown
uid, gid := getUIDGID(fi)
old := &User{UID: uid, GID: gid}

View File

@@ -13,7 +13,7 @@ const (
seTakeOwnershipPrivilege = "SeTakeOwnershipPrivilege"
)
func getUIDGID(fi os.FileInfo) (uid, gid int) {
func getUIDGID(_ os.FileInfo) (uid, gid int) {
return 0, 0
}
@@ -119,10 +119,10 @@ func copyFileContent(dst, src *os.File) error {
return err
}
func copyXAttrs(dst, src string, xeh XAttrErrorHandler) error {
func copyXAttrs(_, _ string, _ XAttrErrorHandler) error {
return nil
}
func copyDevice(dst string, fi os.FileInfo) error {
func copyDevice(_ string, _ os.FileInfo) error {
return errors.New("device copy not supported")
}

View File

@@ -2,6 +2,6 @@ package fs
import "os"
func getLinkInfo(fi os.FileInfo) (uint64, bool) {
func getLinkInfo(_ os.FileInfo) (uint64, bool) {
return 0, false
}

View File

@@ -20,7 +20,7 @@ func rewriteMetadata(p string, stat *types.Stat) error {
// handleTarTypeBlockCharFifo is an OS-specific helper function used by
// createTarFile to handle the following types of header: Block; Char; Fifo
func handleTarTypeBlockCharFifo(path string, stat *types.Stat) error {
func handleTarTypeBlockCharFifo(_ string, _ *types.Stat) error {
return errors.New("Not implemented on windows")
}

View File

@@ -60,7 +60,15 @@ target "test-noroot" {
output = ["${DESTDIR}/coverage"]
}
target "lint" {
group "lint" {
targets = ["lint-golangci", "lint-gopls"]
}
group "lint-cross" {
targets = ["lint-golangci-cross", "lint-gopls-cross"]
}
target "lint-golangci" {
inherits = ["_common"]
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
output = ["type=cacheonly"]
@@ -69,8 +77,17 @@ target "lint" {
}
}
target "lint-cross" {
inherits = ["lint", "_platforms"]
target "lint-gopls" {
inherits = ["lint-golangci"]
target = "gopls-analyze"
}
target "lint-golangci-cross" {
inherits = ["lint-golangci", "_platforms"]
}
target "lint-gopls-cross" {
inherits = ["lint-gopls", "_platforms"]
}
target "validate-generated-files" {