diff --git a/config/i18n/en.yml b/config/i18n/en.yml index aa1c148..2ae303c 100644 --- a/config/i18n/en.yml +++ b/config/i18n/en.yml @@ -120,6 +120,7 @@ network.description: Networks are user-defined networks that containers can be a # service pages service.title: Service service.description: Services are the definitions of tasks to run on a swarm. +service.edit.warning: "NOTE: This service belong to '%s' stack, usually you should modify original compose instead of updating it directly." # service template pages service.template.title: Service Template diff --git a/config/i18n/zh.yml b/config/i18n/zh.yml index 0cf3e2d..156ebef 100644 --- a/config/i18n/zh.yml +++ b/config/i18n/zh.yml @@ -120,6 +120,7 @@ network.description: 能够连接到容器的 Docker 预置和用户自定义的 # service pages service.title: 服务 service.description: 服务是在 Swarm 集群中运行的任务定义。 +service.edit.warning: "注意: 这个服务属于编排 %s,通常你应该修改原始的编排而不是直接修改此服务信息,否则后续重新部署编排时这些修改将会丢失。" # service template pages service.template.title: 服务模板 diff --git a/controller/service.go b/controller/service.go index 6fcb0df..2ad0329 100644 --- a/controller/service.go +++ b/controller/service.go @@ -222,9 +222,10 @@ func serviceEdit(ctx web.Context) error { return err } + stack := service.Spec.Labels["com.docker.stack.namespace"] checkedNetworks := set.FromSlice(service.Endpoint.VirtualIPs, func(i int) interface{} { return service.Endpoint.VirtualIPs[i].NetworkID }) - m := newModel(ctx).Add("Service", model.NewServiceInfo(service)). + m := newModel(ctx).Add("Service", model.NewServiceInfo(service)).Add("Stack", stack). Add("Networks", networks).Add("CheckedNetworks", checkedNetworks). Add("Secrets", secrets).Add("Configs", configs) return ctx.Render("service/edit", m) diff --git a/misc/util.go b/misc/util.go index 5feab07..b6ce831 100644 --- a/misc/util.go +++ b/misc/util.go @@ -53,7 +53,10 @@ func Message(lang string) func(key string, args ...interface{}) string { } return func(key string, args ...interface{}) string { - return t.Format(key, args...) + if s := t.Format(key, args...); s != "" { + return s + } + return "[" + key + "]" } } diff --git a/views/service/edit.jet b/views/service/edit.jet index cab00c4..c2dfa9d 100644 --- a/views/service/edit.jet +++ b/views/service/edit.jet @@ -64,6 +64,9 @@ {{ yield form_others() }} {{ yield form_submit(url="/service/") }} + {{ if .Stack }} +
{{ i18n("service.edit.warning", .Stack) }}
+ {{ end }} {{ yield dialog(name="secret", items=.Secrets) }}