mirror of
https://github.com/cuigh/swirl
synced 2024-12-28 14:51:57 +00:00
Fix bug that deploy api cannot create service
This commit is contained in:
parent
16888e54ee
commit
ab550f8748
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
* feat: Refactor UI with vue3.
|
* feat: Refactor UI with vue3.
|
||||||
* feat: Add support to agent. Swirl can connect to any container even in swarm mode now.
|
* feat: Add support to agent. Swirl can connect to any container even in swarm mode now.
|
||||||
|
* feat: Support token authentication.
|
||||||
* feat: Switch to official MongoDB driver.
|
* feat: Switch to official MongoDB driver.
|
||||||
* feat: Allow set chart margins.
|
* feat: Allow set chart margins.
|
||||||
* fix: Some args are incorrect when generating service command line.
|
* fix: Some args are incorrect when generating service command line.
|
||||||
|
@ -60,7 +60,6 @@ web:
|
|||||||
swirl:
|
swirl:
|
||||||
db_type: mongo
|
db_type: mongo
|
||||||
db_address: mongodb://localhost:27017/swirl
|
db_address: mongodb://localhost:27017/swirl
|
||||||
# token_key: 80fe9a6d5c6d5dd39f27cd37a77faf8a
|
|
||||||
# token_expiry: 30m
|
# token_expiry: 30m
|
||||||
# docker_api_version: '1.41'
|
# docker_api_version: '1.41'
|
||||||
# docker_endpoint: tcp://docker-proxy:2375
|
# docker_endpoint: tcp://docker-proxy:2375
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/cuigh/auxo/log"
|
"github.com/cuigh/auxo/log"
|
||||||
"github.com/cuigh/auxo/net/web"
|
"github.com/cuigh/auxo/net/web"
|
||||||
"github.com/cuigh/swirl/biz"
|
"github.com/cuigh/swirl/biz"
|
||||||
"github.com/cuigh/swirl/docker"
|
|
||||||
"github.com/gobwas/ws"
|
"github.com/gobwas/ws"
|
||||||
"github.com/gobwas/ws/wsutil"
|
"github.com/gobwas/ws/wsutil"
|
||||||
)
|
)
|
||||||
@ -72,10 +71,9 @@ func containerFind(b biz.ContainerBiz) web.HandlerFunc {
|
|||||||
id := ctx.Query("id")
|
id := ctx.Query("id")
|
||||||
container, raw, err := b.Find(node, id)
|
container, raw, err := b.Find(node, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if docker.IsErrNotFound(err) {
|
|
||||||
return web.NewError(http.StatusNotFound, err.Error())
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
|
} else if container == nil {
|
||||||
|
return web.NewError(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
return success(ctx, data.Map{"container": container, "raw": raw})
|
return success(ctx, data.Map{"container": container, "raw": raw})
|
||||||
}
|
}
|
||||||
@ -127,9 +125,11 @@ func containerConnect(b biz.ContainerBiz) web.HandlerFunc {
|
|||||||
cmd = ctx.Query("cmd")
|
cmd = ctx.Query("cmd")
|
||||||
)
|
)
|
||||||
|
|
||||||
_, _, err := b.Find(node, id)
|
container, _, err := b.Find(node, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
} else if container == nil {
|
||||||
|
return web.NewError(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, _, _, err := ws.UpgradeHTTP(ctx.Request(), ctx.Response())
|
conn, _, _, err := ws.UpgradeHTTP(ctx.Request(), ctx.Response())
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/cuigh/auxo/data"
|
"github.com/cuigh/auxo/data"
|
||||||
"github.com/cuigh/auxo/net/web"
|
"github.com/cuigh/auxo/net/web"
|
||||||
"github.com/cuigh/swirl/biz"
|
"github.com/cuigh/swirl/biz"
|
||||||
"github.com/cuigh/swirl/docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceHandler encapsulates service related handlers.
|
// ServiceHandler encapsulates service related handlers.
|
||||||
@ -73,10 +72,9 @@ func serviceFind(b biz.ServiceBiz) web.HandlerFunc {
|
|||||||
status := ctx.Query("status") == "true"
|
status := ctx.Query("status") == "true"
|
||||||
service, raw, err := b.Find(name, status)
|
service, raw, err := b.Find(name, status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if docker.IsErrNotFound(err) {
|
|
||||||
return web.NewError(http.StatusNotFound, err.Error())
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
|
} else if service == nil {
|
||||||
|
return web.NewError(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
return success(ctx, data.Map{"service": service, "raw": raw})
|
return success(ctx, data.Map{"service": service, "raw": raw})
|
||||||
}
|
}
|
||||||
@ -153,6 +151,7 @@ func serviceSave(b biz.ServiceBiz) web.HandlerFunc {
|
|||||||
|
|
||||||
func serviceDeploy(b biz.ServiceBiz) web.HandlerFunc {
|
func serviceDeploy(b biz.ServiceBiz) web.HandlerFunc {
|
||||||
return func(ctx web.Context) error {
|
return func(ctx web.Context) error {
|
||||||
|
//mode := ctx.Query("mode") // update/replace
|
||||||
service := &biz.Service{}
|
service := &biz.Service{}
|
||||||
err := ctx.Bind(service, true)
|
err := ctx.Bind(service, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/cuigh/auxo/data"
|
"github.com/cuigh/auxo/data"
|
||||||
"github.com/cuigh/auxo/net/web"
|
"github.com/cuigh/auxo/net/web"
|
||||||
"github.com/cuigh/swirl/biz"
|
"github.com/cuigh/swirl/biz"
|
||||||
"github.com/cuigh/swirl/docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TaskHandler encapsulates node related handlers.
|
// TaskHandler encapsulates node related handlers.
|
||||||
@ -60,10 +59,9 @@ func taskFind(b biz.TaskBiz) web.HandlerFunc {
|
|||||||
id := ctx.Query("id")
|
id := ctx.Query("id")
|
||||||
task, raw, err := b.Find(id)
|
task, raw, err := b.Find(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if docker.IsErrNotFound(err) {
|
|
||||||
return web.NewError(http.StatusNotFound, err.Error())
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
|
} else if task == nil {
|
||||||
|
return web.NewError(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
return success(ctx, data.Map{"task": task, "raw": raw})
|
return success(ctx, data.Map{"task": task, "raw": raw})
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,15 @@ func (b *containerBiz) Find(node, id string) (c *Container, raw string, err erro
|
|||||||
r []byte
|
r []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
if cj, r, err = b.d.ContainerInspect(context.TODO(), node, id); err == nil {
|
cj, r, err = b.d.ContainerInspect(context.TODO(), node, id)
|
||||||
raw, err = indentJSON(r)
|
if err != nil {
|
||||||
|
if docker.IsErrNotFound(err) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if raw, err = indentJSON(r); err == nil {
|
||||||
c = newContainerDetail(&cj)
|
c = newContainerDetail(&cj)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -50,7 +50,15 @@ func (b *serviceBiz) Find(name string, status bool) (service *Service, raw strin
|
|||||||
s swarm.Service
|
s swarm.Service
|
||||||
r []byte
|
r []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
s, r, err = b.d.ServiceInspect(context.TODO(), name, status)
|
s, r, err = b.d.ServiceInspect(context.TODO(), name, status)
|
||||||
|
if err != nil {
|
||||||
|
if docker.IsErrNotFound(err) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
raw, err = indentJSON(r)
|
raw, err = indentJSON(r)
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,14 @@ func (b *taskBiz) Find(id string) (task *Task, raw string, err error) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
t, r, err = b.d.TaskInspect(context.TODO(), id)
|
t, r, err = b.d.TaskInspect(context.TODO(), id)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
raw, err = indentJSON(r)
|
if docker.IsErrNotFound(err) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raw, err = indentJSON(r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
m, _ := b.d.NodeMap()
|
m, _ := b.d.NodeMap()
|
||||||
task = newTask(&t, m)
|
task = newTask(&t, m)
|
||||||
|
Loading…
Reference in New Issue
Block a user