| @@ -7,6 +7,38 @@ import ( | |||
| "gitlink.org.cn/cloudream/common/utils/serder" | |||
| ) | |||
| type Storage struct { | |||
| StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; autoIncrement;"` | |||
| Name string `json:"name" gorm:"column:Name; not null"` | |||
| // 完全管理此存储服务的Hub的ID | |||
| MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; not null"` | |||
| // 存储服务的地址,包含鉴权所需数据 | |||
| Address StorageAddress `json:"address" gorm:"column:Address; type:json; not null; serializer:union"` | |||
| // 存储服务拥有的特别功能 | |||
| Features []StorageFeature `json:"features" gorm:"column:Features; type:json; serializer:union"` | |||
| } | |||
| func (Storage) TableName() string { | |||
| return "Storage" | |||
| } | |||
| func (s *Storage) String() string { | |||
| return fmt.Sprintf("%v(%v)", s.Name, s.StorageID) | |||
| } | |||
| // 共享存储服务的配置数据 | |||
| type SharedStorage struct { | |||
| StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey"` | |||
| // 调度文件时保存文件的根路径 | |||
| LoadBase string `json:"loadBase" gorm:"column:LoadBase; not null"` | |||
| // 回源数据时数据存放位置的根路径 | |||
| DataReturnBase string `json:"dataReturnBase" gorm:"column:DataReturnBase; not null"` | |||
| } | |||
| func (SharedStorage) TableName() string { | |||
| return "SharedStorage" | |||
| } | |||
| // 存储服务地址 | |||
| type StorageAddress interface { | |||
| GetType() string | |||
| @@ -30,34 +62,53 @@ func (a *LocalStorageAddress) String() string { | |||
| return "Local" | |||
| } | |||
| type Storage struct { | |||
| StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; autoIncrement;"` | |||
| Name string `json:"name" gorm:"column:Name; not null"` | |||
| // 完全管理此存储服务的Hub的ID | |||
| MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; not null"` | |||
| // 存储服务的地址,包含鉴权所需数据 | |||
| Address StorageAddress `json:"address" gorm:"column:Address; type:json; not null; serializer:union"` | |||
| // 存储服务拥有的特别功能 | |||
| Features []StorageFeature `json:"features" gorm:"column:Features; type:json; serializer:union"` | |||
| type OSSAddress struct { | |||
| serder.Metadata `union:"Local"` | |||
| Region string `json:"region"` | |||
| AK string `json:"accessKeyId"` | |||
| SK string `json:"secretAccessKey"` | |||
| Endpoint string `json:"endpoint"` | |||
| Bucket string `json:"bucket"` | |||
| } | |||
| func (Storage) TableName() string { | |||
| return "Storage" | |||
| func (a *OSSAddress) GetType() string { | |||
| return "OSSAddress" | |||
| } | |||
| func (s *Storage) String() string { | |||
| return fmt.Sprintf("%v(%v)", s.Name, s.StorageID) | |||
| func (a *OSSAddress) String() string { | |||
| return "OSSAddress" | |||
| } | |||
| // 共享存储服务的配置数据 | |||
| type SharedStorage struct { | |||
| StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey"` | |||
| // 调度文件时保存文件的根路径 | |||
| LoadBase string `json:"loadBase" gorm:"column:LoadBase; not null"` | |||
| // 回源数据时数据存放位置的根路径 | |||
| DataReturnBase string `json:"dataReturnBase" gorm:"column:DataReturnBase; not null"` | |||
| type OBSAddress struct { | |||
| serder.Metadata `union:"Local"` | |||
| Region string `json:"region"` | |||
| AK string `json:"accessKeyId"` | |||
| SK string `json:"secretAccessKey"` | |||
| Endpoint string `json:"endpoint"` | |||
| Bucket string `json:"bucket"` | |||
| } | |||
| func (SharedStorage) TableName() string { | |||
| return "SharedStorage" | |||
| func (a *OBSAddress) GetType() string { | |||
| return "OBSAddress" | |||
| } | |||
| func (a *OBSAddress) String() string { | |||
| return "OBSAddress" | |||
| } | |||
| type COSAddress struct { | |||
| serder.Metadata `union:"Local"` | |||
| Region string `json:"region"` | |||
| AK string `json:"accessKeyId"` | |||
| SK string `json:"secretAccessKey"` | |||
| Endpoint string `json:"endpoint"` | |||
| Bucket string `json:"bucket"` | |||
| } | |||
| func (a *COSAddress) GetType() string { | |||
| return "COSAddress" | |||
| } | |||
| func (a *COSAddress) String() string { | |||
| return "COSAddress" | |||
| } | |||