Refactor all mounters to use the mounter interface
This commit is contained in:
parent
093c5bf500
commit
9d5d84ebfb
8 changed files with 204 additions and 157 deletions
pkg/s3
34
pkg/s3/mounter.go
Normal file
34
pkg/s3/mounter.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue