vendor: update buildkit to opentelemetry support

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2021-06-15 21:02:39 -07:00
parent 6ba080d337
commit 334c93fbbe
829 changed files with 89541 additions and 24438 deletions

View File

@ -1,7 +1,9 @@
package fsutil
import (
"bytes"
"context"
"io"
"os"
"strings"
@ -35,6 +37,8 @@ const (
// computed during a directory changes calculation.
type ChangeFunc func(ChangeKind, string, os.FileInfo, error) error
const compareChunkSize = 32 * 1024
type currentPath struct {
path string
stat *types.Stat
@ -42,7 +46,7 @@ type currentPath struct {
}
// doubleWalkDiff walks both directories to create a diff
func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b walkerFn, filter FilterFunc) (err error) {
func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b walkerFn, filter FilterFunc, differ DiffType) (err error) {
g, ctx := errgroup.WithContext(ctx)
var (
@ -116,7 +120,7 @@ func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b walkerFn, fil
}
f1 = nil
case ChangeKindModify:
same, err := sameFile(f1, f2copy)
same, err := sameFile(f1, f2copy, differ)
if err != nil {
return err
}
@ -165,7 +169,10 @@ func pathChange(lower, upper *currentPath) (ChangeKind, string) {
}
}
func sameFile(f1, f2 *currentPath) (same bool, retErr error) {
func sameFile(f1, f2 *currentPath, differ DiffType) (same bool, retErr error) {
if differ == DiffNone {
return false, nil
}
// If not a directory also check size, modtime, and content
if !f1.stat.IsDir() {
if f1.stat.Size_ != f2.stat.Size_ {
@ -177,7 +184,43 @@ func sameFile(f1, f2 *currentPath) (same bool, retErr error) {
}
}
return compareStat(f1.stat, f2.stat)
same, err := compareStat(f1.stat, f2.stat)
if err != nil || !same || differ == DiffMetadata {
return same, err
}
return compareFileContent(f1.path, f2.path)
}
func compareFileContent(p1, p2 string) (bool, error) {
f1, err := os.Open(p1)
if err != nil {
return false, err
}
defer f1.Close()
f2, err := os.Open(p2)
if err != nil {
return false, err
}
defer f2.Close()
b1 := make([]byte, compareChunkSize)
b2 := make([]byte, compareChunkSize)
for {
n1, err1 := f1.Read(b1)
if err1 != nil && err1 != io.EOF {
return false, err1
}
n2, err2 := f2.Read(b2)
if err2 != nil && err2 != io.EOF {
return false, err2
}
if n1 != n2 || !bytes.Equal(b1[:n1], b2[:n2]) {
return false, nil
}
if err1 == io.EOF && err2 == io.EOF {
return true, nil
}
}
}
// compareStat returns whether the stats are equivalent,