Skip to content

Commit

Permalink
feat: add alert for driver
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 23, 2023
1 parent 0d3146b commit 4be8524
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions cmd/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,19 @@ func writeFile(name string, data interface{}) {
func generateDriversJson() {
drivers := make(Drivers)
drivers["drivers"] = make(KV[interface{}])
drivers["config"] = make(KV[interface{}])
driverInfoMap := op.GetDriverInfoMap()
for k, v := range driverInfoMap {
drivers["drivers"][k] = convert(k)
items := make(KV[interface{}])
config := map[string]string{}
if v.Config.Alert != "" {
alert := strings.SplitN(v.Config.Alert, "|", 2)
if len(alert) > 1 {
config["alert"] = alert[1]
}
}
drivers["config"][k] = config
for i := range v.Additional {
item := v.Additional[i]
items[item.Name] = convert(item.Name)
Expand Down
1 change: 1 addition & 0 deletions drivers/aliyundrive/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Addition struct {
var config = driver.Config{
Name: "Aliyundrive",
DefaultRoot: "root",
Alert: "warning|Deprecated, no longer maintained and will be removed in a future version",
}

func init() {
Expand Down
4 changes: 2 additions & 2 deletions drivers/aliyundrive_open/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type Addition struct {
OrderBy string `json:"order_by" type:"select" options:"name,size,updated_at,created_at"`
OrderDirection string `json:"order_direction" type:"select" options:"ASC,DESC"`
OauthTokenURL string `json:"oauth_token_url" default:"https://api.nn.ci/alist/ali_open/token"`
ClientID string `json:"client_id" required:"false"`
ClientSecret string `json:"client_secret" required:"false"`
ClientID string `json:"client_id" required:"false" help:"Keep it empty if you don't have one"`
ClientSecret string `json:"client_secret" required:"false" help:"Keep it empty if you don't have one"`
}

var config = driver.Config{
Expand Down
3 changes: 2 additions & 1 deletion internal/driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ type Config struct {
NoUpload bool `json:"no_upload"`
NeedMs bool `json:"need_ms"` // if need get message from user, such as validate code
DefaultRoot string `json:"default_root"`
CheckStatus bool
CheckStatus bool `json:"-"`
Alert string `json:"alert"` //info,success,warning,danger
}

func (c Config) MustProxy() bool {
Expand Down

0 comments on commit 4be8524

Please sign in to comment.