-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
50 lines (35 loc) · 1.12 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package objectstorage
import (
"fmt"
"io"
"net/http"
"github.com/toastate/toastainer/internal/config"
localfs "github.com/toastate/toastainer/internal/db/objectstorage/fs"
"github.com/toastate/toastainer/internal/db/objectstorage/s3"
)
var Client interface {
DownloadFileInto(w http.ResponseWriter, remotePath string) error
PushReader(f io.Reader, destPath string) error
Get(remotePath string) ([]byte, error)
PushFolderTar(folder, destPath string) error
PullFolderTar(remotePath, destination string) error
PullFolderTarWithProgressBar(remotePath, destination string) error
UploadFolder(folder, dest string) error
Exists(remotePath string) (bool, error)
DeleteFolder(folder string) error
}
func Init() error {
var err error
switch config.ObjectStorage.Name {
case "awss3":
Client, err = s3.NewHandler()
case "localfs":
if config.NodeDiscovery {
return fmt.Errorf("you cannot use local filesystem for objectstorage when in a multi-node architecture")
}
Client, err = localfs.NewHandler()
default:
return fmt.Errorf("not yet supported object storage: %s", config.ObjectStorage.Name)
}
return err
}