apiActionExecTriggers.go 801 B

123456789101112131415161718192021222324252627
  1. package api
  2. import (
  3. apiv1 "github.com/OliveTin/OliveTin/gen/olivetin/api/v1"
  4. config "github.com/OliveTin/OliveTin/internal/config"
  5. )
  6. func applyActionExecTriggers(pb *apiv1.Action, cfg *config.Action) {
  7. if cfg == nil {
  8. return
  9. }
  10. pb.ExecOnStartup = cfg.ExecOnStartup
  11. pb.ExecOnCron = append([]string(nil), cfg.ExecOnCron...)
  12. pb.ExecOnFileCreatedInDir = append([]string(nil), cfg.ExecOnFileCreatedInDir...)
  13. pb.ExecOnFileChangedInDir = append([]string(nil), cfg.ExecOnFileChangedInDir...)
  14. pb.ExecOnCalendarFile = cfg.ExecOnCalendarFile
  15. for _, wh := range cfg.ExecOnWebhook {
  16. pb.ExecOnWebhooks = append(pb.ExecOnWebhooks, &apiv1.ActionWebhookExecHint{
  17. Template: wh.Template,
  18. MatchPath: wh.MatchPath,
  19. MatchHeaders: wh.MatchHeaders,
  20. MatchQuery: wh.MatchQuery,
  21. })
  22. }
  23. }