getPossibleChips returns the list of chips used by at least one image. It is used to determine which columns to print (and how much width to reserve).
(view treeView)
| 208 | // It is used to determine which columns to print (and how much width to |
| 209 | // reserve). |
| 210 | func getPossibleChips(view treeView) (chips []imageChip) { |
| 211 | remaining := slices.Clone(allChips) |
| 212 | |
| 213 | check := func(d imageDetails) (done bool) { |
| 214 | // filter without allocating |
| 215 | out := remaining[:0] |
| 216 | for _, chip := range remaining { |
| 217 | if chip.check(&d) { |
| 218 | chips = append(chips, chip) |
| 219 | continue |
| 220 | } |
| 221 | out = append(out, chip) |
| 222 | } |
| 223 | remaining = out |
| 224 | return len(remaining) == 0 |
| 225 | } |
| 226 | |
| 227 | for _, img := range view.images { |
| 228 | if check(img.Details) { |
| 229 | return chips |
| 230 | } |
| 231 | for _, c := range img.Children { |
| 232 | if check(c.Details) { |
| 233 | return chips |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | return chips |
| 239 | } |
| 240 | |
| 241 | func printImageTree(outs command.Streams, view treeView) { |
| 242 | out := tui.NewOutput(outs.Out()) |
no test coverage detected
searching dependent graphs…