2022-09-16 18:53:45 +08:00
|
|
|
package cloud_storage
|
|
|
|
|
|
|
|
import (
|
2022-10-17 16:32:31 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/utils/cloud_storage/client"
|
2022-09-16 18:53:45 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type CloudStorageClient interface {
|
|
|
|
ListBuckets() ([]interface{}, error)
|
2023-08-08 16:44:12 +08:00
|
|
|
ListObjects(prefix string) ([]string, error)
|
2022-09-16 18:53:45 +08:00
|
|
|
Exist(path string) (bool, error)
|
|
|
|
Delete(path string) (bool, error)
|
|
|
|
Upload(src, target string) (bool, error)
|
|
|
|
Download(src, target string) (bool, error)
|
|
|
|
}
|
|
|
|
|
2023-06-23 23:06:13 +08:00
|
|
|
func NewCloudStorageClient(backupType string, vars map[string]interface{}) (CloudStorageClient, error) {
|
|
|
|
switch backupType {
|
|
|
|
case constant.S3:
|
2022-09-16 18:53:45 +08:00
|
|
|
return client.NewS3Client(vars)
|
2023-06-23 23:06:13 +08:00
|
|
|
case constant.OSS:
|
2022-09-16 18:53:45 +08:00
|
|
|
return client.NewOssClient(vars)
|
2023-06-23 23:06:13 +08:00
|
|
|
case constant.Sftp:
|
2022-09-16 18:53:45 +08:00
|
|
|
return client.NewSftpClient(vars)
|
2023-06-23 23:06:13 +08:00
|
|
|
case constant.MinIo:
|
2022-09-16 18:53:45 +08:00
|
|
|
return client.NewMinIoClient(vars)
|
2023-06-23 23:06:13 +08:00
|
|
|
case constant.Cos:
|
2023-04-03 18:51:11 +08:00
|
|
|
return client.NewCosClient(vars)
|
2023-06-23 23:06:13 +08:00
|
|
|
case constant.Kodo:
|
2023-04-03 18:51:11 +08:00
|
|
|
return client.NewKodoClient(vars)
|
2023-06-23 23:06:13 +08:00
|
|
|
case constant.OneDrive:
|
|
|
|
return client.NewOneDriveClient(vars)
|
|
|
|
default:
|
|
|
|
return nil, constant.ErrNotSupportType
|
2023-04-03 18:51:11 +08:00
|
|
|
}
|
2022-09-16 18:53:45 +08:00
|
|
|
}
|