This repository was archived by the owner on Feb 3, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +11
-27
lines changed
Expand file tree Collapse file tree 4 files changed +11
-27
lines changed Original file line number Diff line number Diff line change 88"golang.org/x/net/context"
99)
1010
11- func (c * Core ) Create (info typings.FunctionInfo ) error {
11+ func (c * Core ) Create (info typings.FunctionInfo ) ( string , error ) {
1212// получаем контейнер
1313//_, err := c.client.ImagePull(
1414// context.Background(),
@@ -30,7 +30,6 @@ func (c *Core) Create(info typings.FunctionInfo) error {
3030},
3131Labels : map [string ]string {
3232"lambda.active" : "true" ,
33- "lambda.uuid" : info .Uuid ,
3433"lambda.port" : "8080" ,
3534},
3635Env : []string {
@@ -51,7 +50,7 @@ func (c *Core) Create(info typings.FunctionInfo) error {
5150nil ,
5251info .Uuid )
5352if err != nil {
54- return err
53+ return "" , err
5554}
5655
5756// запускаем контейнер
@@ -63,5 +62,5 @@ func (c *Core) Create(info typings.FunctionInfo) error {
6362panic (err )
6463}
6564
66- return nil
65+ return resp . ID , nil
6766}
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ func createHandler(m manager.Core) gin.HandlerFunc {
2121return
2222}
2323
24- if err := m .Create (body ); err != nil {
24+ uuid , err := m .Create (body )
25+ if err != nil {
2526c .JSON (http .StatusBadRequest , gin.H {
2627"error" : err .Error (),
2728})
@@ -30,7 +31,7 @@ func createHandler(m manager.Core) gin.HandlerFunc {
3031}
3132
3233c .JSON (200 , gin.H {
33- "message " : "ok" ,
34+ "uuid " : uuid ,
3435})
3536}
3637}
Original file line number Diff line number Diff line change @@ -11,29 +11,13 @@ func deleteHandler(m manager.Core) gin.HandlerFunc {
1111return func (c * gin.Context ) {
1212uuid := c .Param ("uuid" )
1313
14- containers , err := m .GetActive ()
15- if err != nil {
14+ if err := m .Stop ( uuid ); err != nil {
15+ log . Println ( err )
1616c .JSON (http .StatusInternalServerError , gin.H {
17- "error" : err . Error () ,
17+ "error" : "function uuid not founded" ,
1818})
19- log .Println (err )
20- return
2119}
2220
23- for _ , cont := range containers {
24- for _ , name := range cont .Names {
25- // fix docker name
26- if name == "/" + uuid {
27- if err := m .Stop (cont .ID ); err != nil {
28- log .Println (err )
29- c .JSON (http .StatusInternalServerError , gin.H {
30- "error" : err .Error (),
31- })
32- }
33-
34- c .JSON (http .StatusOK , gin.H {})
35- }
36- }
37- }
21+ c .JSON (http .StatusOK , gin.H {})
3822}
3923}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package typings
22
33type FunctionInfo struct {
44Name string `json:"name" binding:"required"`
5- Uuid string `json:"uuid" binding:"required" `
5+ Uuid string `json:"uuid"`
66Runtime struct {
77Executor string `json:"executor" binding:"required"`
88Cmd string `json:"cmd"`
You can’t perform that action at this time.
0 commit comments