Add support for Function and Trigger domain objects (#1060)

Vast commit, includes:

 * Introduces the Trigger domain entity.
 * Introduces the Fns domain entity.
 * V2 of the API for interacting with the new entities in swaggerv2.yml
 * Adds v2 end points for Apps to support PUT updates.
 * Rewrites the datastore level tests into a new pattern.
 * V2 routes use entity ID over name as the path parameter.
This commit is contained in:
Tom Coupland
2018-06-25 15:37:06 +01:00
committed by GitHub
parent a5abecaafb
commit 3ebff051a4
76 changed files with 5820 additions and 892 deletions

View File

@@ -61,8 +61,8 @@ func traceWrap(c *gin.Context) {
logrus.Fatal(err)
}
ctx, err := tag.New(c.Request.Context(),
tag.Insert(appKey, c.Param(api.CApp)),
tag.Insert(pathKey, c.Param(api.CRoute)),
tag.Insert(appKey, c.Param(api.ParamAppName)),
tag.Insert(pathKey, c.Param(api.ParamRouteName)),
)
if err != nil {
logrus.Fatal(err)
@@ -133,7 +133,7 @@ func panicWrap(c *gin.Context) {
if !ok {
err = fmt.Errorf("fn: %v", rec)
}
handleErrorResponse(c, err)
handleV1ErrorResponse(c, err)
c.Abort()
}
}(c)
@@ -143,12 +143,12 @@ func panicWrap(c *gin.Context) {
func loggerWrap(c *gin.Context) {
ctx, _ := common.LoggerWithFields(c.Request.Context(), extractFields(c))
if appName := c.Param(api.CApp); appName != "" {
c.Set(api.App, appName)
ctx = context.WithValue(ctx, api.App, appName)
if appName := c.Param(api.ParamAppName); appName != "" {
c.Set(api.AppName, appName)
ctx = context.WithValue(ctx, api.AppName, appName)
}
if routePath := c.Param(api.CRoute); routePath != "" {
if routePath := c.Param(api.ParamRouteName); routePath != "" {
c.Set(api.Path, routePath)
ctx = context.WithValue(ctx, api.Path, routePath)
}
@@ -161,11 +161,11 @@ func (s *Server) checkAppPresenceByNameAtRunner() gin.HandlerFunc {
return func(c *gin.Context) {
ctx, _ := common.LoggerWithFields(c.Request.Context(), extractFields(c))
appName := c.Param(api.CApp)
appName := c.Param(api.ParamAppName)
if appName != "" {
appID, err := s.agent.GetAppID(ctx, appName)
if err != nil {
handleErrorResponse(c, err)
handleV1ErrorResponse(c, err)
c.Abort()
return
}
@@ -181,11 +181,11 @@ func (s *Server) checkAppPresenceByName() gin.HandlerFunc {
return func(c *gin.Context) {
ctx, _ := common.LoggerWithFields(c.Request.Context(), extractFields(c))
appName := c.MustGet(api.App).(string)
appName := c.MustGet(api.AppName).(string)
if appName != "" {
appID, err := s.datastore.GetAppID(ctx, appName)
if err != nil {
handleErrorResponse(c, err)
handleV1ErrorResponse(c, err)
c.Abort()
return
}
@@ -199,17 +199,28 @@ func (s *Server) checkAppPresenceByName() gin.HandlerFunc {
func setAppNameInCtx(c *gin.Context) {
// add appName to context
appName := c.GetString(api.App)
appName := c.GetString(api.AppName)
if appName != "" {
c.Request = c.Request.WithContext(context.WithValue(c.Request.Context(), fnext.AppNameKey, appName))
}
c.Next()
}
func setAppIDInCtx(c *gin.Context) {
// add appName to context
appID := c.Param(api.ParamAppID)
if appID != "" {
c.Set(api.AppID, appID)
c.Request = c.Request.WithContext(c)
}
c.Next()
}
func appNameCheck(c *gin.Context) {
appName := c.GetString(api.App)
appName := c.GetString(api.AppName)
if appName == "" {
handleErrorResponse(c, models.ErrAppsMissingName)
handleV1ErrorResponse(c, models.ErrAppsMissingName)
c.Abort()
return
}