Possibility to register app without creating the container

This commit is contained in:
Adam Štrauch 2020-08-18 22:48:09 +02:00
parent 865a9a187e
commit 6d0f6ca130
Signed by: cx
GPG Key ID: 018304FFA8988F8D

View File

@ -96,7 +96,10 @@ func main() {
})
// Create a new app
// If you add register=1 into query string, it won't start or create any container, just adds record into the database.
e.POST("/v1/apps", func(c echo.Context) error {
registerOnly := c.QueryParam("register") == "1"
app := apps.App{}
err := c.Bind(&app)
if err != nil {
@ -111,6 +114,7 @@ func main() {
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
}
if !registerOnly {
container := docker.Container{
App: &app,
}
@ -124,6 +128,7 @@ func main() {
if err != nil {
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
}
}
return c.JSON(http.StatusOK, Message{Message: "ok"})
})