(appInstallList []model.AppInstall, updated, sync, checkUpdate bool)
| 1593 | } |
| 1594 | |
| 1595 | func handleInstalled(appInstallList []model.AppInstall, updated, sync, checkUpdate bool) ([]response.AppInstallDTO, error) { |
| 1596 | var ( |
| 1597 | res []response.AppInstallDTO |
| 1598 | containersMap map[string]container.Summary |
| 1599 | ) |
| 1600 | if sync { |
| 1601 | cli, err := docker.NewClient() |
| 1602 | if err == nil { |
| 1603 | defer cli.Close() |
| 1604 | containers, err := cli.ListAllContainers() |
| 1605 | if err == nil { |
| 1606 | containersMap = make(map[string]container.Summary, len(containers)) |
| 1607 | for _, contain := range containers { |
| 1608 | containersMap[contain.Names[0]] = contain |
| 1609 | } |
| 1610 | } |
| 1611 | } |
| 1612 | } |
| 1613 | |
| 1614 | for _, installed := range appInstallList { |
| 1615 | if updated && ignoreUpdate(installed) { |
| 1616 | continue |
| 1617 | } |
| 1618 | |
| 1619 | if sync && !doNotNeedSync(installed) { |
| 1620 | synAppInstall(containersMap, &installed, false) |
| 1621 | } |
| 1622 | |
| 1623 | installDTO := response.AppInstallDTO{ |
| 1624 | ID: installed.ID, |
| 1625 | Name: installed.Name, |
| 1626 | AppID: installed.AppId, |
| 1627 | AppDetailID: installed.AppDetailId, |
| 1628 | Version: installed.Version, |
| 1629 | Status: installed.Status, |
| 1630 | Message: installed.Message, |
| 1631 | HttpPort: installed.HttpPort, |
| 1632 | HttpsPort: installed.HttpsPort, |
| 1633 | AppName: installed.App.Name, |
| 1634 | AppKey: installed.App.Key, |
| 1635 | AppType: installed.App.Type, |
| 1636 | Path: installed.GetPath(), |
| 1637 | CreatedAt: installed.CreatedAt, |
| 1638 | WebUI: installed.WebUI, |
| 1639 | App: response.AppDetail{ |
| 1640 | Github: installed.App.Github, |
| 1641 | Website: installed.App.Website, |
| 1642 | Document: installed.App.Document, |
| 1643 | }, |
| 1644 | Favorite: installed.Favorite, |
| 1645 | SortOrder: installed.SortOrder, |
| 1646 | Container: installed.ContainerName, |
| 1647 | ServiceName: strings.ToLower(installed.ServiceName), |
| 1648 | } |
| 1649 | |
| 1650 | if !updated && !checkUpdate { |
| 1651 | installDTO.LinkDB = hasLinkDB(installed.ID) |
| 1652 | res = append(res, installDTO) |
no test coverage detected