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

Function runImages

cli/command/image/list.go:88–147  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, options imagesOptions)

Source from the content-addressed store, hash-verified

86}
87
88func runImages(ctx context.Context, dockerCLI command.Cli, options imagesOptions) (int, error) {
89 filters := options.filter.Value()
90 if options.matchName != "" {
91 filters.Add("reference", options.matchName)
92 }
93
94 useTree, err := shouldUseTree(options)
95 if err != nil {
96 return 0, err
97 }
98
99 listOpts := client.ImageListOptions{
100 All: options.all,
101 Filters: filters,
102 Manifests: useTree,
103 }
104
105 res, err := dockerCLI.Client().ImageList(ctx, listOpts)
106 if err != nil {
107 return 0, err
108 }
109
110 images := res.Items
111 if !options.all {
112 if dangling, ok := filters["dangling"]; !ok || dangling["false"] {
113 images = slices.DeleteFunc(images, isDangling)
114 }
115 }
116
117 format := options.format
118 if len(format) == 0 {
119 if len(dockerCLI.ConfigFile().ImagesFormat) > 0 && !options.quiet && !options.tree {
120 format = dockerCLI.ConfigFile().ImagesFormat
121 useTree = false
122 } else {
123 format = formatter.TableFormatKey
124 }
125 }
126
127 if useTree {
128 return runTree(ctx, dockerCLI, treeOptions{
129 images: images,
130 filters: filters,
131 expanded: options.tree,
132 })
133 }
134
135 imageCtx := formatter.ImageContext{
136 Context: formatter.Context{
137 Output: dockerCLI.Out(),
138 Format: formatter.NewImageFormat(format, options.quiet, options.showDigests),
139 Trunc: !options.noTrunc,
140 },
141 Digest: options.showDigests,
142 }
143 if err := formatter.ImageWrite(imageCtx, images); err != nil {
144 return 0, err
145 }

Callers 1

newImagesCommandFunction · 0.85

Calls 7

shouldUseTreeFunction · 0.85
runTreeFunction · 0.85
ValueMethod · 0.65
ClientMethod · 0.65
ConfigFileMethod · 0.65
OutMethod · 0.65
ImageListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…