-
Notifications
You must be signed in to change notification settings - Fork 405
/
hybrid.go
43 lines (32 loc) · 1.04 KB
/
hybrid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package server
import (
"strings"
"errors"
"fmt"
"net/http"
"github.com/fnproject/fn/api"
"github.com/gin-gonic/gin"
)
// TODO: figure out what to do with this, stale interface from hybrid days but still in use
func (s *Server) handleRunnerGetTriggerBySource(c *gin.Context) {
ctx := c.Request.Context()
appID := c.Param(api.AppID)
triggerType := c.Param(api.TriggerType)
if triggerType == "" {
handleErrorResponse(c, errors.New("no trigger type in request"))
return
}
triggerSource := strings.TrimPrefix(c.Param(api.TriggerSource), "/")
trigger, err := s.datastore.GetTriggerBySource(ctx, appID, triggerType, triggerSource)
if err != nil {
handleErrorResponse(c, err)
return
}
// Not clear that we really need to annotate the trigger here but ... lets do it just in case.
app, err := s.datastore.GetAppByID(ctx, trigger.AppID)
if err != nil {
handleErrorResponse(c, fmt.Errorf("unexpected error - trigger app not available: %s", err))
}
s.triggerAnnotator.AnnotateTrigger(c, app, trigger)
c.JSON(http.StatusOK, trigger)
}