mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
fix: 修改重名容器校验规则 (#1550)
This commit is contained in:
parent
b5a1ffe338
commit
8212ff117b
@ -287,7 +287,7 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerOperate) error {
|
|||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
newContainer, _ := client.ContainerInspect(ctx, req.Name)
|
newContainer, _ := client.ContainerInspect(ctx, req.Name)
|
||||||
if len(newContainer.ID) != 0 {
|
if newContainer.ContainerJSONBase != nil {
|
||||||
return buserr.New(constant.ErrContainerName)
|
return buserr.New(constant.ErrContainerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ func (u *ContainerService) ContainerUpdate(req dto.ContainerOperate) error {
|
|||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
newContainer, _ := client.ContainerInspect(ctx, req.Name)
|
newContainer, _ := client.ContainerInspect(ctx, req.Name)
|
||||||
if len(newContainer.ID) != 0 && newContainer.ID != req.ContainerID {
|
if newContainer.ContainerJSONBase != nil && newContainer.ID != req.ContainerID {
|
||||||
return buserr.New(constant.ErrContainerName)
|
return buserr.New(constant.ErrContainerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ func (u *ContainerService) ContainerOperation(req dto.ContainerOperation) error
|
|||||||
err = client.ContainerUnpause(ctx, req.Name)
|
err = client.ContainerUnpause(ctx, req.Name)
|
||||||
case constant.ContainerOpRename:
|
case constant.ContainerOpRename:
|
||||||
newContainer, _ := client.ContainerInspect(ctx, req.NewName)
|
newContainer, _ := client.ContainerInspect(ctx, req.NewName)
|
||||||
if len(newContainer.ID) != 0 {
|
if newContainer.ContainerJSONBase != nil {
|
||||||
return buserr.New(constant.ErrContainerName)
|
return buserr.New(constant.ErrContainerName)
|
||||||
}
|
}
|
||||||
err = client.ContainerRename(ctx, req.Name, req.NewName)
|
err = client.ContainerRename(ctx, req.Name, req.NewName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user