remove cruft and unneeded loop
This commit is contained in:
parent
01f6aba517
commit
965b606720
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/filesystem"
|
"github.com/GoogleContainerTools/kaniko/pkg/filesystem"
|
||||||
|
|
@ -136,18 +135,23 @@ func (s *Snapshotter) scanFullFilesystem() ([]string, []string, error) {
|
||||||
s.l.Snapshot()
|
s.l.Snapshot()
|
||||||
|
|
||||||
timer := timing.Start("Walking filesystem")
|
timer := timing.Start("Walking filesystem")
|
||||||
// Save the fs state in a map to iterate over later.
|
|
||||||
memFs := map[string]*godirwalk.Dirent{}
|
foundPaths := make([]string, 0)
|
||||||
|
|
||||||
godirwalk.Walk(s.directory, &godirwalk.Options{
|
godirwalk.Walk(s.directory, &godirwalk.Options{
|
||||||
Callback: func(path string, ent *godirwalk.Dirent) error {
|
Callback: func(path string, ent *godirwalk.Dirent) error {
|
||||||
if util.IsInWhitelist(path) {
|
if util.IsInWhitelist(path) {
|
||||||
if util.IsDestDir(path) {
|
if util.IsDestDir(path) {
|
||||||
logrus.Tracef("Skipping paths under %s, as it is a whitelisted directory", path)
|
logrus.Tracef("Skipping paths under %s, as it is a whitelisted directory", path)
|
||||||
|
|
||||||
return filepath.SkipDir
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
memFs[path] = ent
|
|
||||||
|
foundPaths = append(foundPaths, path)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Unsorted: true,
|
Unsorted: true,
|
||||||
|
|
@ -155,24 +159,13 @@ func (s *Snapshotter) scanFullFilesystem() ([]string, []string, error) {
|
||||||
)
|
)
|
||||||
timing.DefaultRun.Stop(timer)
|
timing.DefaultRun.Stop(timer)
|
||||||
|
|
||||||
filesToResolve := make([]string, 0, len(memFs))
|
resolvedFiles, err := filesystem.ResolvePaths(foundPaths, s.whitelist)
|
||||||
for file := range memFs {
|
|
||||||
if strings.HasPrefix(file, "/tmp/dir") {
|
|
||||||
logrus.Infof("found %s", file)
|
|
||||||
}
|
|
||||||
filesToResolve = append(filesToResolve, file)
|
|
||||||
}
|
|
||||||
|
|
||||||
resolvedFiles, err := filesystem.ResolvePaths(filesToResolve, s.whitelist)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvedMemFs := make(map[string]bool)
|
resolvedMemFs := make(map[string]bool)
|
||||||
for _, f := range resolvedFiles {
|
for _, f := range resolvedFiles {
|
||||||
if strings.HasPrefix(f, "/tmp/dir") {
|
|
||||||
logrus.Infof("found again %s", f)
|
|
||||||
}
|
|
||||||
resolvedMemFs[f] = true
|
resolvedMemFs[f] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,14 +64,6 @@ func TestSnapshotFSFileChange(t *testing.T) {
|
||||||
batPath: "baz",
|
batPath: "baz",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Their parents didn't change so they shouldn't be included
|
|
||||||
//for _, dir := range util.ParentDirectoriesWithoutLeadingSlash(fooPath) {
|
|
||||||
// snapshotFiles[dir] = ""
|
|
||||||
//}
|
|
||||||
//for _, dir := range util.ParentDirectoriesWithoutLeadingSlash(batPath) {
|
|
||||||
// snapshotFiles[dir] = ""
|
|
||||||
//}
|
|
||||||
|
|
||||||
actualFiles := []string{}
|
actualFiles := []string{}
|
||||||
for {
|
for {
|
||||||
hdr, err := tr.Next()
|
hdr, err := tr.Next()
|
||||||
|
|
@ -161,11 +153,6 @@ func TestSnapshotFSChangePermissions(t *testing.T) {
|
||||||
batPathWithoutLeadingSlash: "baz2",
|
batPathWithoutLeadingSlash: "baz2",
|
||||||
}
|
}
|
||||||
|
|
||||||
// The parents haven't changed so they shouldn't be in the tar
|
|
||||||
//for _, dir := range util.ParentDirectoriesWithoutLeadingSlash(batPath) {
|
|
||||||
// snapshotFiles[dir] = ""
|
|
||||||
//}
|
|
||||||
|
|
||||||
foundFiles := []string{}
|
foundFiles := []string{}
|
||||||
for {
|
for {
|
||||||
hdr, err := tr.Next()
|
hdr, err := tr.Next()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue