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

Function inspectFormatWrite

cli/command/node/formatter.go:195–215  ·  view source on GitHub ↗

inspectFormatWrite renders the context for a list of nodes.

(fmtCtx formatter.Context, refs []string, getRef inspect.GetRefFunc)

Source from the content-addressed store, hash-verified

193
194// inspectFormatWrite renders the context for a list of nodes.
195func inspectFormatWrite(fmtCtx formatter.Context, refs []string, getRef inspect.GetRefFunc) error {
196 if fmtCtx.Format != nodeInspectPrettyTemplate {
197 return inspect.Inspect(fmtCtx.Output, refs, string(fmtCtx.Format), getRef)
198 }
199 return fmtCtx.Write(&nodeInspectContext{}, func(format func(subContext formatter.SubContext) error) error {
200 for _, ref := range refs {
201 nodeI, _, err := getRef(ref)
202 if err != nil {
203 return err
204 }
205 node, ok := nodeI.(swarm.Node)
206 if !ok {
207 return fmt.Errorf("got wrong object to inspect :%v", ok)
208 }
209 if err := format(&nodeInspectContext{Node: node}); err != nil {
210 return err
211 }
212 }
213 return nil
214 })
215}
216
217type nodeInspectContext struct {
218 swarm.Node

Callers 2

runInspectFunction · 0.70

Calls 3

formatFunction · 0.85
InspectMethod · 0.65
WriteMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…