mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Implementing force delete for apps
Deployment-Impact: DB schema changed
API Impact: HTTP DELETE /apps/{app} accepts query parameters: /apps/{app}?force=True
Closes: #302
This commit is contained in:
@@ -610,8 +610,9 @@ func (ds *sqlStore) GetLog(ctx context.Context, appName, callID string) (*models
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &models.CallLog{
|
return &models.CallLog{
|
||||||
CallID: callID,
|
CallID: callID,
|
||||||
Log: log,
|
Log: log,
|
||||||
|
AppName: appName,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/fnproject/fn/api/common"
|
"github.com/fnproject/fn/api/common"
|
||||||
"github.com/fnproject/fn/api/models"
|
"github.com/fnproject/fn/api/models"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) handleAppDelete(c *gin.Context) {
|
func (s *Server) handleAppDelete(c *gin.Context) {
|
||||||
@@ -21,10 +22,16 @@ func (s *Server) handleAppDelete(c *gin.Context) {
|
|||||||
handleErrorResponse(c, err)
|
handleErrorResponse(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//TODO allow this? #528
|
forceDelete, _ := strconv.ParseBool(c.Query("force"))
|
||||||
if len(routes) > 0 {
|
if !forceDelete {
|
||||||
handleErrorResponse(c, models.ErrDeleteAppsWithRoutes)
|
if len(routes) > 0 {
|
||||||
return
|
handleErrorResponse(c, models.ErrDeleteAppsWithRoutes)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s.Datastore.BatchDeleteLogs(ctx, app.Name)
|
||||||
|
s.Datastore.BatchDeleteCalls(ctx, app.Name)
|
||||||
|
s.Datastore.BatchDeleteRoutes(ctx, app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.FireBeforeAppDelete(ctx, app)
|
err = s.FireBeforeAppDelete(ctx, app)
|
||||||
|
|||||||
@@ -73,11 +73,17 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- Apps
|
- Apps
|
||||||
parameters:
|
parameters:
|
||||||
- name: app
|
- in: path
|
||||||
in: path
|
name: app
|
||||||
description: Name of the app.
|
description: Name of the app.
|
||||||
required: true
|
required: true
|
||||||
type: string
|
schema:
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: force
|
||||||
|
schema:
|
||||||
|
type: bool
|
||||||
|
description: Query parameter that enables force delete for app
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Apps successfully deleted.
|
description: Apps successfully deleted.
|
||||||
|
|||||||
Reference in New Issue
Block a user