mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add plugin tasks (#651)
This commit is contained in:
42
pkg/plugin/convert.go
Normal file
42
pkg/plugin/convert.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/plugin/common"
|
||||
)
|
||||
|
||||
func toPluginArgs(args []*models.PluginArgInput) common.ArgsMap {
|
||||
ret := make(common.ArgsMap)
|
||||
for _, a := range args {
|
||||
ret[a.Key] = toPluginArgValue(a.Value)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func toPluginArgValue(arg *models.PluginValueInput) common.PluginArgValue {
|
||||
if arg == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch {
|
||||
case arg.Str != nil:
|
||||
return common.PluginArgValue(*arg.Str)
|
||||
case arg.I != nil:
|
||||
return common.PluginArgValue(*arg.I)
|
||||
case arg.B != nil:
|
||||
return common.PluginArgValue(*arg.B)
|
||||
case arg.F != nil:
|
||||
return common.PluginArgValue(*arg.F)
|
||||
case arg.O != nil:
|
||||
return common.PluginArgValue(toPluginArgs(arg.O))
|
||||
case arg.A != nil:
|
||||
var ret []common.PluginArgValue
|
||||
for _, v := range arg.A {
|
||||
ret = append(ret, toPluginArgValue(v))
|
||||
}
|
||||
return common.PluginArgValue(ret)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user