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

Function runInspect

cli/command/node/inspect.go:46–77  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, opts inspectOptions)

Source from the content-addressed store, hash-verified

44}
45
46func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error {
47 apiClient := dockerCLI.Client()
48
49 if opts.pretty {
50 opts.format = "pretty"
51 }
52
53 getRef := func(ref string) (any, []byte, error) {
54 nodeRef, err := Reference(ctx, apiClient, ref)
55 if err != nil {
56 return nil, nil, err
57 }
58 res, err := apiClient.NodeInspect(ctx, nodeRef, client.NodeInspectOptions{})
59 return res.Node, res.Raw, err
60 }
61
62 // check if the user is trying to apply a template to the pretty format, which
63 // is not supported
64 if strings.HasPrefix(opts.format, "pretty") && opts.format != "pretty" {
65 return errors.New("cannot supply extra formatting options to the pretty template")
66 }
67
68 nodeCtx := formatter.Context{
69 Output: dockerCLI.Out(),
70 Format: newFormat(opts.format, false),
71 }
72
73 if err := inspectFormatWrite(nodeCtx, opts.nodeIds, getRef); err != nil {
74 return cli.StatusError{StatusCode: 1, Status: err.Error()}
75 }
76 return nil
77}

Callers 1

newInspectCommandFunction · 0.70

Calls 7

ReferenceFunction · 0.85
newFormatFunction · 0.70
inspectFormatWriteFunction · 0.70
ClientMethod · 0.65
OutMethod · 0.65
NodeInspectMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…