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

Function printImageTree

cli/command/image/tree.go:241–348  ·  view source on GitHub ↗
(outs command.Streams, view treeView)

Source from the content-addressed store, hash-verified

239}
240
241func printImageTree(outs command.Streams, view treeView) {
242 out := tui.NewOutput(outs.Out())
243 isTerm := out.IsTerminal()
244
245 _, width := out.GetTtySize()
246 limitWidth := width == 0
247 if isTerm && width < 20 {
248 width = 20
249 }
250
251 topNameColor := out.Color(aec.NewBuilder(aec.BlueF, aec.Bold).ANSI)
252 normalColor := out.Color(tui.ColorSecondary)
253 untaggedColor := out.Color(tui.ColorTertiary)
254 titleColor := out.Color(tui.ColorTitle)
255
256 // Legend is right-aligned, so don't print it if the width is unlimited
257 if !limitWidth {
258 out.Println(generateLegend(out, width))
259 }
260
261 possibleChips := getPossibleChips(view)
262 columns := []imgColumn{
263 {
264 Title: "Image",
265 Align: alignLeft,
266 Width: 0,
267 NoEllipsis: true,
268 },
269 {
270 Title: "ID",
271 Align: alignLeft,
272 Width: 12,
273 DetailsValue: func(d *imageDetails) string {
274 return formatter.TruncateID(d.ID)
275 },
276 },
277 {
278 Title: "Disk usage",
279 Align: alignRight,
280 Width: 10,
281 DetailsValue: func(d *imageDetails) string {
282 return d.DiskUsage
283 },
284 },
285 {
286 Title: "Content size",
287 Align: alignRight,
288 Width: 12,
289 DetailsValue: func(d *imageDetails) string {
290 return d.ContentSize
291 },
292 },
293 {
294 Title: "Extra",
295 Align: alignLeft,
296 Width: func() int {
297 maxChipsWidth := 0
298 for _, chip := range possibleChips {

Callers 3

runTreeFunction · 0.85
TestPrintImageTreeGoldenFunction · 0.85

Calls 14

ColorMethod · 0.95
PrintlnMethod · 0.95
SprintMethod · 0.95
generateLegendFunction · 0.85
getPossibleChipsFunction · 0.85
adjustColumnsFunction · 0.85
printNamesFunction · 0.85
printDetailsFunction · 0.85
printChildrenFunction · 0.85
GetTtySizeMethod · 0.80
OutMethod · 0.65
StringMethod · 0.65

Tested by 2

TestPrintImageTreeGoldenFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…