mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Add plugin tasks (#651)
This commit is contained in:
30
pkg/plugin/args.go
Normal file
30
pkg/plugin/args.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
func findArg(args []*models.PluginArgInput, name string) *models.PluginArgInput {
|
||||
for _, v := range args {
|
||||
if v.Key == name {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyDefaultArgs(args []*models.PluginArgInput, defaultArgs map[string]string) []*models.PluginArgInput {
|
||||
for k, v := range defaultArgs {
|
||||
if arg := findArg(args, k); arg == nil {
|
||||
args = append(args, &models.PluginArgInput{
|
||||
Key: k,
|
||||
Value: &models.PluginValueInput{
|
||||
Str: &v,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
Reference in New Issue
Block a user