Skip to content

Commit 87227b7

Browse files
committed
simplify
1 parent 4e26e84 commit 87227b7

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

pkg/transformer/kubernetes/k8sutils.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,20 +1267,6 @@ func isConfigFile(filePath string) (useConfigMap bool, readonly bool, skip bool)
12671267
// checkIsEmptyDir checks if filepath is empty
12681268
func checkIsEmptyDir(filePath string) (bool, error) {
12691269
log.Debugf("checkIsEmptyDir of File : %v", filePath)
1270-
var dirFilePath string = ""
1271-
fi, err := os.Stat(filePath)
1272-
if errors.Is(err, os.ErrNotExist) {
1273-
log.Errorf("filePath %v does not exist!", filePath)
1274-
return false, err
1275-
}
1276-
mode := fi.Mode()
1277-
if mode.IsDir() {
1278-
dirFilePath = filePath
1279-
log.Debugf("filePath %v is directory!", dirFilePath)
1280-
} else {
1281-
dirFilePath = filepath.Dir(filePath)
1282-
log.Debugf("dirname of filePath is %v !", dirFilePath)
1283-
}
12841270
files, err := os.ReadDir(filePath)
12851271
if err != nil {
12861272
log.Errorf("ReadDir of %v failed !",filePath);
@@ -1297,7 +1283,8 @@ func checkIsEmptyDir(filePath string) (bool, error) {
12971283
// not empty
12981284
return false, nil
12991285
}
1300-
_, err := checkIsEmptyDir(filepath.Join(dirFilePath,file.Name()))
1286+
// recurse directory
1287+
_, err := checkIsEmptyDir(filepath.Join(filePath,file.Name()))
13011288
if err != nil {
13021289
log.Debugf("Recursive checkIsEmptyDir return err %v for %v !",err, file);
13031290
return false, err

0 commit comments

Comments
 (0)