|
|
@ -118,9 +118,13 @@ var DatabaseKeys = map[string]uint{
|
|
|
|
"memcached": 11211,
|
|
|
|
"memcached": 11211,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ToolKeys = map[string]uint{
|
|
|
|
|
|
|
|
"minio": 9001,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall, params map[string]interface{}) error {
|
|
|
|
func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall, params map[string]interface{}) error {
|
|
|
|
var dbConfig dto.AppDatabase
|
|
|
|
var dbConfig dto.AppDatabase
|
|
|
|
if app.Type == "runtime" && DatabaseKeys[app.Key] > 0 {
|
|
|
|
if DatabaseKeys[app.Key] > 0 {
|
|
|
|
database := &model.Database{
|
|
|
|
database := &model.Database{
|
|
|
|
AppInstallID: appInstall.ID,
|
|
|
|
AppInstallID: appInstall.ID,
|
|
|
|
Name: appInstall.Name,
|
|
|
|
Name: appInstall.Name,
|
|
|
@ -153,21 +157,23 @@ func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall
|
|
|
|
case "mysql", "mariadb", "postgresql", "mongodb":
|
|
|
|
case "mysql", "mariadb", "postgresql", "mongodb":
|
|
|
|
if password, ok := params["PANEL_DB_ROOT_PASSWORD"]; ok {
|
|
|
|
if password, ok := params["PANEL_DB_ROOT_PASSWORD"]; ok {
|
|
|
|
if password != "" {
|
|
|
|
if password != "" {
|
|
|
|
|
|
|
|
database.Password = password.(string)
|
|
|
|
|
|
|
|
if app.Key == "mysql" || app.Key == "mariadb" {
|
|
|
|
|
|
|
|
database.Username = "root"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if rootUser, ok := params["PANEL_DB_ROOT_USER"]; ok {
|
|
|
|
|
|
|
|
database.Username = rootUser.(string)
|
|
|
|
|
|
|
|
}
|
|
|
|
authParam := dto.AuthParam{
|
|
|
|
authParam := dto.AuthParam{
|
|
|
|
RootPassword: password.(string),
|
|
|
|
RootPassword: password.(string),
|
|
|
|
|
|
|
|
RootUser: database.Username,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
authByte, err := json.Marshal(authParam)
|
|
|
|
authByte, err := json.Marshal(authParam)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
appInstall.Param = string(authByte)
|
|
|
|
appInstall.Param = string(authByte)
|
|
|
|
database.Password = password.(string)
|
|
|
|
|
|
|
|
if app.Key == "mysql" || app.Key == "mariadb" {
|
|
|
|
|
|
|
|
database.Username = "root"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if rootUser, ok := params["PANEL_DB_ROOT_USER"]; ok {
|
|
|
|
|
|
|
|
database.Username = rootUser.(string)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case "redis":
|
|
|
|
case "redis":
|
|
|
@ -189,6 +195,23 @@ func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ToolKeys[app.Key] > 0 {
|
|
|
|
|
|
|
|
if app.Key == "minio" {
|
|
|
|
|
|
|
|
authParam := dto.MinioAuthParam{}
|
|
|
|
|
|
|
|
if password, ok := params["PANEL_MINIO_ROOT_PASSWORD"]; ok {
|
|
|
|
|
|
|
|
authParam.RootPassword = password.(string)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if rootUser, ok := params["PANEL_MINIO_ROOT_USER"]; ok {
|
|
|
|
|
|
|
|
authParam.RootUser = rootUser.(string)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
authByte, err := json.Marshal(authParam)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
appInstall.Param = string(authByte)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if app.Type == "website" || app.Type == "tool" {
|
|
|
|
if app.Type == "website" || app.Type == "tool" {
|
|
|
|
paramByte, err := json.Marshal(params)
|
|
|
|
paramByte, err := json.Marshal(params)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|