(req dto.PageContainer)
| 108 | } |
| 109 | |
| 110 | func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, error) { |
| 111 | client, err := docker.NewDockerClient() |
| 112 | if err != nil { |
| 113 | return 0, nil, err |
| 114 | } |
| 115 | defer func() { _ = client.Close() }() |
| 116 | options := container.ListOptions{All: true} |
| 117 | if len(req.Filters) != 0 { |
| 118 | options.Filters = filters.NewArgs() |
| 119 | options.Filters.Add("label", req.Filters) |
| 120 | } |
| 121 | containers, err := client.ContainerList(context.Background(), options) |
| 122 | if err != nil { |
| 123 | return 0, nil, err |
| 124 | } |
| 125 | records := searchWithFilter(req, containers) |
| 126 | |
| 127 | var backData []dto.ContainerInfo |
| 128 | total, start, end := len(records), (req.Page-1)*req.PageSize, req.Page*req.PageSize |
| 129 | if start > total { |
| 130 | backData = make([]dto.ContainerInfo, 0) |
| 131 | } else { |
| 132 | if end >= total { |
| 133 | end = total |
| 134 | } |
| 135 | backData = records[start:end] |
| 136 | } |
| 137 | |
| 138 | for i := 0; i < len(backData); i++ { |
| 139 | install, _ := appInstallRepo.GetFirst(appInstallRepo.WithContainerName(backData[i].Name)) |
| 140 | if install.ID > 0 { |
| 141 | backData[i].AppInstallName = install.Name |
| 142 | backData[i].AppName = install.App.Name |
| 143 | websites, _ := websiteRepo.GetBy(websiteRepo.WithAppInstallId(install.ID)) |
| 144 | for _, website := range websites { |
| 145 | backData[i].Websites = append(backData[i].Websites, website.PrimaryDomain) |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | return int64(total), backData, nil |
| 151 | } |
| 152 | |
| 153 | func (u *ContainerService) List() []dto.ContainerOptions { |
| 154 | var options []dto.ContainerOptions |
nothing calls this directly
no test coverage detected