(install *model.AppInstall, allowedOrigins []string)
| 493 | } |
| 494 | |
| 495 | func migrateOpenclawInstallEnv(install *model.AppInstall, allowedOrigins []string) error { |
| 496 | if install == nil { |
| 497 | return nil |
| 498 | } |
| 499 | envMap := make(map[string]interface{}) |
| 500 | if strings.TrimSpace(install.Env) != "" { |
| 501 | if err := json.Unmarshal([]byte(install.Env), &envMap); err != nil { |
| 502 | return err |
| 503 | } |
| 504 | } |
| 505 | if install.HttpsPort > 0 { |
| 506 | envMap["PANEL_APP_PORT_HTTPS"] = install.HttpsPort |
| 507 | } else { |
| 508 | delete(envMap, "PANEL_APP_PORT_HTTPS") |
| 509 | } |
| 510 | if install.HttpPort > 0 { |
| 511 | envMap["PANEL_APP_PORT_HTTP"] = install.HttpPort |
| 512 | } |
| 513 | if install.HttpPort == 0 { |
| 514 | delete(envMap, "PANEL_APP_PORT_HTTP") |
| 515 | } |
| 516 | if allowedOrigin := firstAllowedOrigin(allowedOrigins); allowedOrigin != "" { |
| 517 | envMap["ALLOWED_ORIGIN"] = allowedOrigin |
| 518 | } else { |
| 519 | delete(envMap, "ALLOWED_ORIGIN") |
| 520 | } |
| 521 | payload, err := json.Marshal(envMap) |
| 522 | if err != nil { |
| 523 | return err |
| 524 | } |
| 525 | install.Env = string(payload) |
| 526 | return nil |
| 527 | } |
| 528 | |
| 529 | func syncOpenclawAllowedOriginEnv(install *model.AppInstall, allowedOrigins []string) error { |
| 530 | if install == nil { |
no test coverage detected