diff --git a/biz/docker/config.go b/biz/docker/config.go index 74549c8..da6d536 100644 --- a/biz/docker/config.go +++ b/biz/docker/config.go @@ -60,7 +60,7 @@ func ConfigUpdate(info *model.ConfigUpdateInfo) error { //spec.Name = info.Name //spec.Data = []byte(info.Data) spec.Labels = info.Labels.ToMap() - return cli.ConfigUpdate(ctx, info.ID, cfg.Version, spec) + return cli.ConfigUpdate(ctx, info.ID, version(info.Version), spec) }) } diff --git a/biz/docker/docker.go b/biz/docker/docker.go index db4929f..7efceb3 100644 --- a/biz/docker/docker.go +++ b/biz/docker/docker.go @@ -7,6 +7,7 @@ import ( "github.com/cuigh/auxo/log" "github.com/cuigh/swirl/misc" + "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" ) @@ -61,3 +62,7 @@ func (m *manager) Logger() *log.Logger { } return m.logger } + +func version(v uint64) swarm.Version { + return swarm.Version{Index: v} +} diff --git a/biz/docker/node.go b/biz/docker/node.go index 7f5385b..0e82a99 100644 --- a/biz/docker/node.go +++ b/biz/docker/node.go @@ -64,15 +64,12 @@ func NodeInspect(id string) (node swarm.Node, raw []byte, err error) { // NodeUpdate update a node. func NodeUpdate(id string, info *model.NodeUpdateInfo) error { return mgr.Do(func(ctx context.Context, cli *client.Client) (err error) { - version := swarm.Version{ - Index: info.Version, - } spec := swarm.NodeSpec{ Role: info.Role, Availability: info.Availability, } spec.Name = info.Name spec.Labels = info.Labels.ToMap() - return cli.NodeUpdate(ctx, id, version, spec) + return cli.NodeUpdate(ctx, id, version(info.Version), spec) }) } diff --git a/biz/docker/secret.go b/biz/docker/secret.go index 9ff85ae..d67c44c 100644 --- a/biz/docker/secret.go +++ b/biz/docker/secret.go @@ -60,7 +60,7 @@ func SecretUpdate(info *model.ConfigUpdateInfo) error { //spec.Name = info.Name //spec.Data = []byte(info.Data) spec.Labels = info.Labels.ToMap() - return cli.SecretUpdate(ctx, info.ID, secret.Version, spec) + return cli.SecretUpdate(ctx, info.ID, version(info.Version), spec) }) } diff --git a/biz/docker/service.go b/biz/docker/service.go index b0a10d8..000efb1 100644 --- a/biz/docker/service.go +++ b/biz/docker/service.go @@ -308,7 +308,7 @@ func ServiceUpdate(info *model.ServiceInfo) error { RegistryAuthFrom: types.RegistryAuthFromSpec, QueryRegistry: false, } - resp, err := cli.ServiceUpdate(context.Background(), info.Name, service.Version, spec, options) + resp, err := cli.ServiceUpdate(context.Background(), info.Name, version(info.Version), spec, options) if err == nil && len(resp.Warnings) > 0 { mgr.Logger().Warnf("service %s was updated but got warnings: %v", info.Name, resp.Warnings) } @@ -720,6 +720,7 @@ func ServiceRollback(name string) error { options := types.ServiceUpdateOptions{ RegistryAuthFrom: types.RegistryAuthFromPreviousSpec, QueryRegistry: false, + Rollback: "previous", } resp, err := cli.ServiceUpdate(context.Background(), name, service.Version, spec, options) if err == nil && len(resp.Warnings) > 0 { diff --git a/biz/user.go b/biz/user.go index 8226162..0ef8606 100644 --- a/biz/user.go +++ b/biz/user.go @@ -9,7 +9,7 @@ import ( "github.com/cuigh/auxo/errors" "github.com/cuigh/auxo/log" "github.com/cuigh/auxo/net/web" - "github.com/cuigh/auxo/security/password" + "github.com/cuigh/auxo/security/passwd" "github.com/cuigh/swirl/dao" "github.com/cuigh/swirl/misc" "github.com/cuigh/swirl/model" @@ -43,7 +43,7 @@ func (b *userBiz) Create(user *model.User, ctxUser web.User) (err error) { user.CreatedAt = time.Now() user.UpdatedAt = user.CreatedAt if user.Type == model.UserTypeInternal { - user.Password, user.Salt, err = password.Generate(user.Password) + user.Password, user.Salt, err = passwd.Generate(user.Password) if err != nil { return } @@ -107,12 +107,12 @@ func (b *userBiz) UpdatePassword(id, oldPwd, newPwd string) (err error) { return } - if !password.Validate(oldPwd, user.Password, user.Salt) { + if !passwd.Validate(oldPwd, user.Password, user.Salt) { err = errors.New("Current password is incorrect") return } - pwd, salt, err = password.Generate(newPwd) + pwd, salt, err = passwd.Generate(newPwd) if err != nil { return } @@ -189,7 +189,7 @@ func (b *userBiz) Login(name, pwd string) (token string, err error) { } func (b *userBiz) loginInternal(user *model.User, pwd string) error { - if !password.Validate(pwd, user.Password, user.Salt) { + if !passwd.Validate(pwd, user.Password, user.Salt) { return ErrIncorrectAuth } return nil diff --git a/model/docker.go b/model/docker.go index 2964c8f..7410818 100644 --- a/model/docker.go +++ b/model/docker.go @@ -163,6 +163,7 @@ func NewServiceDetailInfo(service swarm.Service) *ServiceDetailInfo { type ServiceInfo struct { Name string `json:"name"` + Version uint64 `json:"version"` Registry string `json:"registry"` RegistryURL string `json:"-"` RegistryAuth string `json:"-"` @@ -236,7 +237,8 @@ type ServiceInfo struct { func NewServiceInfo(service swarm.Service) *ServiceInfo { spec := service.Spec si := &ServiceInfo{ - Name: spec.Name, + Name: spec.Name, + Version: service.Version.Index, //Hostname: spec.TaskTemplate.ContainerSpec.Hostname, Image: spec.TaskTemplate.ContainerSpec.Image, Command: strings.Join(spec.TaskTemplate.ContainerSpec.Command, " "), @@ -549,7 +551,8 @@ type ConfigCreateInfo struct { } type ConfigUpdateInfo struct { - ID string `json:"id"` + ID string `json:"id"` + Version uint64 `json:"version"` ConfigCreateInfo } diff --git a/views/config/edit.jet b/views/config/edit.jet index efb4549..5a79e19 100644 --- a/views/config/edit.jet +++ b/views/config/edit.jet @@ -48,6 +48,7 @@
+ {*
*} {**} {*
*} diff --git a/views/secret/edit.jet b/views/secret/edit.jet index 9cda287..01d4f1b 100644 --- a/views/secret/edit.jet +++ b/views/secret/edit.jet @@ -48,6 +48,7 @@
+
{{ yield options(name="label", items=.Secret.Spec.Labels) }} diff --git a/views/service/edit.jet b/views/service/edit.jet index e7c3df3..3bf2c91 100644 --- a/views/service/edit.jet +++ b/views/service/edit.jet @@ -36,6 +36,7 @@
+