From 8c2d3e432dff86c85c858e1c6f394c0f69e54cb9 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Sun, 6 Aug 2023 22:28:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20redis=20=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=91=BD=E4=BB=A4=E8=A1=8C=E6=89=A7=E8=A1=8C=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E6=8F=90=E7=A4=BA=E6=9C=AA=E8=AE=A4=E8=AF=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#1858)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/repo/app_install.go | 15 ++++++++++++--- backend/app/service/app_install.go | 10 +++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/backend/app/repo/app_install.go b/backend/app/repo/app_install.go index a70abb442..00bf3742d 100644 --- a/backend/app/repo/app_install.go +++ b/backend/app/repo/app_install.go @@ -192,10 +192,19 @@ func (a *AppInstallRepo) LoadBaseInfo(key string, name string) (*RootInfo, error if err := json.Unmarshal([]byte(appInstall.Env), &envMap); err != nil { return nil, err } - password, ok := envMap["PANEL_DB_ROOT_PASSWORD"].(string) - if ok { - info.Password = password + switch app.Key { + case "mysql": + password, ok := envMap["PANEL_DB_ROOT_PASSWORD"].(string) + if ok { + info.Password = password + } + case "redis": + password, ok := envMap["PANEL_REDIS_ROOT_PASSWORD"].(string) + if ok { + info.Password = password + } } + userPassword, ok := envMap["PANEL_DB_USER_PASSWORD"].(string) if ok { info.UserPassword = userPassword diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 2b9912110..f47971b19 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -731,7 +731,11 @@ func updateInstallInfoInDB(appKey, appName, param string, isRestart bool, value envKey := "" switch param { case "password": - envKey = "PANEL_DB_ROOT_PASSWORD=" + if appKey == "mysql" { + envKey = "PANEL_DB_ROOT_PASSWORD=" + } else { + envKey = "PANEL_REDIS_ROOT_PASSWORD=" + } case "port": envKey = "PANEL_APP_PORT_HTTP=" case "user-password": @@ -760,6 +764,10 @@ func updateInstallInfoInDB(appKey, appName, param string, isRestart bool, value if param == "password" { oldVal = fmt.Sprintf("\"PANEL_DB_ROOT_PASSWORD\":\"%v\"", appInstall.Password) newVal = fmt.Sprintf("\"PANEL_DB_ROOT_PASSWORD\":\"%v\"", value) + if appKey == "redis" { + oldVal = fmt.Sprintf("\"PANEL_REDIS_ROOT_PASSWORD\":\"%v\"", appInstall.Password) + newVal = fmt.Sprintf("\"PANEL_REDIS_ROOT_PASSWORD\":\"%v\"", value) + } _ = appInstallRepo.BatchUpdateBy(map[string]interface{}{ "param": strings.ReplaceAll(appInstall.Param, oldVal, newVal), "env": strings.ReplaceAll(appInstall.Env, oldVal, newVal),