mirror of https://github.com/1Panel-dev/1Panel
fix: 解决 app 升级,container_name 改变的BUG
parent
0e11b18cd6
commit
37bcd12c8d
|
@ -189,9 +189,7 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
|
|||
if err := checkRequiredAndLimit(app); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := copyAppData(app.Key, appDetail.Version, req.Name, req.Params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
paramByte, err := json.Marshal(req.Params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -211,16 +209,25 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
|
|||
if err := yaml.Unmarshal([]byte(appDetail.DockerCompose), &composeMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
servicesMap := composeMap["services"].(map[string]interface{})
|
||||
|
||||
value, ok := composeMap["services"]
|
||||
if !ok {
|
||||
return nil, buserr.New("")
|
||||
}
|
||||
servicesMap := value.(map[string]interface{})
|
||||
changeKeys := make(map[string]string, len(servicesMap))
|
||||
for k, v := range servicesMap {
|
||||
index := 0
|
||||
for k := range servicesMap {
|
||||
serviceName := k + "-" + common.RandStr(4)
|
||||
changeKeys[k] = serviceName
|
||||
value := v.(map[string]interface{})
|
||||
containerName := constant.ContainerPrefix + k + "-" + common.RandStr(4)
|
||||
value["container_name"] = containerName
|
||||
if index > 0 {
|
||||
continue
|
||||
}
|
||||
req.Params["CONTAINER_NAME"] = containerName
|
||||
appInstall.ServiceName = serviceName
|
||||
appInstall.ContainerName = containerName
|
||||
index++
|
||||
}
|
||||
for k, v := range changeKeys {
|
||||
servicesMap[v] = servicesMap[k]
|
||||
|
@ -232,6 +239,10 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
|
|||
}
|
||||
appInstall.DockerCompose = string(composeByte)
|
||||
|
||||
if err := copyAppData(app.Key, appDetail.Version, req.Name, req.Params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fileOp := files.NewFileOp()
|
||||
if err := fileOp.WriteFile(appInstall.GetComposePath(), strings.NewReader(string(composeByte)), 0775); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -857,7 +857,7 @@ export default {
|
|||
deleteWarn:
|
||||
'The delete operation will delete all data and backups together. This operation cannot be rolled back. Do you want to continue? ',
|
||||
syncSuccess: 'Sync successfully',
|
||||
canUpdate: 'Upgraded',
|
||||
canUpdate: 'Upgrade',
|
||||
backup: 'Backup',
|
||||
backupName: 'File Name',
|
||||
backupPath: 'File Path',
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<Header :header="$t('app.install')" :back="handleClose" />
|
||||
</template>
|
||||
|
||||
<el-row>
|
||||
<el-row v-loading="loading">
|
||||
<el-col :span="22" :offset="1">
|
||||
<el-form
|
||||
ref="paramForm"
|
||||
|
@ -64,7 +64,7 @@ let form = ref<{ [key: string]: any }>({});
|
|||
let rules = ref<FormRules>({
|
||||
NAME: [Rules.linuxName],
|
||||
});
|
||||
let loading = false;
|
||||
let loading = ref(false);
|
||||
const paramForm = ref<FormInstance>();
|
||||
const req = reactive({
|
||||
appDetailId: 0,
|
||||
|
@ -99,10 +99,15 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
req.appDetailId = installData.value.appDetailId;
|
||||
req.params = form.value;
|
||||
req.name = form.value['NAME'];
|
||||
InstallApp(req).then(() => {
|
||||
handleClose();
|
||||
router.push({ path: '/apps/installed' });
|
||||
});
|
||||
loading.value = true;
|
||||
InstallApp(req)
|
||||
.then(() => {
|
||||
handleClose();
|
||||
router.push({ path: '/apps/installed' });
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue