(req dto.PageContainer, containers []container.Summary)
| 2171 | } |
| 2172 | |
| 2173 | func searchWithFilter(req dto.PageContainer, containers []container.Summary) []dto.ContainerInfo { |
| 2174 | var ( |
| 2175 | records []dto.ContainerInfo |
| 2176 | list []container.Summary |
| 2177 | ) |
| 2178 | |
| 2179 | if req.ExcludeAppStore { |
| 2180 | for _, item := range containers { |
| 2181 | if created, ok := item.Labels[composeCreatedBy]; ok && created == "Apps" { |
| 2182 | continue |
| 2183 | } |
| 2184 | list = append(list, item) |
| 2185 | } |
| 2186 | } else { |
| 2187 | list = containers |
| 2188 | } |
| 2189 | |
| 2190 | if len(req.Name) != 0 { |
| 2191 | length, count := len(list), 0 |
| 2192 | for count < length { |
| 2193 | if !strings.Contains(list[count].Names[0][1:], req.Name) && !strings.Contains(list[count].Image, req.Name) { |
| 2194 | list = append(list[:count], list[(count+1):]...) |
| 2195 | length-- |
| 2196 | } else { |
| 2197 | count++ |
| 2198 | } |
| 2199 | } |
| 2200 | } |
| 2201 | if req.State != "all" { |
| 2202 | length, count := len(list), 0 |
| 2203 | for count < length { |
| 2204 | if list[count].State != req.State { |
| 2205 | list = append(list[:count], list[(count+1):]...) |
| 2206 | length-- |
| 2207 | } else { |
| 2208 | count++ |
| 2209 | } |
| 2210 | } |
| 2211 | } |
| 2212 | switch req.OrderBy { |
| 2213 | case "name": |
| 2214 | sort.Slice(list, func(i, j int) bool { |
| 2215 | if req.Order == constant.OrderAsc { |
| 2216 | return list[i].Names[0][1:] < list[j].Names[0][1:] |
| 2217 | } |
| 2218 | return list[i].Names[0][1:] > list[j].Names[0][1:] |
| 2219 | }) |
| 2220 | default: |
| 2221 | sort.Slice(list, func(i, j int) bool { |
| 2222 | if req.Order == constant.OrderAsc { |
| 2223 | return list[i].Created < list[j].Created |
| 2224 | } |
| 2225 | return list[i].Created > list[j].Created |
| 2226 | }) |
| 2227 | } |
| 2228 | for _, item := range list { |
| 2229 | IsFromCompose := false |
| 2230 | if _, ok := item.Labels[composeProjectLabel]; ok { |
no test coverage detected