Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
github.com/google/go-containerregistry v0.19.1
github.com/google/go-github v17.0.0+incompatible
github.com/google/slowjam v1.1.1
github.com/karrick/godirwalk v1.16.1
github.com/minio/highwayhash v1.0.2
github.com/moby/buildkit v0.13.1
github.com/otiai10/copy v1.14.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
Expand Down
49 changes: 20 additions & 29 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/GoogleContainerTools/kaniko/pkg/timing"
"github.com/docker/docker/pkg/archive"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/karrick/godirwalk"
"github.com/moby/buildkit/frontend/dockerfile/dockerignore"
"github.com/moby/patternmatcher"
otiai10Cpy "github.com/otiai10/copy"
Expand Down Expand Up @@ -1262,7 +1261,7 @@ func gowalkDir(dir string, existingPaths map[string]struct{}, changeFunc func(st
foundPaths := make([]string, 0)
deletedFiles := existingPaths // Make a reference.

callback := func(path string, ent *godirwalk.Dirent) error {
callback := func(path string, ent fs.DirEntry, err error) error {
logrus.Tracef("Analyzing path '%s'", path)

if IsInIgnoreList(path) {
Expand All @@ -1285,11 +1284,7 @@ func gowalkDir(dir string, existingPaths map[string]struct{}, changeFunc func(st
return nil
}

godirwalk.Walk(dir,
&godirwalk.Options{
Callback: callback,
Unsorted: true,
})
filesystem.WalkDir(dir, callback)

return walkFSResult{foundPaths, deletedFiles}
}
Expand All @@ -1299,33 +1294,29 @@ func GetFSInfoMap(dir string, existing map[string]os.FileInfo) (map[string]os.Fi
fileMap := map[string]os.FileInfo{}
foundPaths := []string{}
timer := timing.Start("Walking filesystem with Stat")
godirwalk.Walk(dir, &godirwalk.Options{
Callback: func(path string, ent *godirwalk.Dirent) error {
if CheckCleanedPathAgainstIgnoreList(path) {
if IsDestDir(path) {
logrus.Tracef("Skipping paths under %s, as it is a ignored directory", path)
return filepath.SkipDir
}
return nil
filesystem.WalkDir(dir, func(path string, ent fs.DirEntry, err error) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: I didn't add err handling here, surprised at how much err handling is missing but didn't feel like this PR is the right place to add it.

if CheckCleanedPathAgainstIgnoreList(path) {
if IsDestDir(path) {
logrus.Tracef("Skipping paths under %s, as it is a ignored directory", path)
return filepath.SkipDir
}
if fi, err := filesystem.FS.Lstat(path); err == nil {
if fiPrevious, ok := existing[path]; ok {
// check if file changed
if !isSame(fiPrevious, fi) {
fileMap[path] = fi
foundPaths = append(foundPaths, path)
}
} else {
// new path
return nil
}
if fi, err := filesystem.FS.Lstat(path); err == nil {
if fiPrevious, ok := existing[path]; ok {
// check if file changed
if !isSame(fiPrevious, fi) {
fileMap[path] = fi
foundPaths = append(foundPaths, path)
}
} else {
// new path
fileMap[path] = fi
foundPaths = append(foundPaths, path)
}
return nil
},
Unsorted: true,
},
)
}
return nil
})
timing.DefaultRun.Stop(timer)
return fileMap, foundPaths
}
Expand Down
19 changes: 0 additions & 19 deletions vendor/github.com/karrick/godirwalk/.gitignore

This file was deleted.

25 changes: 0 additions & 25 deletions vendor/github.com/karrick/godirwalk/LICENSE

This file was deleted.

Loading