Refactor all mounters to use the mounter interface

This commit is contained in:
Cyrill Troxler 2018-07-21 13:35:31 +02:00
parent 093c5bf500
commit 9d5d84ebfb
8 changed files with 204 additions and 157 deletions

34
pkg/s3/mounter.go Normal file
View file

@ -0,0 +1,34 @@
package s3
import "fmt"
// Mounter interface which can be implemented
// by the different mounter types
type Mounter interface {
Format() error
Mount(targetPath string) error
}
const (
mounterKey = "mounter"
s3fsMounterType = "s3fs"
goofysMounterType = "goofys"
s3qlMounterType = "s3ql"
)
// newMounter returns a new mounter depending on the mounterType parameter
func newMounter(mounterType string, bucket string, cfg *Config) (Mounter, error) {
switch mounterType {
case "":
case s3fsMounterType:
return newS3fsMounter(bucket, cfg)
case goofysMounterType:
return newGoofysMounter(bucket, cfg)
case s3qlMounterType:
return newS3qlMounter(bucket, cfg)
}
return nil, fmt.Errorf("Error mounting bucket %s, invalid mounter specified: %s", bucket, mounterType)
}