- Notifications
You must be signed in to change notification settings - Fork 794
Description
Expected Behavior
no warning !
and normaly the massage must be ERR and not WARN!
Actual Behavior
when start convertion : WARN Failed to check if the directory is empty: open data: no such file or directory
the directory is not empty, it's containt only one sub directory.
Steps To Reproduce
myservice: image: myimage/myimage restart: always ports: - 5333/tcp volumes: - /data/mydir:/opt/mydirWARN Failed to check if the directory is empty: open data: no such file or directory WARN Skip file in path /data/mydir the /data/mydir is directory, and contain only one subdir... and /data is directory... and the sub directory containe multiple file...
Kompose Version
v1.33.0 and higher it's work fine in v1.32.0 Docker-Compose file
myservice: image: myimage/myimage restart: always ports: - 5333/tcp volumes: - /data/mydir:/opt/mydirAnything else?
i think the problem is in the function checkIsEmptyDir.
they try to recurse the filePath... they found in first a directory data...
but when call recursively checkIsEmptyDir the use relative name data, not the absolute name /data/mydir/data...
they break on first os.ReadDir... but is normal because they try to check data in place of /data/mydir/data.
kompose/pkg/transformer/kubernetes/k8sutils.go
Lines 1265 to 1284 in 9532cee
| // checkIsEmptyDir checks if filepath is empty | |
| func checkIsEmptyDir(filePath string) (bool, error) { | |
| files, err := os.ReadDir(filePath) | |
| if err != nil { | |
| return false, err | |
| } | |
| if len(files) == 0 { | |
| return true, err | |
| } | |
| for _, file := range files { | |
| if !file.IsDir() { | |
| return false, nil | |
| } | |
| _, err := checkIsEmptyDir(file.Name()) | |
| if err != nil { | |
| return false, err | |
| } | |
| } | |
| return true, nil | |
| } |