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