fix: 镜像操作状态获取、显示优化

This commit is contained in:
ssongliu
2023-02-14 11:28:38 +08:00
committed by ssongliu
parent bce1995969
commit b0e23ec2c7
26 changed files with 162 additions and 84 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
"github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
@@ -65,18 +66,16 @@ func (u *ImageRepoService) Create(req dto.ImageRepoCreate) error {
}
if req.Protocol == "http" {
_ = u.handleRegistries(req.DownloadUrl, "", "create")
stdout, err := cmd.Exec("systemctl restart docker")
if err != nil {
return errors.New(string(stdout))
}
}
if err := copier.Copy(&imageRepo, &req); err != nil {
return errors.WithMessage(constant.ErrStructTransform, err.Error())
}
cmd := exec.Command("systemctl", "restart", "docker")
stdout, err := cmd.CombinedOutput()
if err != nil {
return errors.New(string(stdout))
}
imageRepo.Status = constant.StatusSuccess
if err := u.checkConn(req.DownloadUrl, req.Username, req.Password); err != nil {
imageRepo.Status = constant.StatusFailed