mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-12-11 23:19:09 +08:00
feat: 应用安装增加镜像拉取 (#1517)
This commit is contained in:
parent
fdf2a9d247
commit
555a32c273
@ -576,8 +576,14 @@ func upApp(appInstall *model.AppInstall) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = composeService.ComposePull()
|
||||
if err != nil {
|
||||
appInstall.Status = constant.PullErr
|
||||
return err
|
||||
}
|
||||
err = composeService.ComposeUp()
|
||||
if err != nil {
|
||||
appInstall.Status = constant.Error
|
||||
return err
|
||||
}
|
||||
return
|
||||
@ -586,8 +592,14 @@ func upApp(appInstall *model.AppInstall) {
|
||||
}
|
||||
}
|
||||
if err := upProject(appInstall); err != nil {
|
||||
appInstall.Status = constant.Error
|
||||
appInstall.Message = err.Error()
|
||||
otherMsg := ""
|
||||
if strings.Contains(err.Error(), "no such host") {
|
||||
otherMsg = i18n.GetMsgByKey("ErrNoSuchHost") + ":"
|
||||
}
|
||||
if strings.Contains(err.Error(), "timeout") {
|
||||
otherMsg = i18n.GetMsgByKey("ErrImagePullTimeOut") + ":"
|
||||
}
|
||||
appInstall.Message = otherMsg + err.Error()
|
||||
} else {
|
||||
appInstall.Status = constant.Running
|
||||
}
|
||||
@ -751,7 +763,7 @@ func handleErr(install model.AppInstall, err error, out string) error {
|
||||
func handleInstalled(appInstallList []model.AppInstall, updated bool) ([]response.AppInstalledDTO, error) {
|
||||
var res []response.AppInstalledDTO
|
||||
for _, installed := range appInstallList {
|
||||
if updated && installed.App.Type == "php" || installed.Status == constant.Installing {
|
||||
if updated && (installed.App.Type == "php" || installed.Status == constant.Installing) {
|
||||
continue
|
||||
}
|
||||
installDTO := response.AppInstalledDTO{
|
||||
|
@ -11,6 +11,7 @@ const (
|
||||
DirNotFound = "DirNotFound"
|
||||
Upgrading = "Upgrading"
|
||||
UpgradeErr = "UpgradeErr"
|
||||
PullErr = "PullErr"
|
||||
|
||||
ContainerPrefix = "1Panel-"
|
||||
|
||||
|
@ -40,6 +40,7 @@ ErrHttpReqTimeOut: "Request timed out {{.err}}"
|
||||
ErrHttpReqFailed: "Request failed {{.err}}"
|
||||
ErrHttpReqNotFound: "The file does not exist"
|
||||
ErrNoSuchHost: "Network connection failed"
|
||||
ErrImagePullTimeOut: 'Image pull timeout'
|
||||
|
||||
#file
|
||||
ErrFileCanNotRead: "File can not read"
|
||||
|
@ -40,6 +40,7 @@ ErrHttpReqTimeOut: "請求超時 {{.err}}"
|
||||
ErrHttpReqFailed: "請求失敗 {{.err}}"
|
||||
ErrHttpReqNotFound: "文件不存在"
|
||||
ErrNoSuchHost: "網路連接失敗"
|
||||
ErrImagePullTimeOut: "鏡像拉取超時"
|
||||
|
||||
#file
|
||||
ErrFileCanNotRead: "此文件不支持預覽"
|
||||
|
@ -40,6 +40,7 @@ ErrHttpReqTimeOut: "请求超时 {{.err}}"
|
||||
ErrHttpReqFailed: "请求失败 {{.err}}"
|
||||
ErrHttpReqNotFound: "文件不存在"
|
||||
ErrNoSuchHost: "网络连接失败"
|
||||
ErrImagePullTimeOut: '镜像拉取超时'
|
||||
|
||||
#file
|
||||
ErrFileCanNotRead: "此文件不支持预览"
|
||||
|
@ -89,6 +89,10 @@ func (s *ComposeService) ComposeBuild() error {
|
||||
return s.Build(context.Background(), s.project, api.BuildOptions{})
|
||||
}
|
||||
|
||||
func (s *ComposeService) ComposePull() error {
|
||||
return s.Pull(context.Background(), s.project, api.PullOptions{})
|
||||
}
|
||||
|
||||
func GetComposeProject(projectName, workDir string, yml []byte, env []byte, skipNormalization bool) (*types.Project, error) {
|
||||
var configFiles []types.ConfigFile
|
||||
configFiles = append(configFiles, types.ConfigFile{
|
||||
|
@ -209,6 +209,7 @@ const message = {
|
||||
downloaderr: 'Download Error',
|
||||
upgrading: 'Upgrading',
|
||||
upgradeerr: 'Upgrade Error',
|
||||
pullerr: 'Pull Image Error',
|
||||
},
|
||||
units: {
|
||||
second: 'Second',
|
||||
|
@ -208,6 +208,7 @@ const message = {
|
||||
downloaderr: '下載失敗',
|
||||
upgrading: '升級中',
|
||||
upgradeerr: '升級失敗',
|
||||
pullerr: '鏡像拉取失敗',
|
||||
},
|
||||
units: {
|
||||
second: '秒',
|
||||
|
@ -208,6 +208,7 @@ const message = {
|
||||
downloaderr: '下载失败',
|
||||
upgrading: '升级中',
|
||||
upgradeerr: '升级失败',
|
||||
pullerr: '镜像拉取失败',
|
||||
},
|
||||
units: {
|
||||
second: '秒',
|
||||
|
@ -175,7 +175,7 @@ const handleParams = () => {
|
||||
if (p.type === 'service' || p.type === 'apps') {
|
||||
rules[p.envKey] = [Rules.requiredSelect];
|
||||
if (p.child) {
|
||||
p.childProp = p.child.envKey;
|
||||
p.childProp = propStart.value + p.child.envKey;
|
||||
if (p.child.type === 'service') {
|
||||
rules[p.child.envKey] = [Rules.requiredSelect];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user