MCPcopy Index your code
hub / github.com/docker/cli / getPossibleChips

Function getPossibleChips

cli/command/image/tree.go:210–239  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

208// It is used to determine which columns to print (and how much width to
209// reserve).
210func 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
241func printImageTree(outs command.Streams, view treeView) {
242 out := tui.NewOutput(outs.Out())

Callers 1

printImageTreeFunction · 0.85

Calls 1

checkFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…