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

Function NewTemplateInspectorFromString

cli/command/inspect/inspector.go:48–65  ·  view source on GitHub ↗

NewTemplateInspectorFromString creates a new TemplateInspector from a string which is compiled into a template.

(out io.Writer, tmplStr string)

Source from the content-addressed store, hash-verified

46// NewTemplateInspectorFromString creates a new TemplateInspector from a string
47// which is compiled into a template.
48func NewTemplateInspectorFromString(out io.Writer, tmplStr string) (Inspector, error) {
49 if out == nil {
50 return nil, errors.New("no output stream")
51 }
52 if tmplStr == "" {
53 return NewIndentedInspector(out), nil
54 }
55
56 if tmplStr == "json" {
57 return NewJSONInspector(out), nil
58 }
59
60 tmpl, err := templates.Parse(tmplStr)
61 if err != nil {
62 return nil, fmt.Errorf("template parsing error: %w", err)
63 }
64 return NewTemplateInspector(out, tmpl), nil
65}
66
67// GetRefFunc is a function which used by Inspect to fetch an object from a
68// reference

Callers 2

InspectFunction · 0.85

Calls 3

NewIndentedInspectorFunction · 0.85
NewJSONInspectorFunction · 0.85
NewTemplateInspectorFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…