Possibility to register app without creating the container
This commit is contained in:
parent
865a9a187e
commit
6d0f6ca130
25
main.go
25
main.go
@ -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,18 +114,20 @@ func main() {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
}
|
||||
|
||||
container := docker.Container{
|
||||
App: &app,
|
||||
}
|
||||
if !registerOnly {
|
||||
container := docker.Container{
|
||||
App: &app,
|
||||
}
|
||||
|
||||
err = container.Create()
|
||||
if err != nil {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
}
|
||||
err = container.Create()
|
||||
if err != nil {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
}
|
||||
|
||||
err = container.Start()
|
||||
if err != nil {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
err = container.Start()
|
||||
if err != nil {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, Message{Message: "ok"})
|
||||
|
Loading…
Reference in New Issue
Block a user