2021-07-26 11:51:19 +00:00
|
|
|
package mounter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2021-08-24 10:33:26 +00:00
|
|
|
"github.com/yandex-cloud/k8s-csi-s3/pkg/s3"
|
2021-07-26 11:51:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
geesefsCmd = "geesefs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Implements Mounter
|
|
|
|
type geesefsMounter struct {
|
|
|
|
meta *s3.FSMeta
|
|
|
|
endpoint string
|
|
|
|
region string
|
|
|
|
accessKeyID string
|
|
|
|
secretAccessKey string
|
|
|
|
}
|
|
|
|
|
|
|
|
func newGeeseFSMounter(meta *s3.FSMeta, cfg *s3.Config) (Mounter, error) {
|
|
|
|
return &geesefsMounter{
|
|
|
|
meta: meta,
|
|
|
|
endpoint: cfg.Endpoint,
|
2021-07-27 10:53:34 +00:00
|
|
|
region: cfg.Region,
|
2021-07-26 11:51:19 +00:00
|
|
|
accessKeyID: cfg.AccessKeyID,
|
|
|
|
secretAccessKey: cfg.SecretAccessKey,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (geesefs *geesefsMounter) Stage(stageTarget string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (geesefs *geesefsMounter) Unstage(stageTarget string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (geesefs *geesefsMounter) Mount(source string, target string) error {
|
|
|
|
fullPath := fmt.Sprintf("%s:%s", geesefs.meta.BucketName, geesefs.meta.Prefix)
|
|
|
|
args := []string{
|
|
|
|
"--endpoint", geesefs.endpoint,
|
|
|
|
"-o", "allow_other",
|
2021-09-07 10:37:04 +00:00
|
|
|
"--log-file", "/dev/stderr",
|
|
|
|
}
|
|
|
|
if geesefs.region != "" {
|
|
|
|
args = append(args, "--region", geesefs.region)
|
2021-07-26 11:51:19 +00:00
|
|
|
}
|
|
|
|
args = append(args, geesefs.meta.MountOptions...)
|
2021-07-27 10:49:43 +00:00
|
|
|
args = append(args, fullPath, target)
|
2021-07-26 11:51:19 +00:00
|
|
|
os.Setenv("AWS_ACCESS_KEY_ID", geesefs.accessKeyID)
|
|
|
|
os.Setenv("AWS_SECRET_ACCESS_KEY", geesefs.secretAccessKey)
|
|
|
|
return fuseMount(target, geesefsCmd, args)
|
|
|
|
}
|