Add plugin tasks (#651)

This commit is contained in:
WithoutPants
2020-08-08 12:05:35 +10:00
committed by GitHub
parent 0874852fa8
commit 0ffefa6e16
47 changed files with 2855 additions and 17 deletions

42
pkg/plugin/convert.go Normal file
View 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
}