stash/pkg/plugin/args.go

32 lines
630 B
Go
Raw Normal View History

2020-08-08 02:05:35 +00:00
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 {
v := v // Copy v, because it's being exported out of the loop
2020-08-08 02:05:35 +00:00
args = append(args, &models.PluginArgInput{
Key: k,
Value: &models.PluginValueInput{
Str: &v,
},
})
}
}
return args
}