Replace find with native Go code

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira
2021-12-07 10:46:25 +00:00
parent 22dc60e059
commit 77a321a073
3 changed files with 44 additions and 32 deletions

View File

@@ -25,8 +25,8 @@ import (
exec "golang.org/x/sys/execabs"
)
func getVolumeHostPathOwnership(criRoot, containerID string) (string, error) {
hostCmd := fmt.Sprintf("find %s/containers/%s/volumes/* | xargs stat -c %%U:%%G", criRoot, containerID)
func getOwnership(path string) (string, error) {
hostCmd := fmt.Sprintf("stat -c %%U:%%G '%s'", path)
output, err := exec.Command("sh", "-c", hostCmd).CombinedOutput()
if err != nil {
return "", err