From a1cc42bdb753d1c079afbb06f058a5597d843f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=9A=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 10 Sep 2019 00:44:27 +0200 Subject: [PATCH 1/2] Fix https://github.com/GoogleContainerTools/kaniko/issues/756 --- pkg/util/fs_util.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index d22dcb4aa4..fa7a5db7d2 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -121,6 +121,10 @@ func DeleteFilesystem() error { logrus.Info("Deleting filesystem...") return filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, _ error) error { if CheckWhitelist(path) { + if ! isExist(path) { + logrus.Debugf("Path %s whitelisted, but not exists", path) + return nil + } if info.IsDir() { return filepath.SkipDir } @@ -137,6 +141,13 @@ func DeleteFilesystem() error { return os.RemoveAll(path) }) } +// isExists returns tru if path exists +func isExist(path string) bool { + if _, err := os.Stat(path); err == nil { + return true + } + return false +} // ChildDirInWhitelist returns true if there is a child file or directory of the path in the whitelist func childDirInWhitelist(path string) bool { From a21129f8899260fcc73dc5abd6cebad7d9bbdae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=9A=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 18 Sep 2019 10:43:26 +0200 Subject: [PATCH 2/2] Fix typo and run go fmt over fs_util --- pkg/util/fs_util.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index fa7a5db7d2..81a268c090 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -121,8 +121,8 @@ func DeleteFilesystem() error { logrus.Info("Deleting filesystem...") return filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, _ error) error { if CheckWhitelist(path) { - if ! isExist(path) { - logrus.Debugf("Path %s whitelisted, but not exists", path) + if !isExist(path) { + logrus.Debugf("Path %s whitelisted, but not exists", path) return nil } if info.IsDir() { @@ -141,7 +141,8 @@ func DeleteFilesystem() error { return os.RemoveAll(path) }) } -// isExists returns tru if path exists + +// isExists returns true if path exists func isExist(path string) bool { if _, err := os.Stat(path); err == nil { return true