(req request.AppUpdateVersion)
| 568 | } |
| 569 | |
| 570 | func (a *AppInstallService) GetUpdateVersions(req request.AppUpdateVersion) ([]dto.AppVersion, error) { |
| 571 | install, err := appInstallRepo.GetFirst(repo.WithByID(req.AppInstallID)) |
| 572 | var versions []dto.AppVersion |
| 573 | if err != nil { |
| 574 | return versions, err |
| 575 | } |
| 576 | app, err := appRepo.GetFirst(repo.WithByID(install.AppId)) |
| 577 | if err != nil { |
| 578 | return versions, err |
| 579 | } |
| 580 | details, err := appDetailRepo.GetBy(appDetailRepo.WithAppId(app.ID)) |
| 581 | if err != nil { |
| 582 | return versions, err |
| 583 | } |
| 584 | for _, detail := range details { |
| 585 | ignores, _ := appIgnoreUpgradeRepo.List(runtimeRepo.WithDetailId(detail.ID), appIgnoreUpgradeRepo.WithScope("version")) |
| 586 | if len(ignores) > 0 { |
| 587 | continue |
| 588 | } |
| 589 | if common.IsCrossVersion(install.Version, detail.Version) && !app.CrossVersionUpdate { |
| 590 | continue |
| 591 | } |
| 592 | canUpgrade := common.CompareVersion(detail.Version, install.Version) |
| 593 | if app.Key == vllmAppKeyForUpgrade { |
| 594 | currentImage := loadVllmImageFromEnv(install.Env) |
| 595 | canUpgrade = isVllmUpgradeCandidate(install.Version, detail.Version, currentImage) |
| 596 | } |
| 597 | if canUpgrade { |
| 598 | var newCompose string |
| 599 | if req.UpdateVersion != "" && req.UpdateVersion == detail.Version && detail.DockerCompose == "" && !app.IsLocalApp() { |
| 600 | filename := filepath.Base(detail.DownloadUrl) |
| 601 | dockerComposeUrl := fmt.Sprintf("%s%s", strings.TrimSuffix(detail.DownloadUrl, filename), "docker-compose.yml") |
| 602 | statusCode, composeRes, err := req_helper.HandleRequest(dockerComposeUrl, http.MethodGet, constant.TimeOut20s) |
| 603 | if err != nil { |
| 604 | return versions, err |
| 605 | } |
| 606 | if statusCode > 200 { |
| 607 | return versions, err |
| 608 | } |
| 609 | detail.DockerCompose = string(composeRes) |
| 610 | _ = appDetailRepo.Update(context.Background(), detail) |
| 611 | } |
| 612 | newCompose, err = getUpgradeCompose(install, detail) |
| 613 | if err != nil { |
| 614 | return versions, err |
| 615 | } |
| 616 | if app.Key == constant.AppMysql { |
| 617 | majorVersion := getMajorVersion(install.Version) |
| 618 | if !strings.HasPrefix(detail.Version, majorVersion) { |
| 619 | continue |
| 620 | } |
| 621 | } |
| 622 | versions = append(versions, dto.AppVersion{ |
| 623 | Version: detail.Version, |
| 624 | DetailId: detail.ID, |
| 625 | DockerCompose: newCompose, |
| 626 | }) |
| 627 | } |
nothing calls this directly
no test coverage detected