feat: 创建运行环境逻辑修改 (#1079)

pull/1083/head
zhengkunwang223 2 years ago committed by GitHub
parent d065558865
commit 205e32dde8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -236,7 +236,7 @@ func upgradeInstall(installId uint, detailId uint) error {
defer func() {
if upErr != nil {
install.Status = constant.UpgradeErr
install.Message = err.Error()
install.Message = upErr.Error()
_ = appInstallRepo.Save(context.Background(), &install)
}
}()
@ -318,6 +318,11 @@ func upgradeInstall(installId uint, detailId uint) error {
return
}
fileOp := files.NewFileOp()
envParams := make(map[string]string, len(envs))
handleMap(envs, envParams)
if err = env.Write(envParams, install.GetEnvPath()); err != nil {
return
}
if upErr = fileOp.WriteFile(install.GetComposePath(), strings.NewReader(install.DockerCompose), 0775); upErr != nil {
return
}
@ -424,9 +429,11 @@ func downloadApp(app model.App, appDetail model.AppDetail, appInstall *model.App
defer func() {
if err != nil {
if appInstall != nil {
appInstall.Status = constant.DownloadErr
appInstall.Message = err.Error()
}
}
}()
if err = fileOp.DownloadFile(appDetail.DownloadUrl, filePath); err != nil {

@ -64,7 +64,13 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (err error) {
return err
}
fileOp := files.NewFileOp()
buildDir := path.Join(constant.AppResourceDir, app.Key, "versions", appDetail.Version, "build")
appVersionDir := path.Join(constant.AppResourceDir, app.Resource, app.Key, appDetail.Version)
if !fileOp.Stat(appVersionDir) {
if err := downloadApp(app, appDetail, nil); err != nil {
return err
}
}
buildDir := path.Join(appVersionDir, "build")
if !fileOp.Stat(buildDir) {
return buserr.New(constant.ErrDirNotFound)
}

Loading…
Cancel
Save