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

Function Inspect

cli/command/inspect/inspector.go:73–106  ·  view source on GitHub ↗

Inspect fetches objects by reference using GetRefFunc and writes the json representation to the output writer.

(out io.Writer, references []string, tmplStr string, getRef GetRefFunc)

Source from the content-addressed store, hash-verified

71// Inspect fetches objects by reference using GetRefFunc and writes the json
72// representation to the output writer.
73func Inspect(out io.Writer, references []string, tmplStr string, getRef GetRefFunc) error {
74 if out == nil {
75 return errors.New("no output stream")
76 }
77 inspector, err := NewTemplateInspectorFromString(out, tmplStr)
78 if err != nil {
79 return cli.StatusError{StatusCode: 64, Status: err.Error()}
80 }
81
82 var errs []error
83 for _, ref := range references {
84 element, raw, err := getRef(ref)
85 if err != nil {
86 errs = append(errs, err)
87 continue
88 }
89
90 if err := inspector.Inspect(element, raw); err != nil {
91 errs = append(errs, err)
92 }
93 }
94
95 if err := inspector.Flush(); err != nil {
96 logrus.Error(err)
97 }
98
99 if err := errors.Join(errs...); err != nil {
100 return cli.StatusError{
101 StatusCode: 1,
102 Status: err.Error(),
103 }
104 }
105 return nil
106}
107
108// Inspect executes the inspect template.
109// It decodes the raw element into a map if the initial execution fails.

Callers

nothing calls this directly

Calls 4

InspectMethod · 0.65
FlushMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…