feat: driver manage
This commit is contained in:
@ -1,4 +1,13 @@
|
||||
package driver
|
||||
|
||||
type Addition interface {
|
||||
type Additional interface {
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Default string `json:"default"`
|
||||
Values string `json:"values"`
|
||||
Required bool `json:"required"`
|
||||
Desc string `json:"desc"`
|
||||
}
|
||||
|
@ -3,4 +3,6 @@ package driver
|
||||
type Config struct {
|
||||
Name string
|
||||
LocalSort bool
|
||||
OnlyLocal bool
|
||||
OnlyProxy bool
|
||||
}
|
||||
|
@ -6,9 +6,18 @@ import (
|
||||
)
|
||||
|
||||
type Driver interface {
|
||||
Other
|
||||
Reader
|
||||
Writer
|
||||
Other
|
||||
}
|
||||
|
||||
type Other interface {
|
||||
Config() Config
|
||||
Init(ctx context.Context, account model.Account) error
|
||||
Update(ctx context.Context, account model.Account) error
|
||||
Drop(ctx context.Context) error
|
||||
// GetAccount transform additional field to string and assign to account's addition
|
||||
GetAccount() model.Account
|
||||
}
|
||||
|
||||
type Reader interface {
|
||||
@ -25,12 +34,3 @@ type Writer interface {
|
||||
Remove(ctx context.Context, path string) error
|
||||
Put(ctx context.Context, stream FileStream, parentPath string) error
|
||||
}
|
||||
|
||||
type Other interface {
|
||||
Init(ctx context.Context, account model.Account) error
|
||||
Update(ctx context.Context, account model.Account) error
|
||||
Drop(ctx context.Context) error
|
||||
// GetAccount transform additional field to string and assign to account's addition
|
||||
GetAccount() model.Account
|
||||
Config() Config
|
||||
}
|
||||
|
14
internal/driver/manage.go
Normal file
14
internal/driver/manage.go
Normal file
@ -0,0 +1,14 @@
|
||||
package driver
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type New func() Driver
|
||||
|
||||
var driversMap = map[string]New{}
|
||||
|
||||
func RegisterDriver(name string, new New) {
|
||||
log.Infof("register driver: [%s]", name)
|
||||
driversMap[name] = new
|
||||
}
|
1
internal/driver/operations/operate.go
Normal file
1
internal/driver/operations/operate.go
Normal file
@ -0,0 +1 @@
|
||||
package operations
|
@ -7,6 +7,7 @@ type Account struct {
|
||||
Driver string `json:"driver"`
|
||||
Status string `json:"status"`
|
||||
Addition string `json:"addition"`
|
||||
Remark string `json:"remark"`
|
||||
Sort
|
||||
Proxy
|
||||
}
|
||||
|
Reference in New Issue
Block a user