Use goofys binary

This commit is contained in:
Vitaliy Filippov 2021-07-16 16:29:44 +03:00
parent d78d476d6d
commit 63a2ab3476

View file

@ -4,12 +4,8 @@ import (
"fmt"
"os"
"path"
"strings"
"context"
"github.com/ctrox/csi-s3/pkg/s3"
goofysApi "github.com/kahing/goofys/api"
)
const (
@ -50,37 +46,15 @@ func (goofys *goofysMounter) Unstage(stageTarget string) error {
}
func (goofys *goofysMounter) Mount(source string, target string) error {
mountOptions := make(map[string]string)
for _, opt := range goofys.meta.MountOptions {
s := 0
if len(opt) >= 2 && opt[0] == '-' && opt[1] == byte('-') {
s = 2
}
p := strings.Index(opt, "=")
if p > 0 {
mountOptions[string(opt[s : p])] = string(opt[p : ])
} else {
mountOptions[string(opt[s : ])] = ""
}
fullPath := fmt.Sprintf("%s:%s", goofys.meta.BucketName, path.Join(goofys.meta.Prefix, goofys.meta.FSPath))
args := []string{
"--endpoint", goofys.endpoint,
"--region", goofys.region,
"-o", "allow_other",
fullPath, target,
}
mountOptions["allow_other"] = ""
goofysCfg := &goofysApi.Config{
MountPoint: target,
Endpoint: goofys.endpoint,
Region: goofys.region,
DirMode: 0755,
FileMode: 0644,
MountOptions: mountOptions,
}
args = append(args, goofys.meta.MountOptions...)
os.Setenv("AWS_ACCESS_KEY_ID", goofys.accessKeyID)
os.Setenv("AWS_SECRET_ACCESS_KEY", goofys.secretAccessKey)
fullPath := fmt.Sprintf("%s:%s", goofys.meta.BucketName, path.Join(goofys.meta.Prefix, goofys.meta.FSPath))
_, _, err := goofysApi.Mount(context.Background(), fullPath, goofysCfg)
if err != nil {
return fmt.Errorf("Error mounting via goofys: %s", err)
}
return nil
return fuseMount(target, goofysCmd, args)
}